inconsistency in `cpg_csc` dimensions
ghorn opened this issue · comments
Greg Horn commented
The definition of cpg_csc
is:
// Compressed sparse column matrix
typedef struct {
cpg_int nzmax;
cpg_int n;
cpg_int m;
cpg_int *p;
cpg_int *i;
cpg_float *x;
cpg_int nz;
} cpg_csc;
Note that n
comes before m
. When matrices are defined, the code is:
def write_mat_def(f, mat, name):
"""
Write sparse matrix (scipy compressed sparse column) to file
"""
write_vec_def(f, mat['i'], name + '_i', 'cpg_int')
write_vec_def(f, mat['p'], name + '_p', 'cpg_int')
write_vec_def(f, mat['x'], name + '_x', 'cpg_float')
f.write(f'cpg_csc {name} = {{')
f.write(f'{mat["nzmax"]}, ')
f.write(f'{mat["m"]}, ')
f.write(f'{mat["n"]}, ')
f.write(f'{name}_p, ')
f.write(f'{name}_i, ')
f.write(f'{name}_x, ')
f.write(f'{mat["nz"]}}};\n')
note that n
and m
are switched.
I think the reason that this works is that n
and m
are never used. Is that correct?
Maximilian Schaller commented
Thanks for pointing this out. Indeed, nzmax
, n
, m
are not used. Fixed with #37