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 <[email protected]> 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 <tel:+33%203%2044%2023%2046%2088>
    http://www.utc.fr/~mottelet
    
<https://antiphishing.vadesecure.com/v4?f=RWp5bEt5cWRvWHZLUzFDRMPAbgQqTi_Twvc24wFCNi0cD555ASVet1ojx_UaBxT5&i=RGlHYzhiRkNBWWxzVkd3ZZXoyxOFFwxcFvJQWRQCipI&k=gA0E&r=dkFaMlN1eld3UHl5NHhOVGIe9smcmSFMfwNZ5uQBEk8bbulNeA9CneplwcnM9UVa&s=bf13500add801819c20e1aafd6e6bb3c3602f2f9f2e144358c8ddd22219512d5&u=http%3A%2F%2Fwww.utc.fr%2F~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

Reply via email to