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


C++ CellMatrix类代码示例

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


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

示例1: MG_THROW

MG_XLObjectPtr
VolatilityCurve_Create	(	const MG_Date	& aAsOf
						,	const CellMatrix& aMaturities
						,	const CellMatrix& aTenors
						,	const CellMatrix& aVolatilities
						,	const string& aCcy
						,	const string& aUnderIndex
						,	const CellMatrix& aInterpolMeths)
{
	if (aVolatilities.Size() != aTenors.Size()*aMaturities.Size())
		MG_THROW("Volatilities matrix size and (Maturities,Tenors) size are not consistent");

	vector<double> vMaturities	= FromCellMatrixToVectorDouble(aMaturities, 0);
	vector<double> vTenors		= FromCellMatrixToVectorDouble(aTenors, 0);
	MG_Matrix vVols				= FromCellMatrixToMGMatrix		(aVolatilities);

	vector<int> vInterpolMeths = vector<int>(2, LINEAR_INTERPOL);
	if (!aInterpolMeths(0,0).IsEmpty())
		vInterpolMeths = FromCellMatrixToInterpolVector(aInterpolMeths);
	if (vInterpolMeths.size() == 1)
		vInterpolMeths.push_back(vInterpolMeths[0]);
	long vInterpolCode = MG_Interpolator::CreateInterpolCode(vInterpolMeths);

	return MG_XLObjectPtr(new MG_IRVolatilityCurve(aAsOf, vMaturities, vTenors, vVols, aCcy, aUnderIndex, vInterpolCode));
}
开发者ID:lemahdi,项目名称:mglib,代码行数:25,代码来源:justatest.cpp

示例2: FromCellMatrixToVectorStr

	/* converting a CellMatrix to a std::vector<string> */
	vector<string> FromCellMatrixToVectorStr(const CellMatrix& aCM, const vector<bool>& aIsDate)
	{
		size_t vRows(aCM.RowsInStructure()), vCols(aCM.ColumnsInStructure());
		vector<string> vVect(vRows*vCols);
		CellValue vTmpCell;
		double vTmpDbl;
		MG_Date vTmpDate;
		for(size_t i=0; i<vRows; ++i)
		{
			for(size_t j=0; j<vCols; ++j)
			{
				vTmpCell = aCM(i,j);
				if (vTmpCell.IsAString())
				{
					vVect[j+i*vCols] = aCM(i,j);
					continue;
				}
				if (vTmpCell.IsANumber())
				{
					vTmpDbl = aCM(i,j);
					if (aIsDate[j])
					{
						vTmpDate = MG_Date(FromXLDateToJulianDay(vTmpDbl));
						vVect[j+i*vCols] = vTmpDate.ToString('/');
						continue;
					}
					vVect[j+i*vCols] = ftoa(vTmpDbl);
					continue;
				}
			}
		}
		return vVect;
	}
开发者ID:lemahdi,项目名称:mglib,代码行数:34,代码来源:utils.cpp

示例3: FromCellMatrixToMGMatrix

	/* converting a CellMatrix to a MG_Matrix */
	MG_Matrix FromCellMatrixToMGMatrix(const CellMatrix& aCM)
	{
		size_t vRows(aCM.RowsInStructure()), vCols(aCM.ColumnsInStructure());
		MG_Matrix vMat(vRows, vCols);
		for(size_t i=0; i<vRows; ++i)
			for(size_t j=0; j<vCols; ++j)
				vMat(i, j) = aCM(i, j).NumericValue();
		return vMat;
	}
开发者ID:lemahdi,项目名称:mglib,代码行数:10,代码来源:utils.cpp

示例4: ContainsError

bool // checks to see if there's an error
ContainsError(const CellMatrix& input // data to check for errors
                             )
{
    for (unsigned long i=0; i < input.RowsInStructure(); ++i)
        for (unsigned long j=0; j < input.ColumnsInStructure(); ++j)
            if (input(i,j).IsError())
                return true;

    return false;

}
开发者ID:Laeeth,项目名称:d_excelsdk,代码行数:12,代码来源:Attributes.cpp

