main/sc/source/core/tool/interpr5.cxx
// Fill default values in matrix X, transform Y to log(Y) in case LOGEST|GROWTH,
// determine sizes of matrices X and Y, determine kind of regression, clone
// Y in case LOGEST|GROWTH, if constant.
Fill default values in matrix X, transform Y to log(Y) in case LOGEST|GROWTH,
determine sizes of matrices X and Y, determine kind of regression, clone
Y in case LOGEST|GROWTH, if constant.
Fill default values in matrix X transform Y to log ( Y ) in case LOGEST|GROWTH determine sizes of matrices X and Y determine kind of regression clone Y in case LOGEST|GROWTH if constant .
bool ScInterpreter::CheckMatrix(bool _bLOG, sal_uInt8& nCase, SCSIZE& nCX,
                        SCSIZE& nCY, SCSIZE& nRX, SCSIZE& nRY, SCSIZE& M,
                        SCSIZE& N, ScMatrixRef& pMatX, ScMatrixRef& pMatY)
{
    nCX = 0;
    nCY = 0;
    nRX = 0;
    nRY = 0;
    M = 0;
    N = 0;
    pMatY->GetDimensions(nCY, nRY);
    const SCSIZE nCountY = nCY * nRY;
    for ( SCSIZE i = 0; i < nCountY; i++ )
    {
        if (!pMatY->IsValue(i))
        {
            PushIllegalArgument();
            return false;
        }
    }
    if ( _bLOG )
    {
        ScMatrixRef pNewY = pMatY->CloneIfConst();
        for (SCSIZE nElem = 0; nElem < nCountY; nElem++)
        {
            const double fVal = pNewY->GetDouble(nElem);
            if (fVal <= 0.0)
            {
                PushIllegalArgument();
                return false;
            }
            else
                pNewY->PutDouble(log(fVal), nElem);
        }
        pMatY = pNewY;
    }
    if (pMatX)
    {
        pMatX->GetDimensions(nCX, nRX);
        const SCSIZE nCountX = nCX * nRX;
        for ( SCSIZE i = 0; i < nCountX; i++ )
            if (!pMatX->IsValue(i))
            {
                PushIllegalArgument();
                return false;
            }
        if (nCX == nCY && nRX == nRY)
        {
            nCase = 1;                  
            M = 1;
            N = nCountY;
        }
        else if (nCY != 1 && nRY != 1)
        {
            PushIllegalArgument();
            return false;
        }
        else if (nCY == 1)
        {
            if (nRX != nRY)
            {
                PushIllegalArgument();
                return false;
            }
            else
            {
                nCase = 2;              
                N = nRY;
                M = nCX;
            }
        }
        else if (nCX != nCY)
        {
            PushIllegalArgument();
            return false;
        }
        else
        {
            nCase = 3;                  
            N = nCY;
            M = nRX;
        }
    }
    else
    {
        pMatX = GetNewMat(nCY, nRY);
        nCX = nCY;
        nRX = nRY;
        if (!pMatX)
        {
            PushIllegalArgument();
            return false;
        }
        for ( SCSIZE i = 1; i <= nCountY; i++ )
            pMatX->PutDouble(static_cast<double>(i), i-1);
        nCase = 1;
        N = nCountY;
        M = 1;
    }
    return true;
}
bool ScInterpreter :: CheckMatrix ( bool _bLOG , sal_uInt8 & nCase , SCSIZE & nCX , SCSIZE & nCY , SCSIZE & nRX , SCSIZE & nRY , SCSIZE & M , SCSIZE & N , ScMatrixRef & pMatX , ScMatrixRef & pMatY ) { nCX = 0 ; nCY = 0 ; nRX = 0 ; nRY = 0 ; M = 0 ; N = 0 ; pMatY -> GetDimensions ( nCY , nRY ) ; const SCSIZE nCountY = nCY * nRY ; for ( SCSIZE i = 0 ; i < nCountY ; i ++ ) { if ( ! pMatY -> IsValue ( i ) ) { PushIllegalArgument ( ) ; return false ; } } if ( _bLOG ) { ScMatrixRef pNewY = pMatY -> CloneIfConst ( ) ; for ( SCSIZE nElem = 0 ; nElem < nCountY ; nElem ++ ) { const double fVal = pNewY -> GetDouble ( nElem ) ; if ( fVal <= 0.0 ) { PushIllegalArgument ( ) ; return false ; } else pNewY -> PutDouble ( log ( fVal ) , nElem ) ; } pMatY = pNewY ; } if ( pMatX ) { pMatX -> GetDimensions ( nCX , nRX ) ; const SCSIZE nCountX = nCX * nRX ; for ( SCSIZE i = 0 ; i < nCountX ; i ++ ) if ( ! pMatX -> IsValue ( i ) ) { PushIllegalArgument ( ) ; return false ; } if ( nCX == nCY && nRX == nRY ) { nCase = 1 ; M = 1 ; N = nCountY ; } else if ( nCY != 1 && nRY != 1 ) { PushIllegalArgument ( ) ; return false ; } else if ( nCY == 1 ) { if ( nRX != nRY ) { PushIllegalArgument ( ) ; return false ; } else { nCase = 2 ; N = nRY ; M = nCX ; } } else if ( nCX != nCY ) { PushIllegalArgument ( ) ; return false ; } else { nCase = 3 ; N = nCY ; M = nRX ; } } else { pMatX = GetNewMat ( nCY , nRY ) ; nCX = nCY ; nRX = nRY ; if ( ! pMatX ) { PushIllegalArgument ( ) ; return false ; } for ( SCSIZE i = 1 ; i <= nCountY ; i ++ ) pMatX -> PutDouble ( static_cast < double > ( i ) , i - 1 ) ; nCase = 1 ; N = nCountY ; M = 1 ; } return true ; }
Fill default values in matrix X, transform Y to log(Y) in case LOGEST|GROWTH,
determine sizes of matrices X and Y, determine kind of regression, clone
Y in case LOGEST|GROWTH, if constant.
Fill default values in matrix X transform Y to log ( Y ) in case LOGEST|GROWTH determine sizes of matrices X and Y determine kind of regression clone Y in case LOGEST|GROWTH if constant .
// simple regression // Y is column // Y is row