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


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

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


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

示例1: sci_inspectorGetUnreferencedItem

Function::ReturnValue sci_inspectorGetUnreferencedItem(typed_list &in, int _iRetCount, typed_list &out)
{
    if (in.size() != 1)
    {
        Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), "inspectorGetItem", 1);
        return Function::Error;
    }

    if (in[0]->isDouble() == false)
    {

        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), "inspectorGetItem", 1);
        return Function::Error;
    }

    Double *pD = in[0]->getAs<Double>();
    if (pD->isScalar() == false)
    {
        Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), "inspectorGetItem", 1);
        Function::Error;
    }

    int iPos = (int)pD->get(0) - 1;

    out.push_back(Inspector::getUnreferencedItem(iPos));
    return Function::OK;
}
开发者ID:scitao,项目名称:scilab,代码行数:27,代码来源:sci_inspectorGetUnreferencedItem.cpp

示例2: Double

types::InternalType* opposite_M<types::Bool, types::Double>(types::Bool* _pL)
{
    Double* pOut = new Double(_pL->getDims(), _pL->getDimsArray());
    int iSize = _pL->getSize();

    int* pI = _pL->get();
    double* pD = pOut->get();
    for (int i = 0 ; i < iSize ; ++i)
    {
        pD[i] = pI[i] == 0 ? 1 : 0;
    }

    return pOut;
}
开发者ID:Bitiquinho,项目名称:Scilab-Jupyter-Kernel,代码行数:14,代码来源:types_opposite.cpp

示例3:

double *mxGetPr(const mxArray *ptr)
{
    InternalType *pIT = (InternalType *)ptr;
    if (pIT == NULL)
    {
        return NULL;
    }

    Double *pD = dynamic_cast<Double *>(pIT);
    if (pD == NULL)
    {
        return NULL;
    }

    return pD->get();
}
开发者ID:scitao,项目名称:scilab,代码行数:16,代码来源:mexlib.cpp

示例4: DotPowerSpaseByDouble