示例5: cells

xlw::DoubleOrNothing::DoubleOrNothing(const CellMatrix& cells, const std::string& identifier)
{
    if (cells.ColumnsInStructure() != 1 || cells.RowsInStructure() != 1)
        THROW_XLW("Multiple values given where one expected for DoubleOrNothing " << identifier);

    if (!cells(0,0).IsEmpty() && !cells(0,0).IsANumber() )
        THROW_XLW("expected a double or nothing, got something else " << identifier);

    Empty = cells(0,0).IsEmpty();

    Value = Empty ? 0.0 : cells(0,0).NumericValue();

}
开发者ID:alhunor,项目名称:projects,代码行数:13,代码来源:DoubleOrNothing.cpp

示例6: ContainsDivByZero

bool // checks to see if there's a div by zero
ContainsDivByZero(const CellMatrix& input // data to check for errors
                             )
{
    for (unsigned long i=0; i < input.RowsInStructure(); ++i)
        for (unsigned long j=0; j < input.ColumnsInStructure(); ++j)
            if (input(i,j).IsError())
                if (input(i,j).ErrorValue() == 7UL)
                    return true;

    return false;

}
开发者ID:Laeeth,项目名称:d_excelsdk,代码行数:13,代码来源:Attributes.cpp

示例7: FromCellMatrixToMGVectorDate

	/* converting a CellMatrix to a MG_Vector */
	MG_Vector FromCellMatrixToMGVectorDate(const CellMatrix& aCM, const size_t& aIndex)
	{
		if (aCM.ColumnsInStructure()!=1 && aCM.RowsInStructure()!=1)
			MG_THROW("CellMatrix should be a one row or column structure");
		bool vIsRow = aCM.ColumnsInStructure() == 1;

		size_t vSize = vIsRow ? aCM.RowsInStructure() : aCM.ColumnsInStructure();
		MG_Vector vRes(vSize);
		if (vIsRow)
		{
			for(size_t i=0; i<vSize; ++i)
				vRes[i] = FromXLDateToJulianDay(aCM(i, aIndex).NumericValue());
			return vRes;
		}
		for(size_t i=0; i<vSize; ++i)
			vRes[i] = FromXLDateToJulianDay(aCM(aIndex, i).NumericValue());
		return vRes;
	}
开发者ID:lemahdi,项目名称:mglib,代码行数:19,代码来源:utils.cpp

示例8: FromCellMatrixToVectorDouble

	/* converting a CellMatrix to a std::vector<double> */
	vector<double> FromCellMatrixToVectorDouble(const CellMatrix& aCM, const size_t& aIndex)
	{
		if (aCM.ColumnsInStructure()!=1 && aCM.RowsInStructure()!=1)
			MG_THROW("CellMatrix should be a one row or column structure");
		bool vIsRow = aCM.ColumnsInStructure() == 1;

		size_t vSize = vIsRow ? aCM.RowsInStructure() : aCM.ColumnsInStructure();
		vector<double> vRes(vSize);
		if (vIsRow)
		{
			for(size_t i=0; i<vSize; ++i)
				vRes[i] = aCM(i, aIndex).NumericValue();
			return vRes;
		}
		for(size_t i=0; i<vSize; ++i)
			vRes[i] = aCM(aIndex, i).NumericValue();
		return vRes;
	}
开发者ID:lemahdi,项目名称:mglib,代码行数:19,代码来源:utils.cpp

示例9: ExtractCells

