grid->R0 = NULL;
grid->R = NULL;
grid->next = NULL;
- grid->inks = (double*)MALLOC(sizeof(double)*(A->m));
grid->edges = edges;
grid->delete_top_level_A = 0;
grid->total_ink = -1;
if (level == 0){
double total_ink = 0;
for (i = 0; i < n; i++) {
- (grid->inks)[i] = ink1(edges[i]);
- total_ink += (grid->inks)[i];
+ grid->inks.push_back(ink1(edges[i]));
+ total_ink += grid->inks[i];
}
grid->total_ink = total_ink;
}
/* on level 0, R0 = NULL, on level 1, R0 = R */
if (grid->level > 1) SparseMatrix_delete(grid->R0);
SparseMatrix_delete(grid->R);
- free(grid->inks);
Agglomerative_Ink_Bundling_delete(grid->next);
free(grid);
int *ia = A->ia, *ja = A->ja;
int i, j, k, jj, jc, jmax, ni, nj, npicks;
pedge *edges = grid->edges;
- double *inks = grid->inks, *cinks, inki, inkj;
+ const std::vector<double> &inks = grid->inks;
+ double inki, inkj;
double gain, maxgain, minink, total_gain = 0;
int *ip = NULL, *jp = NULL, ie;
std::vector<std::vector<int>> cedges;/* a table listing the content of bundled edges in the coarsen grid.
if (Verbose > 1) fprintf(stderr,"level ===================== %d, n = %d\n",grid->level, n);
cedges.resize(n);
- cinks = (double*)MALLOC(sizeof(double)*n);
+ std::vector<double> cinks(n, 0.0);
if (grid->level > 0){
ip = grid->R0->ia;
#pragma once
+#include <vector>
+
typedef struct Agglomerative_Ink_Bundling_struct *Agglomerative_Ink_Bundling;
struct Agglomerative_Ink_Bundling_struct {
the nodes on the finest grid corresponding to the coarsest node 1, etc */
SparseMatrix R;/* striction mtrix from level to level + 1*/
Agglomerative_Ink_Bundling next;
- double *inks; /* amount of ink needed to draw this edge/bundle. Dimension n. */
+ std::vector<double> inks; /* amount of ink needed to draw this edge/bundle. Dimension n. */
double total_ink; /* amount of ink needed to draw this edge/bundle. Dimension n. */
pedge* edges; /* the original edge info. This does not vary level to level and is of dimenion n0, where n0 is the number of original edges */
int delete_top_level_A;/*whether the top level matrix should be deleted on garbage collecting the grid */