main/sc/source/core/tool/interpr5.cxx
// same with transposed matrix A, N is count of columns, K count of rows
same with transposed matrix A, N is count of columns, K count of rows
same with transposed matrix A N is count of columns K count of rows
bool lcl_TCalculateQRdecomposition(ScMatrixRef pMatA,
                    ::std::vector< double>& pVecR, SCSIZE nK, SCSIZE nN)
{
    double fScale ;
    double fEuclid ;
    double fFactor ;
    double fSignum ;
    double fSum ;
    for (SCSIZE row = 0; row <nK; row++)
    {
        fScale = lcl_TGetColumnMaximumNorm(pMatA, row, row, nN);
        if (fScale == 0.0)
            return false;
        for (SCSIZE col = row; col <nN; col++)
            pMatA->PutDouble( pMatA->GetDouble(col,row)/fScale, col, row);
        fEuclid = lcl_TGetColumnEuclideanNorm(pMatA, row, row, nN);
        fFactor = 1.0/fEuclid/(fEuclid + fabs(pMatA->GetDouble(row,row)));
        fSignum = lcl_GetSign(pMatA->GetDouble(row,row));
        pMatA->PutDouble( pMatA->GetDouble(row,row) + fSignum*fEuclid, row,row);
        pVecR[row] = -fSignum * fScale * fEuclid;
        for (SCSIZE r=row+1; r<nK; r++)
        {
            fSum =lcl_TGetColumnSumProduct(pMatA, row, pMatA, r, row, nN);
            for (SCSIZE col = row; col <nN; col++)
                pMatA->PutDouble( pMatA->GetDouble(col,r)
                        - fSum * fFactor * pMatA->GetDouble(col,row), col, r);
        }
    }
    return true;
}
bool lcl_TCalculateQRdecomposition ( ScMatrixRef pMatA , :: std :: vector < double > & pVecR , SCSIZE nK , SCSIZE nN ) { double fScale ; double fEuclid ; double fFactor ; double fSignum ; double fSum ; for ( SCSIZE row = 0 ; row < nK ; row ++ ) { fScale = lcl_TGetColumnMaximumNorm ( pMatA , row , row , nN ) ; if ( fScale == 0.0 ) return false ; for ( SCSIZE col = row ; col < nN ; col ++ ) pMatA -> PutDouble ( pMatA -> GetDouble ( col , row ) / fScale , col , row ) ; fEuclid = lcl_TGetColumnEuclideanNorm ( pMatA , row , row , nN ) ; fFactor = 1.0 / fEuclid / ( fEuclid + fabs ( pMatA -> GetDouble ( row , row ) ) ) ; fSignum = lcl_GetSign ( pMatA -> GetDouble ( row , row ) ) ; pMatA -> PutDouble ( pMatA -> GetDouble ( row , row ) + fSignum * fEuclid , row , row ) ; pVecR [ row ] = - fSignum * fScale * fEuclid ; for ( SCSIZE r = row + 1 ; r < nK ; r ++ ) { fSum = lcl_TGetColumnSumProduct ( pMatA , row , pMatA , r , row , nN ) ; for ( SCSIZE col = row ; col < nN ; col ++ ) pMatA -> PutDouble ( pMatA -> GetDouble ( col , r ) - fSum * fFactor * pMatA -> GetDouble ( col , row ) , col , r ) ; } } return true ; }
same with transposed matrix A, N is count of columns, K count of rows
same with transposed matrix A N is count of columns K count of rows
// ScMatrix matrices are zero based, index access (column,row) // calculate vector u of the householder transformation // A is singular // apply Householder transformation to A