CellMatrix ExtractCells(CellMatrix& cells,
						unsigned long row,
						unsigned long column,
						std::string ErrorId,
						std::string thisName,
						bool nonNumeric)
{
	if (!cells(row,column).IsANumber())
		throw(ErrorId+" "+thisName+" rows and columns expected.");
	if (cells.ColumnsInStructure() <= column+1)
		throw(ErrorId+" "+thisName+" rows and columns expected.");
	if (!cells(row,column+1).IsANumber())
		throw(ErrorId+" "+thisName+" rows and columns expected.");

	unsigned long numberRows = cells(row,column);
	unsigned long numberColumns = cells(row,column+1);

	cells(row,column).clear();
	cells(row,column+1).clear();

	CellMatrix result(numberRows,numberColumns);

	if (numberRows +row+1>cells.RowsInStructure())
		throw(ErrorId+" "+thisName+" insufficient rows in structure");

	if (numberColumns +column>cells.ColumnsInStructure())
		throw(ErrorId+" "+thisName+" insufficient columns in structure");

	for (unsigned long i=0; i < numberRows; i++)
		for (unsigned long j=0; j < numberColumns; j++)
		{
			result(i,j) = cells(row+1+i,column+j);
			cells(row+1+i,column+j).clear();

			if (!result(i,j).IsANumber())
				nonNumeric = true;
		}


	return result;


}
开发者ID:jabogithub,项目名称:fann-excel,代码行数:43,代码来源:ArgList.cpp

示例10: maxi

xlw::CellMatrix xlw::MergeCellMatrices(const CellMatrix& Top, const CellMatrix& Bottom)
{
    size_t cols = maxi(Top.ColumnsInStructure(), Bottom.ColumnsInStructure());
    size_t rows = Top.RowsInStructure()+Bottom.RowsInStructure();

    CellMatrix merged(rows,cols);

    {for (size_t i=0; i < Top.ColumnsInStructure(); i++)
        for (size_t j=0; j < Top.RowsInStructure(); j++)
            merged(j,i) = Top(j,i);}

    for (size_t i=0; i < Bottom.ColumnsInStructure(); i++)
        for (size_t j=0; j < Bottom.RowsInStructure(); j++)
            merged(j+Top.RowsInStructure(),i) = Bottom(j,i);

    return merged;
}
开发者ID:DangerMouseB,项目名称:xpy,代码行数:17,代码来源:CellMatrix.cpp

示例11: Robot

MG_XLObjectPtr
Robot(const MG_Date& aAsOf, CellMatrix& aMktData)
{
	MG_MarketDataPtr vMktData(NULL);
	size_t vSize = aMktData.RowsInStructure();
	string vDesc;
	vector<MG_MarketDataPtr> vMDVect(vSize);
	for(size_t i=0; i<vSize; ++i)
		vMDVect[i] = MG_MarketDataPtr(aMktData(i, 0).MGObjectValue()->Clone());

	return MG_XLObjectPtr(new MG_Robot(aAsOf, vMDVect));
}
开发者ID:lemahdi,项目名称:mglib,代码行数:12,代码来源:justatest.cpp

示例12: FromCellMatrixToInterpolVector

	/* converting a CellMatrix of interpolation types to a sid::vector<int> */
	vector<int> FromCellMatrixToInterpolVector(const CellMatrix& aCM)
	{
		if (aCM.Size() > maxInterpoltypesNb)
		{
			ostringstream vOs;
			vOs << "Maximum number of interpolations is " << maxInterpoltypesNb << ", please advise.";
			MG_THROW(vOs.str());
		}
		vector<string> vInterpolTypesStr = FromCellMatrixToVectorStr(aCM);
		size_t vSize(vInterpolTypesStr.size());
		vector<int> vInterpolTypesInt(vSize);
		for(size_t i=0; i<vSize; ++i)
			vInterpolTypesInt[i] = InterpolMethodConvertor[vInterpolTypesStr[i]];
		return vInterpolTypesInt;
	}
开发者ID:lemahdi,项目名称:mglib,代码行数:16,代码来源:utils.cpp

示例13: GenSec_Create

