本文整理汇总了C++中Double::getImg方法的典型用法代码示例。如果您正苦于以下问题:C++ Double::getImg方法的具体用法?C++ Double::getImg怎么用?C++ Double::getImg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Double
的用法示例。
在下文中一共展示了Double::getImg方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: 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);
//.........这里部分代码省略.........
示例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];
//.........这里部分代码省略.........
示例4: RDividePolyByDouble
int RDividePolyByDouble(Polynom* _pPoly, Double* _pDouble, Polynom** _pPolyOut)
{
bool bComplex1 = _pPoly->isComplex();
bool bComplex2 = _pDouble->isComplex();
bool bScalar1 = _pPoly->getRows() == 1 && _pPoly->getCols() == 1;
bool bScalar2 = _pDouble->getRows() == 1 && _pDouble->getCols() == 1;
Polynom *pTemp = NULL; //use only if _pPoly is scalar and _pDouble not.
int iRowResult = 0;
int iColResult = 0;
int *piRank = NULL;
/* if(bScalar1 && bScalar2)
{
iRowResult = 1;
iColResult = 1;
piRank = new int[1];
piRank[0] = _pPoly->get(0)->getRank();
}
else */
if (bScalar1 == false && bScalar2 == false)
{
// call overload
return 0;
}
if (bScalar2)
{
double dblDivR = _pDouble->get(0);
double dblDivI = _pDouble->getImg(0);
(*_pPolyOut) = _pPoly->clone()->getAs<Polynom>();
if (_pDouble->isComplex())
{
(*_pPolyOut)->setComplex(true);
}
for (int i = 0 ; i < _pPoly->getSize() ; i++)
{
bool bComplex1 = _pPoly->isComplex();
bool bComplex2 = _pDouble->isComplex();
SinglePoly* pC = (*_pPolyOut)->get(i);
if (bComplex1 == false && bComplex2 == false)
{
iRightDivisionRealMatrixByRealMatrix(pC->get(), 1, &dblDivR, 0, pC->get(), 1, pC->getSize());
}
else if (bComplex1 == true && bComplex2 == false)
{
iRightDivisionComplexMatrixByRealMatrix(pC->get(), pC->getImg(), 1, &dblDivR, 0, pC->get(), pC->getImg(), 1, pC->getSize());
}
else if (bComplex1 == false && bComplex2 == true)
{
iRightDivisionRealMatrixByComplexMatrix(pC->get(), 1, &dblDivR, &dblDivI, 0, pC->get(), pC->getImg(), 1, pC->getSize());
}
else if (bComplex1 == true && bComplex2 == true)
{
iRightDivisionComplexMatrixByComplexMatrix(pC->get(), pC->getImg(), 1, &dblDivR, &dblDivI, 0, pC->get(), pC->getImg(), 1, pC->getSize());
}
}
return 0;
}
if (bScalar1)
{
//in this case, we have to create a temporary square polinomial matrix
iRowResult = _pDouble->getCols();
iColResult = _pDouble->getRows();
piRank = new int[iRowResult * iRowResult];
int iMaxRank = _pPoly->getMaxRank();
for (int i = 0 ; i < iRowResult * iRowResult ; i++)
{
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);
}
//.........这里部分代码省略.........
示例5: switch
void *mxGetImagData(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->getImg();
}
case InternalType::ScilabBool:
{
Bool *pB = pIT->getAs<Bool>();
return pB->getImg();
}
case InternalType::ScilabInt8:
{
Int8 *pI = pIT->getAs<Int8>();
return pI->getImg();
}
case InternalType::ScilabUInt8:
{
UInt8 *pI = pIT->getAs<UInt8>();
return pI->getImg();
}
case InternalType::ScilabInt16:
{
Int16 *pI = pIT->getAs<Int16>();
return pI->getImg();
}
case InternalType::ScilabUInt16:
{
UInt16 *pI = pIT->getAs<UInt16>();
return pI->getImg();
}
case InternalType::ScilabInt32:
{
Int32 *pI = pIT->getAs<Int32>();
return pI->getImg();
}
case InternalType::ScilabUInt32:
{
UInt32 *pI = pIT->getAs<UInt32>();
return pI->getImg();
}
case InternalType::ScilabInt64:
{
Int64 *pI = pIT->getAs<Int64>();
return pI->getImg();
}
case InternalType::ScilabUInt64:
{
UInt64 *pI = pIT->getAs<UInt64>();
return pI->getImg();
}
default:
return NULL;
}
}