DrTimothyAldenDavis / SuiteSparse

The official SuiteSparse library: a suite of sparse matrix algorithms authored or co-authored by Tim Davis, Texas A&M University.
https://people.engr.tamu.edu/davis/suitesparse.html
Other
1.11k stars 256 forks source link

Question: how to get origin matrix by NumericType? #777

Open DragonPara opened 4 months ago

DragonPara commented 4 months ago

by using umfpack_di_get_numeric(Lp,Lj,Lx,Up,Ui,Ux,P,Q,nullptr,nullptr,nullptr,numeric);

excuse me, how to get origin matrix?

My code are as follows(uncorrect result):

    int ptr=0;
    for (size_t i1 = 0; i1 < n; i1++)
    {
        int i = P[i1];
        for (size_t j1 = 0; j1 < n; j1++)
        {
            int j = Q[j1];
            double temp = 0;
            int lstart = Lp[i];
            int lend = Lp[i+1];
            int ustart = Up[j];
            int uend = Up[j+1];
            while(lstart<lend && ustart<uend){
                if(Lj[lstart] == Ui[ustart]){
                    temp += Lx[lstart]*Ux[ustart];
                    lstart++;
                    ustart++;
                    continue;
                }
                else if(Lj[lstart] > Ui[ustart]){
                    ustart++;
                }
                else{
                    lstart++;
                }
            }
            if(temp!=0){
                Ai2[ptr] = i1;
                Aj2[ptr] = j1;
                Ax2[ptr] = temp;
                ptr++;
            }
        }
    }
DragonPara commented 4 months ago

thanks a lot!

DrTimothyAldenDavis commented 4 months ago

The factorization doesn't include a copy of the original matrix. I don't keep a copy of it. I can use it later on in the solve step, but it must be passed in from the user application.

DragonPara commented 3 months ago

Doctor, I want to get the original matrix by the result of factorization by L*U = A.

DrTimothyAldenDavis commented 3 months ago

It's not possible. The LU factorization cannot be used to compute the original matrix