MG_XLObjectPtr
GenSec_Create(const CellMatrix& aDealDesc)
{
	size_t vColsSize = aDealDesc.ColumnsInStructure();
	vector<bool> vIsDate(vColsSize);
	string vTmp, vDateStr("DATE");
	for(size_t i=0; i<vColsSize; ++i)
	{
		vTmp = aDealDesc(0,i).StringValue();
		vTmp = ToUpper(vTmp.substr(vTmp.size()-4));
		vIsDate[i] = vTmp==vDateStr ? true : false;
	}
	
	vector<string> vDealDesc = FromCellMatrixToVectorStr(aDealDesc, vIsDate);
	return MG_XLObjectPtr(new MG_GenSecurity(vDealDesc, vColsSize));
}
开发者ID:lemahdi,项目名称:mglib,代码行数:16,代码来源:justatest.cpp

示例14: newRowsResize

void xlw::CellMatrix::PushBottom(const CellMatrix& newRows)
{
    CellMatrix newRowsResize(newRows);
    size_t newColumns = maxi(newRows.ColumnsInStructure(),Columns);

    if (newColumns > Columns)
        for (size_t i=0; i < Rows; i++)
            Cells[i].resize(newColumns);

    if (newColumns > newRows.Columns)
        for (size_t i=0; i < newRowsResize.Rows; i++)
            newRowsResize.Cells[i].resize(newColumns);

    for (size_t i=0; i < newRowsResize.Rows; i++)
        Cells.push_back(newRowsResize.Cells[i]);

    Rows = static_cast<size_t>(Cells.size());
    Columns = newColumns;
}
开发者ID:DangerMouseB,项目名称:xpy,代码行数:19,代码来源:CellMatrix.cpp

示例15: ConvertCellMatrixToPyObject

bool
ConvertCellMatrixToPyObject( const CellMatrix& rCM,
                             PyObject*& rpObj )
{
    bool rc = true;
    long i, j, cols, rows;
    PyObject *pCols, *pValue;

    rows = rCM.RowsInStructure();
    cols = rCM.ColumnsInStructure();
    assert(rows && cols);

    if (rows == 1 && cols == 1) {
        // Don't build a nested tuple; extract the single value
        const CellValue& rCV = rCM(0, 0);
        rc = ConvertCellValueToPyObject( rCV, rpObj );
        if (rc) {
            assert(rpObj);
        } else {
            assert(!rpObj);
            ERROUT("Failed to convert single cell to PyObject");
            rc = false;
        }
    } else if (rows == 1) { // Single horizontal rows should NOT be double-nested; they're vectors, not matrices
        assert(cols > 1);
        rpObj = PyTuple_New(cols); // Just ONE ROW here, with cols # of elements
        for (j = 0; rc && j < cols; ++j) {
            const CellValue& rCV = rCM(0, j);
            rc = ConvertCellValueToPyObject( rCV, pValue );
            if (rc) {
                assert(pValue);
                PyTuple_SetItem(rpObj, j, pValue); // pValue reference stolen here
            } else {
                assert(!pValue);
                ERROUT("Failed to convert element %d of single-row cell to PyObject", j);
                Py_DECREF(rpObj);   // Get rid of the entire row; it owns elements and will delete them
                rpObj = NULL;
                rc = false;
            }
        } // end j
    } else { // 2-D matrix
        rpObj = PyTuple_New(rows);
        for (i = 0; rc && i < rows; ++i) {
            pCols = PyTuple_New(cols);
            PyTuple_SetItem(rpObj, i, pCols); // pCols reference stolen here
            for (j = 0; rc && j < cols; ++j) {
                const CellValue& rCV = rCM(i, j);
                rc = ConvertCellValueToPyObject( rCV, pValue );
                if (rc) {
                    assert(pValue);
                    PyTuple_SetItem(pCols, j, pValue); // pValue reference stolen here
                } else {
                    assert(!pValue);
                    ERROUT("Failed to convert element %d, %d of matrix cell to PyObject", i, j);
                    Py_DECREF(rpObj);   // Get rid of the entire matrix; it owns elements and will delete them
                    rpObj = NULL;
                    rc = false;
                }
            } // end j
        } // end i
    } // end 2-D matrix code

    return rc;
}
开发者ID:edelmoral,项目名称:levinsky-pyinex,代码行数:64,代码来源:Utils.cpp


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