Re: [eigen] Converting code SparseQR -> SuiteSparse SPQR

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Agreed. Thanks for looking into this. Would you mind filing this as an issue/feature request here: https://gitlab.com/libeigen/eigen/-/issues

On Tue, Mar 5, 2024 at 9:13 AM Stéphane Mottelet <stephane.mottelet@xxxxxx> wrote:

Hello,

After looking into the sources, the SPQR interface is less developped than the SparseQR one. 

For example, the assignment operator used in Q = qr.matrixQ()  is defined in SparseQR interface but not in SPQR (which explains the error I have reported). In addition, in SPQR the multiplication of qr.matrixQ() by another object is defined only for dense vectors. On the typical use cases I am testing, SuiteSparse SPQR implementation is 5 times faster than Eigen's SparseQR, so the SuiteSparse interface is worth being improved!

S.

On 3/5/24 18:01, Rasmus Munk Larsen wrote:
Sameer, Do you have any advice here?

On Tue, Mar 5, 2024 at 1:00 AM Stéphane Mottelet <stephane.mottelet@xxxxxx> wrote:
Hello,

I have a code using regular SparseQR working fine (within a Scilab gateway):

     typedef Eigen::SparseMatrix<double, 0x1, int> RealSparse_t;

     types::Sparse *pSpA = in[0]->getAs<types::Sparse>();
     types::Sparse::RealSparse_t* sp0 = pSpA->matrixReal;

     Eigen::SparseQR <types::Sparse::RealSparse_t,
Eigen::COLAMDOrdering<int> > qr;
     qr.compute(*sp0);

     pOutR = new types::Sparse(new
types::Sparse::RealSparse_t(qr.matrixR()),NULL);
     out.push_back(pOutR);

     Eigen::SparseMatrix<double> Q;
     Q = qr.matrixQ();
     pOutQ = new types::Sparse(new types::Sparse::RealSparse_t(Q),NULL);
     out.push_back(pOutQ);

I wanted to test SuiteSparse SPQR instead, but the mechanism to recover
the Householdr reflection list qr.matrixQ() as a regular matrix does not
seem to be supported, as the almost same as above following code
(Eigen::SparseQR is replaced by Eigen::SPQR and header include (not
shown here) is also updated)

     typedef Eigen::SparseMatrix<double, 0x1, int> RealSparse_t;

     types::Sparse *pSpA = in[0]->getAs<types::Sparse>();
     types::Sparse::RealSparse_t* sp0 = pSpA->matrixReal;

     Eigen::SPQR <types::Sparse::RealSparse_t> qr;
     qr.compute(*sp0);

     pOutR = new types::Sparse(new
types::Sparse::RealSparse_t(qr.matrixR()),NULL);
     out.push_back(pOutR);

     Eigen::SparseMatrix<double> Q;
     Q = qr.matrixQ();
     pOutQ = new types::Sparse(new types::Sparse::RealSparse_t(Q),NULL);
     out.push_back(pOutQ);

does not compile and yields the following error (SPQR updated code
compiles and runs fine when extracting R only):

error: no viable overloaded '='

  Q = qr.matrixQ();

How can I recover the Q matrix when using SuiteSparse SPQR ?

Thanks for your help.

--
Stéphane Mottelet
Ingénieur de recherche HDR
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet



-- 
Stéphane Mottelet
Ingénieur de recherche HDR
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/