main/sc/source/core/tool/interpr5.cxx
/* Solve for X in R*X=S using back substitution. The solution X overwrites S.
 * Uses R from the result of the QR decomposition of a NxK matrix A.
 * S is a column vector given as matrix, with at least elements on index
 * 0 to K-1; elements on index>=K are ignored. Vector R must not have zero
 * elements, no check is done.
 */
Solve for X in R*X=S using back substitution. The solution X overwrites S.
Uses R from the result of the QR decomposition of a NxK matrix A.
S is a column vector given as matrix, with at least elements on index
0 to K-1; elements on index>=K are ignored. Vector R must not have zero
elements, no check is done.
Solve for X in R * X = S using back substitution . The solution X overwrites S . Uses R from the result of the QR decomposition of a NxK matrix A . S is a column vector given as matrix with at least elements on index 0 to K - 1 ; elements on index > = K are ignored . Vector R must not have zero elements no check is done .
void lcl_SolveWithUpperRightTriangle(ScMatrixRef pMatA,
                        ::std::vector< double>& pVecR, ScMatrixRef pMatS,
                        SCSIZE nK, bool bIsTransposed)
{
    double fSum;
    SCSIZE row;
    for (SCSIZE rowp1 = nK; rowp1>0; rowp1--)
    {
        row = rowp1-1;
        fSum = pMatS->GetDouble(row);
        for (SCSIZE col = rowp1; col<nK ; col++)
            if (bIsTransposed)
                fSum -= pMatA->GetDouble(row,col) * pMatS->GetDouble(col);
            else
                fSum -= pMatA->GetDouble(col,row) * pMatS->GetDouble(col);
        pMatS->PutDouble( fSum / pVecR[row] , row);
    }
}
void lcl_SolveWithUpperRightTriangle ( ScMatrixRef pMatA , :: std :: vector < double > & pVecR , ScMatrixRef pMatS , SCSIZE nK , bool bIsTransposed ) { double fSum ; SCSIZE row ; for ( SCSIZE rowp1 = nK ; rowp1 > 0 ; rowp1 -- ) { row = rowp1 - 1 ; fSum = pMatS -> GetDouble ( row ) ; for ( SCSIZE col = rowp1 ; col < nK ; col ++ ) if ( bIsTransposed ) fSum -= pMatA -> GetDouble ( row , col ) * pMatS -> GetDouble ( col ) ; else fSum -= pMatA -> GetDouble ( col , row ) * pMatS -> GetDouble ( col ) ; pMatS -> PutDouble ( fSum / pVecR [ row ] , row ) ; } }
Solve for X in R*X=S using back substitution.
Solve for X in R * X = S using back substitution .
// ScMatrix matrices are zero based, index access (column,row) // SCSIZE is never negative, therefore test with rowp1=row+1