36template <
class IT,
class NT>
38 jc(NULL), ir(NULL), num(NULL), n(0), nz(0)
43template <
class IT,
class NT>
46 assert(
size != 0 &&
n != 0);
52template <
class IT,
class NT>
63 std::copy(rhs.
jc, rhs.
jc+
n+1,
jc);
66template <
class IT,
class NT>
85 std::copy(rhs.
ir, rhs.
ir+nz, ir);
86 std::copy(rhs.
num, rhs.
num+nz, num);
89 std::copy(rhs.
jc, rhs.
jc+n+1, jc);
94template <
class IT,
class NT>
106template <
class IT,
class NT>
129 std::copy(tmpir, tmpir + nz, ir);
130 std::copy(tmpnum, tmpnum + nz, num);
134 std::copy(tmpir, tmpir + nsize, ir);
135 std::copy(tmpnum, tmpnum + nsize, num);
144template <
class IT,
class NT>
145template <
typename UnaryOperation,
typename GlobalIT>
154 for (
IT i = 0; i < n; ++i)
156 for (
IT j = jc[i]; j < jc[i+1]; ++j)
158 if (!(unary_op(std::make_tuple(rowOffset + ir[j],
159 colOffset + i, num[j]))))
168 ir =
new IT[prunednnz];
169 num =
new NT[prunednnz];
173 for (
IT i = 0; i < n; ++i)
175 for (
IT j = oldjc[i]; j < oldjc[i+1]; ++j)
177 if (!(unary_op(std::make_tuple(rowOffset + oldir[j],
178 colOffset + i, oldnum[j]))))
181 num[cnnz++] = oldnum[j];
187 assert (cnnz == prunednnz);
214template <
class IT,
class NT>
227 std::copy(jc, jc + cut + 1,
A->jc);
228 std::copy(ir, ir + jc[cut],
A->ir);
229 std::copy(num, num + jc[cut],
A->num);
233 if (nz - jc[cut] == 0)
238 std::copy(jc + cut, jc + n + 1,
B->jc);
239 transform(
B->jc,
B->jc + (n - cut + 1),
B->jc,
240 bind2nd(std::minus<IT>(), jc[cut]));
241 std::copy(ir + jc[cut], ir + nz,
B->ir);
242 std::copy(num + jc[cut], num + nz,
B->num);
248template <
class IT,
class NT>
255 assert (
A != NULL &&
B != NULL);
257 IT cnz =
A->nz +
B->nz;
263 std::copy(
A->jc,
A->jc +
A->n, jc);
264 std::copy(
B->jc,
B->jc +
B->n + 1, jc +
A->n);
265 transform(jc +
A->n, jc + cn + 1, jc +
A->n,
266 bind2nd(std::plus<IT>(),
A->jc[
A->n]));
268 std::copy(
A->ir,
A->ir +
A->nz, ir);
269 std::copy(
B->ir,
B->ir +
B->nz, ir +
A->nz);
271 std::copy(
A->num,
A->num +
A->nz, num);
272 std::copy(
B->num,
B->num +
B->nz, num +
A->nz);
void Merge(const Csc< IT, NT > *A, const Csc< IT, NT > *B, IT cut)
Csc< IT, NT > * PruneI(UnaryOperation unary_op, bool inPlace, GlobalIT rowOffset, GlobalIT colOffset)
Csc< IT, NT > & operator=(const Csc< IT, NT > &rhs)
void Resize(IT nsize)
Does not change the dimension.
void Split(Csc< IT, NT > *&A, Csc< IT, NT > *&B, IT cut)