sampotter / butterfly

A library for butterfly and hierarchical matrix factorizations.
https://github.com/sampotter/butterfly
Apache License 2.0
5 stars 2 forks source link

Fixed LBO timing and attempted CHOLMOD covariance computations #7

Closed pbeckman closed 5 months ago

pbeckman commented 5 months ago

Minor bug fixes to new timing code in lbo.c

Big refactor of cheb_cov.c to allow CHOLMOD sparse Cholesky instead of diagonal lumped mass matrices. I've added a lumping flag to the command line args.

There are a number of places where we need to apply $C^{-\top}$ for a sparse Cholesky factor $C$. I've marked these as 'TODO' in cheb_cov.c. Is this possible using your existing CHOLMOD interface?

Currently the code compiles and runs fine for me with lumping: ./cheb_cov ../butterfly-LBO-models/bunny0.obj 1e-4 0 10 128 1 but I have segfault problems when I change that last lumping flag to a 0, and even if the code did run, the result would be wrong because of the need for $C^{-\top}$ instead of $C^{-1}$.

pbeckman commented 5 months ago

One other question that's likely easier to resolve --- what's the best way to load the binaries L_data.bin, L_rowptr.bin, L_colind.bin that you generated with MFEM into a sparse bfMat *L in bf_lbo.c? Do you already have such a method?

I've refactored a bit to introduce a matPath option that will point to a directory with the data, rowptr, and colind files for M and L, so all I need is a method to load sparse matrices from binaries.

sampotter commented 5 months ago

As a start, I just went ahead and merged this.

You'll want to read in L and M as BfMatCsrReal, which has bfMatCsrRealNewFromBinaryFiles. Just pass it the three paths.

If you want to convert to BfMat after, use bfMatCsrRealToMat.

Looking into $C^{-\top}$ in CHOLMOD now...

sampotter commented 5 months ago

To be explicit, something like:

BfMat *L = bfMatCsrRealToMat(bfMatCsrRealNewFromBinaryFiles("rowptr.bin", "colind.bin", "data.bin"));
...
bfMatDelete(&L);