Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistency in cpg_csc dimensions #34

Closed
ghorn opened this issue Nov 4, 2023 · 1 comment
Closed

inconsistency in cpg_csc dimensions #34

ghorn opened this issue Nov 4, 2023 · 1 comment

Comments

@ghorn
Copy link
Contributor

ghorn commented Nov 4, 2023

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?

@maxschaller
Copy link
Collaborator

Thanks for pointing this out. Indeed, nzmax, n, m are not used. Fixed with #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants