const bool is_square = optimize_diag && (csp.n_rows() == csp.n_cols());
std::vector<unsigned int> row_lengths (csp.n_rows());
for (unsigned int i=0; i<csp.n_rows(); ++i)
- row_lengths[i] = csp.row_length(i) +
- (is_square ? 1 : 0);
+ {
+ unsigned int additional_diagonal = 0;
+ if (is_square)
+ if (csp.exists(i,i) == false)
+ additional_diagonal = 1;
+
+ row_lengths[i] = csp.row_length(i) + additional_diagonal;
+ }
+
reinit (csp.n_rows(), csp.n_cols(), row_lengths, is_square);
// now enter all the elements into
}
}
- // finally compress
- // everything. this also sorts the
- // entries within each row
- compress ();
+ // do not need to compress the sparsity
+ // pattern since we already have
+ // allocated the right amount of data,
+ // and the CSP data is sorted, too.
+ compressed = true;
}
const bool is_square = optimize_diag && (csp.n_rows() == csp.n_cols());
std::vector<unsigned int> row_lengths (csp.n_rows());
for (unsigned int i=0; i<csp.n_rows(); ++i)
- row_lengths[i] = csp.row_length(i) +
- (is_square ? 1 : 0);
+ {
+ unsigned int additional_diagonal = 0;
+ if (is_square)
+ if (csp.exists(i,i) == false)
+ additional_diagonal = 1;
+
+ row_lengths[i] = csp.row_length(i) + additional_diagonal;
+ }
reinit (csp.n_rows(), csp.n_cols(), row_lengths, is_square);
// now enter all the elements into
}
}
- // finally compress
- // everything. this also sorts the
- // entries within each row
- compress ();
+ // do not need to compress the sparsity
+ // pattern since we already have
+ // allocated the right amount of data,
+ // and the CSP data is sorted, too.
+ //compress ();
+ compressed = true;
}
void
const bool is_square = optimize_diag && (csp.n_rows() == csp.n_cols());
std::vector<unsigned int> row_lengths (csp.n_rows());
for (unsigned int i=0; i<csp.n_rows(); ++i)
- row_lengths[i] = csp.row_length(i) +
- (is_square ? 1 : 0);
+ {
+ unsigned int additional_diagonal = 0;
+ if (is_square)
+ if (csp.exists(i,i) == false)
+ additional_diagonal = 1;
+
+ row_lengths[i] = csp.row_length(i) + additional_diagonal;
+ }
reinit (csp.n_rows(), csp.n_cols(), row_lengths, is_square);
// now enter all the elements into
}
}
- // finally compress
- // everything. this also sorts the
- // entries within each row
- compress ();
+ // do not need to compress the sparsity
+ // pattern since we already have
+ // allocated the right amount of data,
+ // and the CSP data is sorted, too.
+ compressed = true;
}