当前位置: 首页>>代码示例>>C++>>正文


C++ Double::getReal方法代码示例

本文整理汇总了C++中Double::getReal方法的典型用法代码示例。如果您正苦于以下问题:C++ Double::getReal方法的具体用法?C++ Double::getReal怎么用?C++ Double::getReal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Double的用法示例。


在下文中一共展示了Double::getReal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RDividePolyByDouble


//.........这里部分代码省略.........
        {
            piRank[i] = iMaxRank;
        }

        pTemp = new Polynom(_pPoly->getVariableName(), iRowResult, iRowResult, piRank);
        if (bComplex1 || bComplex2)
        {
            pTemp->setComplex(true);
        }

        SinglePoly *pdblData = _pPoly->get(0);
        for (int i = 0 ; i < iRowResult ; i++)
        {
            pTemp->set(i, i, pdblData);
        }
    }

    (*_pPolyOut) = new Polynom(_pPoly->getVariableName(), iRowResult, iColResult, piRank);
    delete[] piRank;
    if (bComplex1 || bComplex2)
    {
        (*_pPolyOut)->setComplex(true);
    }

    if (bScalar2)
    {
        //[p] * cst
        for (int i = 0 ; i < _pPoly->getSize() ; i++)
        {
            SinglePoly *pPolyIn   = _pPoly->get(i);
            double* pRealIn  = pPolyIn->get();
            double* pImgIn  = pPolyIn->getImg();

            SinglePoly *pPolyOut  = (*_pPolyOut)->get(i);
            double* pRealOut = pPolyOut->get();
            double* pImgOut  = pPolyOut->getImg();

            if (bComplex1 == false && bComplex2 == false)
            {
                iRightDivisionRealMatrixByRealMatrix(
                    pRealIn, 1,
                    _pDouble->getReal(), 0,
                    pRealOut, 1, pPolyOut->getSize());
            }
            else if (bComplex1 == false && bComplex2 == true)
            {
                iRightDivisionRealMatrixByComplexMatrix(
                    pRealIn, 1,
                    _pDouble->getReal(), _pDouble->getImg(), 0,
                    pRealOut, pImgOut, 1, pPolyOut->getSize());
            }
            else if (bComplex1 == true && bComplex2 == false)
            {
                iRightDivisionComplexMatrixByRealMatrix(
                    pRealIn, pImgIn, 1,
                    _pDouble->getReal(), 0,
                    pRealOut, pImgOut, 1, pPolyOut->getSize());
            }
            else if (bComplex1 == true && bComplex2 == true)
            {
                iRightDivisionComplexMatrixByComplexMatrix(
                    pRealIn, pImgIn, 1,
                    _pDouble->getReal(), _pDouble->getImg(), 0,
                    pRealOut, pImgOut, 1, pPolyOut->getSize());
            }
        }
    }
    else if (bScalar1)
    {
        for (int i = 0 ; i < pTemp->get(0)->getSize() ; i++)
        {
            Double *pCoef    = pTemp->extractCoef(i);
            Double *pResultCoef = new Double(iRowResult, iColResult, pCoef->isComplex());
            double *pReal    = pResultCoef->getReal();
            double *pImg    = pResultCoef->getImg();

            if (bComplex1 == false && bComplex2 == false)
            {
                double dblRcond = 0;
                iRightDivisionOfRealMatrix(
                    pCoef->getReal(), iRowResult, iRowResult,
                    _pDouble->getReal(), _pDouble->getRows(), _pDouble->getCols(),
                    pReal, iRowResult, iColResult, &dblRcond);
            }
            else
            {
                double dblRcond = 0;
                iRightDivisionOfComplexMatrix(
                    pCoef->getReal(), pCoef->getImg(), iRowResult, iRowResult,
                    _pDouble->getReal(), _pDouble->getImg(), _pDouble->getRows(), _pDouble->getCols(),
                    pReal, pImg, iRowResult, iColResult, &dblRcond);
            }

            (*_pPolyOut)->insertCoef(i, pResultCoef);
            delete pCoef;
            delete pResultCoef;
        }
    }
    return 0;
}
开发者ID:scitao,项目名称:scilab,代码行数:101,代码来源:types_divide.cpp