int DotPowerSpaseByDouble(Sparse* _pSp, Double* _pDouble, InternalType** _pOut)
{
    if (_pDouble->isEmpty())
    {
        //sp .^ []
        *_pOut = Double::Empty();
        return 0;
    }

    size_t iSize = _pSp->nonZeros();
    int* Col = new int[iSize];
    int* Row = new int[iSize];
    _pSp->getColPos(Col);
    _pSp->getNbItemByRow(Row);
    int* iPositVal = new int[iSize];

    int j = 0;
    for (int i = 0; i < iSize;  j++)
    {
        for (int k = 0; k < Row[j]; k++)
        {

            iPositVal[i] = (Col[i] - 1) * _pSp->getRows() + j;
            i++;
        }
    }

    Double** pDbl = new Double*[iSize];
    Double** pDblSp = new Double*[iSize];
    double* pdbl = _pDouble->get();

    if (_pDouble->isScalar())
    {
        if (_pDouble->isComplex())
        {
            double* pdblImg = _pDouble->getImg();
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[0], pdblImg[0]);
                pDblSp[i] = new Double(_pSp->get(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
        else
        {
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[0]);
                pDblSp[i] = new Double(_pSp->getReal(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
    }
    else if (_pDouble->getSize() == iSize)
    {
        if (_pDouble->isComplex())
        {
            double* pdblImg = _pDouble->getImg();
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[i], pdblImg[i]);
                pDblSp[i] = new Double(_pSp->getReal(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
        else
        {
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[i]);
                pDblSp[i] = new Double(_pSp->getReal(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
    }
    else
    {
        delete[] pDblSp;
        throw ast::InternalError(_W("Invalid exponent.\n"));
        return 1;
    }

    Sparse* pSpTemp = new Sparse(_pSp->getRows(), _pSp->getCols(), _pSp->isComplex() || _pDouble->isComplex());
    pSpTemp->zero_set();

    Double* ppDblGet = NULL;
    for (int i = 0; i < iSize; i++)
    {
        if ((pDblSp[i]->get(0) != 0) || (pDblSp[i]->getImg(0) != 0))
        {
            DotPowerDoubleByDouble(pDblSp[i], pDbl[i], &ppDblGet);
            std::complex<double> cplx(ppDblGet->get(0), ppDblGet->getImg(0));
            pSpTemp->set(iPositVal[i], cplx, false);
        }
    }

    delete[] Col;
    delete[] Row;
    delete[] iPositVal;

    pSpTemp->finalize();
    *_pOut = pSpTemp;
    return 0;

//.........这里部分代码省略.........
开发者ID:Macisia,项目名称:scilab,代码行数:101,代码来源:types_power.cpp

示例5: RDivideSparseByDouble

int RDivideSparseByDouble(types::Sparse* _pSp, types::Double* _pDouble, InternalType** _pSpOut)
{
    if (_pDouble->isEmpty())
    {
        //sp / []
        *_pSpOut = Double::Empty();
        return 0;
    }

    if (_pDouble->isIdentity())
    {
        *_pSpOut    = new Sparse(*_pSp);
        return 0;
    }

    size_t iSize = _pSp->nonZeros();
    int* Col = new int[iSize];
    int* Row = new int[_pSp->getRows()];
    _pSp->getColPos(Col);
    _pSp->getNbItemByRow(Row);
    int* iPositVal = new int[iSize];

    int idx = 0;
    for (int i = 0; i < _pSp->getRows(); i++)
    {
        for (int j = 0; j < Row[i]; j++)
        {
            iPositVal[idx] = (Col[idx] - 1) * _pSp->getRows() + i;
            ++idx;
        }
    }

    Double** pDbl = new Double*[iSize];
    Double** pDblSp = new Double*[iSize];
    double* pdbl = _pDouble->get();

    if (_pDouble->isScalar())
    {
        if (_pDouble->isComplex())
        {
            double* pdblImg = _pDouble->getImg();
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[0], pdblImg[0]);
                pDblSp[i] = new Double(_pSp->get(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
        else
        {
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[0]);
                pDblSp[i] = new Double(_pSp->getReal(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
    }
    else if (_pDouble->getSize() == iSize)
    {
        if (_pDouble->isComplex())
        {
            double* pdblImg = _pDouble->getImg();
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[i], pdblImg[i]);
                pDblSp[i] = new Double(_pSp->getReal(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
        else
        {
            for (int i = 0; i < iSize; i++)
            {
                pDbl[i] = new Double(pdbl[i]);
                pDblSp[i] = new Double(_pSp->getReal(iPositVal[i]), _pSp->getImg(iPositVal[i]).imag());
            }
        }
    }
    else
    {
        for (int i = 0; i < iSize; ++i)
        {
            delete pDbl[i];
            delete pDblSp[i];
        }

        delete[] pDbl;
        delete[] pDblSp;
        throw ast::InternalError(_W("Invalid exponent.\n"));
        return 1;
    }

    Sparse* pSpTemp = new Sparse(_pSp->getRows(), _pSp->getCols(), _pSp->isComplex() || _pDouble->isComplex());
    pSpTemp->zero_set();

    Double* ppDblGet = NULL;
    int iResultat;
    for (int i = 0; i < iSize; i++)
    {
        if ((pDblSp[i]->get(0) != 0) || (pDblSp[i]->getImg(0) != 0))
        {
            iResultat = RDivideDoubleByDouble(pDblSp[i], pDbl[i], &ppDblGet);
//.........这里部分代码省略.........
开发者ID:scitao,项目名称:scilab,代码行数:101,代码来源:types_divide.cpp

示例6: mxGetScalar

double mxGetScalar(const mxArray *ptr)
{
    // TODO: review spec
    InternalType *pIT = (InternalType *)ptr;
    if (pIT == NULL)
    {
        return 0;
    }

    switch (pIT->getType())
    {
        case InternalType::ScilabDouble:
        {
            Double *pD = pIT->getAs<Double>();
            return pD->get(0);
        }
        case InternalType::ScilabBool:
        {
            Bool *pB = pIT->getAs<Bool>();
            return (double)pB->get(0);
        }
        case InternalType::ScilabInt8:
        {
            Int8 *pI = pIT->getAs<Int8>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabUInt8:
        {
            UInt8 *pI = pIT->getAs<UInt8>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabInt16:
        {
            Int16 *pI = pIT->getAs<Int16>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabUInt16:
        {
            UInt16 *pI = pIT->getAs<UInt16>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabInt32:
        {
            Int32 *pI = pIT->getAs<Int32>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabUInt32:
        {
            UInt32 *pI = pIT->getAs<UInt32>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabInt64:
        {
            Int64 *pI = pIT->getAs<Int64>();
            return (double)pI->get(0);
        }
        case InternalType::ScilabUInt64:
        {
            UInt64 *pI = pIT->getAs<UInt64>();
            return (double)pI->get(0);
        }
        default:
            return 0;
    }
}
开发者ID:scitao,项目名称:scilab,代码行数:65,代码来源:mexlib.cpp

示例7: switch

void *mxGetData(const mxArray *ptr)
{
    InternalType *pIT = (InternalType *)ptr;
    if (pIT == NULL)
    {
        return NULL;
    }

    switch (pIT->getType())
    {
        case InternalType::ScilabDouble:
        {
            Double *pD = pIT->getAs<Double>();
            return pD->get();
        }
        case InternalType::ScilabBool:
        {
            Bool *pB = pIT->getAs<Bool>();
            return pB->get();
        }
        case InternalType::ScilabInt8:
        {
            Int8 *pI = pIT->getAs<Int8>();
            return pI->get();
        }
        case InternalType::ScilabUInt8:
        {
            UInt8 *pI = pIT->getAs<UInt8>();
            return pI->get();
        }
        case InternalType::ScilabInt16:
        {
            Int16 *pI = pIT->getAs<Int16>();
            return pI->get();
        }
        case InternalType::ScilabUInt16:
        {
            UInt16 *pI = pIT->getAs<UInt16>();
            return pI->get();
        }
        case InternalType::ScilabInt32:
        {
            Int32 *pI = pIT->getAs<Int32>();
            return pI->get();
        }
        case InternalType::ScilabUInt32:
        {
            UInt32 *pI = pIT->getAs<UInt32>();
            return pI->get();
        }
        case InternalType::ScilabInt64:
        {
            Int64 *pI = pIT->getAs<Int64>();
            return pI->get();
        }
        case InternalType::ScilabUInt64:
        {
            UInt64 *pI = pIT->getAs<UInt64>();
            return pI->get();
        }
        default:
            return NULL;
    }
}
开发者ID:scitao,项目名称:scilab,代码行数:64,代码来源:mexlib.cpp

示例8: extract

InternalType* ImplicitList::extract(typed_list* _pArgs)
{
    int iDims = (int)_pArgs->size();
    typed_list pArg;
    InternalType* pOut = NULL;
    int index = 0;

    int* piMaxDim = new int[iDims];
    int* piCountDim = new int[iDims];

    //evaluate each argument and replace by appropriate value and compute the count of combinations
    int iSeqCount = checkIndexesArguments(this, _pArgs, &pArg, piMaxDim, piCountDim);
    if (iSeqCount == 0)
    {
        //free pArg content
        cleanIndexesArguments(_pArgs, &pArg);
        return createEmptyDouble();
    }

    if (iDims == 1 && iSeqCount == 1)
    {
        if (piMaxDim[0] > 0 && piMaxDim[0] <= 3)
        {
            //standard case a(1)
            Double* pDbl = pArg[0]->getAs<Double>();
            index = (int)pDbl->get()[0] - 1;
        }
        else
        {
            index = 0;
        }
    }
    else
    {
        int* piDims = new int[iDims];
        int* pIndex = new int[iDims];
        for (int i = 0 ; i < iDims ; i++)
        {
            piDims[i] = 1;
        }

        for (int i = 0 ; i < iSeqCount ; i++)
        {
            for (int j = 0 ; j < iDims ; j++)
            {
                Double* pDbl = pArg[j]->getAs<Double>();
                pIndex[j] = (int)pDbl->get()[i] - 1;
            }

            index = getIndexWithDims(pIndex, piDims, iDims);
        }
        delete[] pIndex;
        delete[] piDims;
    }

    switch (index)
    {
        case 0 :
            pOut = getStart();
            break;
        case 1 :
            pOut = getStep();
            break;
        case 2 :
            pOut = getEnd();
            break;
        default :
            pOut = NULL;
            break;
    }

    //free pArg content
    cleanIndexesArguments(_pArgs, &pArg);

    delete[] piMaxDim;
    delete[] piCountDim;
    return pOut;
}
开发者ID:Bitiquinho,项目名称:Scilab-Jupyter-Kernel,代码行数:78,代码来源:implicitlist.cpp


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