示例2: DotRDividePolyByDouble

int DotRDividePolyByDouble(Polynom* _pPoly1, Double* _pDouble2, Polynom** _pPolyOut)
{
    int iErr        = 0;
    bool bComplex1  = _pPoly1->isComplex();
    bool bComplex2  = _pDouble2->isComplex();

    //X ./ Y
    //check dimension compatibilities ( same number of dimension and same size for each dimension
    int iDims1      = _pPoly1->getDims();
    int* piDims1    = _pPoly1->getDimsArray();
    int iMaxSize    = _pPoly1->getMaxRank() + 1;
    int iSizePoly   = _pPoly1->getSize();
    int iDims2      = _pDouble2->getDims();
    int* piDims2    = _pDouble2->getDimsArray();

    if (iDims1 != iDims2)
    {
        return 1;
    }

    for (int i = 0 ; i < iDims1 ; i++)
    {
        if (piDims1[i] != piDims2[i])
        {
            return 1;
        }
    }

    // compute output ranks
    int* piRanks = new int[iSizePoly];
    for (int i = 0; i < iSizePoly; i++)
    {
        piRanks[i] = iMaxSize - 1;
    }

    // create output and working table
    (*_pPolyOut) = new Polynom(_pPoly1->getVariableName(), iDims2, piDims2, piRanks);
    delete[] piRanks;
    Double* pDblCoefOut = new Double(_pPoly1->getRows(), _pPoly1->getCols() * iMaxSize, bComplex1 || bComplex2);
    double* pdblCoef2   = new double[_pPoly1->getRows() * _pPoly1->getCols() * iMaxSize];
    Double* pDblCoef1   = _pPoly1->getCoef();

    int iZero = 0;
    double* pdbl = _pDouble2->get();
    for (int i = 0; i < iSizePoly; i++)
    {
        C2F(dcopy)(&iMaxSize, pdbl + i, &iZero, pdblCoef2 + i, &iSizePoly);
    }

    int iInc1       = 1;
    int iInc2       = 1;
    int iIncOut     = 1;
    int iSizeResult = pDblCoefOut->getSize();

    if (bComplex1 == false && bComplex2 == false)
    {
        // r ./ R
        iErr = iRightDivisionRealMatrixByRealMatrix(
                   pDblCoef1->getReal(), iInc1,
                   pdblCoef2, iInc2,
                   pDblCoefOut->getReal(), iIncOut, iSizeResult);
    }
    else if (bComplex1 == false && bComplex2 == true)
    {
        // r ./ C
        //        iErr = iRightDivisionRealMatrixByComplexMatrix(
        //                   _pDouble1->getReal(), iInc1,
        //                   _pDouble2->getReal(), _pDouble2->getImg(), iInc2,
        //                   (*_pDoubleOut)->getReal(), (*_pDoubleOut)->getImg(), iIncOut, iSizeResult);

        // waiting for polynom rewrite about complex
        iErr = 10;
    }
    else if (bComplex1 == true && bComplex2 == false)
    {
        // c ./ R
        //        iErr = iRightDivisionComplexMatrixByRealMatrix(
        //                   _pDouble1->getReal(), _pDouble1->getImg(), iInc1,
        //                   _pDouble2->getReal(), iInc2,
        //                   (*_pDoubleOut)->getReal(), (*_pDoubleOut)->getImg(), iIncOut, iSizeResult);

        // waiting for polynom rewrite about complex
        iErr = 10;
    }
    else if (bComplex1 == true && bComplex2 == true)
    {
        // c ./ C
        //        iErr = iRightDivisionComplexMatrixByComplexMatrix(
        //                   _pDouble1->getReal(), _pDouble1->getImg(), iInc1,
        //                   _pDouble2->getReal(), _pDouble2->getImg(), iInc2,
        //                   (*_pDoubleOut)->getReal(), (*_pDoubleOut)->getImg(), iIncOut, iSizeResult);

        // waiting for polynom rewrite about complex
        iErr = 10;
    }

    (*_pPolyOut)->setCoef(pDblCoefOut);
    (*_pPolyOut)->updateRank();

    delete pDblCoefOut;
//.........这里部分代码省略.........
开发者ID:scitao,项目名称:scilab,代码行数:101,代码来源:types_divide.cpp

示例3: RDivideDoubleByDouble

int RDivideDoubleByDouble(Double *_pDouble1, Double *_pDouble2, Double **_pDoubleOut)
{
    int iErr = 0;

    //check finite values of _pDouble1 and _pDouble2
    if (isDoubleFinite(_pDouble1) == false || isDoubleFinite(_pDouble2) == false)
    {
        if (_pDouble2->isScalar() == false)
        {
            return 2;
        }
    }

    if (_pDouble2->isScalar())
    {
        //Y / x
        int iInc1       = 1;
        int iInc2       = 0;
        bool bComplex1  = _pDouble1->isComplex();
        bool bComplex2  = _pDouble2->isComplex();

        *_pDoubleOut    = new Double(_pDouble1->getDims(), _pDouble1->getDimsArray(), bComplex1 || bComplex2);

        if (bComplex1 == false && bComplex2 == false)
        {
            // Real1 \ Real2 -> Real2 / Real1
            iErr = iRightDivisionRealMatrixByRealMatrix(
                       _pDouble1->get(), iInc1,
                       _pDouble2->get(), iInc2,
                       (*_pDoubleOut)->get(), 1, _pDouble1->getSize());
        }
        else if (bComplex1 == false && bComplex2 == true)
        {
            // Real \ Complex -> Complex / Real
            iErr = iRightDivisionRealMatrixByComplexMatrix(
                       _pDouble1->get(), iInc1,
                       _pDouble2->get(), _pDouble2->getImg(), iInc2,
                       (*_pDoubleOut)->get(), (*_pDoubleOut)->getImg(), 1, _pDouble1->getSize());
        }
        else if (bComplex1 == true && bComplex2 == false)
        {
            // Complex \ Real -> Real / Complex
            iErr = iRightDivisionComplexMatrixByRealMatrix(
                       _pDouble1->get(), _pDouble1->getImg(), iInc1,
                       _pDouble2->get(), iInc2,
                       (*_pDoubleOut)->get(), (*_pDoubleOut)->getImg(), 1, _pDouble1->getSize());
        }
        else if (bComplex1 == true && bComplex2 == true)
        {
            // Complex \ Complex
            iErr = iRightDivisionComplexMatrixByComplexMatrix(
                       _pDouble1->get(), _pDouble1->getImg(), iInc1,
                       _pDouble2->get(), _pDouble2->getImg(), iInc2,
                       (*_pDoubleOut)->get(), (*_pDoubleOut)->getImg(), 1, _pDouble1->getSize());
        }

        return iErr;
    }

    if (_pDouble1->isScalar())
    {
        if (_pDouble2->getDims() > 2)
        {
            //not managed, call overload
            return 0;
        }

        // x / eye() = x
        if (_pDouble2->isIdentity() )
        {
            *_pDoubleOut    = new Double(*_pDouble1);
            return 0;
        }
        double dblSavedR = 0;
        double dblSavedI = 0;
        Double *pdblTemp = NULL;

        int iRowResult = _pDouble2->getCols();
        int iColResult = _pDouble2->getRows();




        //in this case, we have to create a temporary square matrix
        pdblTemp = new Double(iRowResult, iRowResult, _pDouble1->isComplex());
        pdblTemp->setZeros();

        if (_pDouble1->isComplex())
        {
            dblSavedR = _pDouble1->getReal()[0];
            dblSavedI = _pDouble1->getImg()[0];
            for (int i = 0 ; i < iRowResult ; i++)
            {
                pdblTemp->set(i, i, dblSavedR);
                pdblTemp->setImg(i, i, dblSavedI);
            }
        }
        else
        {
            dblSavedR = _pDouble1->getReal()[0];
//.........这里部分代码省略.........
开发者ID:scitao,项目名称:scilab,代码行数:101,代码来源:types_divide.cpp


注:本文中的Double::getReal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。