Exemplo n.º 1
0
 void operator()(
         LoopFunction &loopFunction, 
         XLOPER &xIn, 
         XLOPER &xOut,
         bool expandVector) {
     InputType inputItem = reposit::convert2<InputType>(ConvertOper(xIn));
     loopFunction(inputItem);
     scalarToOper(true, xOut, expandVector);
 }
Exemplo n.º 2
0
 void matrixToOper(const QuantLib::Matrix &m, OPER &xMatrix) {
     if (m.empty()) {
         xMatrix.xltype = xltypeErr;
         xMatrix.val.err = xlerrNA;
         return;
     }
     xMatrix.val.array.rows = m.rows();
     xMatrix.val.array.columns = m.columns();
     xMatrix.val.array.lparray = new OPER[xMatrix.val.array.rows * xMatrix.val.array.columns]; 
     xMatrix.xltype = xltypeMulti | xlbitDLLFree;
     for (unsigned int i=0; i<m.rows(); ++i)
         for (unsigned int j=0; j<m.columns(); ++j)
             scalarToOper(m[i][j], xMatrix.val.array.lparray[i * m.columns() + j]);
 }
Exemplo n.º 3
0
    void vectorToOper(T begin, T end, OPER &xVector) {
        std::size_t size = end - begin;
        if (size == 0) {
            xVector.xltype = xltypeErr;
            xVector.val.err = xlerrNA;
            return;
        }

        if (FunctionCall::instance().callerDimensions() == CallerDimensions::Row) {
            xVector.val.array.columns = size;
            xVector.val.array.rows = 1;
        } else {
            xVector.val.array.rows = size;
            xVector.val.array.columns = 1;
        }

        xVector.val.array.lparray = new OPER[size]; 
        xVector.xltype = xltypeMulti | xlbitDLLFree;
        for (unsigned int i=0; i<size; ++i, ++begin)
            scalarToOper(*begin, xVector.val.array.lparray[i], false);
    }
Exemplo n.º 4
0
    void tableToOper(const std::vector<std::string> &columnHeadings, 
                     const std::vector<std::string> &rowHeadings, 
                     const std::vector<std::vector<double>> &data, 
                     OPER &xMatrix)
    {
        if (data.empty()) 
        {
            xMatrix.xltype = xltypeErr;
            xMatrix.val.err = xlerrNA;
            return;
        }
        size_t dataRows = data.size();
        size_t rows = dataRows;
        size_t rowOffset = 0;
        size_t dataColumns = data[0].size();
        for (size_t i = 0; i < rows; ++i) 
        {
            dataColumns = std::max(dataColumns, data[i].size());
        }
        size_t columns = dataColumns;
        size_t columnOffset = 0;
        if (columnHeadings.size() != 0) 
        {
            ++rows;
            rowOffset = 1;
        }
        if (rowHeadings.size() != 0) 
        {
            ++columns;
            columnOffset = 1;
        }

        xMatrix.val.array.rows = rows;
        xMatrix.val.array.columns = columns;
        xMatrix.val.array.lparray = new OPER[xMatrix.val.array.rows * xMatrix.val.array.columns]; 
        xMatrix.xltype = xltypeMulti | xlbitDLLFree;

        if (columnHeadings.size() != 0) 
        {
            for (size_t i=columnOffset; i<columns; ++i)
            {
                scalarToOper(columnHeadings[i-columnOffset], xMatrix.val.array.lparray[i]);
            }
        }

        if (rowHeadings.size() != 0) 
        {
            for (size_t i=rowOffset; i<rows; ++i)
            {
                scalarToOper(rowHeadings[i-rowOffset], xMatrix.val.array.lparray[i * columns]);
            }
        }

        for (size_t i=rowOffset; i<rows; ++i) 
        {
            for (size_t j=columnOffset; j<columns; ++j)
            {
                if (j < data[i-rowOffset].size()+columnOffset)
                {
                    scalarToOper(data[i-rowOffset][j-columnOffset], xMatrix.val.array.lparray[i * columns + j]);
                }
                else 
                {
                    scalarToOper(0.0, xMatrix.val.array.lparray[i * columns + j]);
                }
            }
        }

        if ((columnHeadings.size() != 0) && (rowHeadings.size() != 0))
        {
            scalarToOper("", xMatrix.val.array.lparray[0]);
        }
    }
Exemplo n.º 5
0
 void operator()(const std::vector<std::vector<T> >& v) {
     if(m_expand)
         matrixToOper(v, oper_);
     else
         scalarToOper("<MATRIX>", oper_);
 }
Exemplo n.º 6
0
 void operator()(const std::vector<T>& v) {
     if(m_expand)
         vectorToOper(v, oper_);
     else
         scalarToOper("<VECTOR>", oper_);
 }
Exemplo n.º 7
0
 void operator() (const T& t) { scalarToOper(t, oper_); }
Exemplo n.º 8
0
    DLL_API void scalarToOper(const char *value, OPER &xChar, bool expandVector) {
		scalarToOper(std::string(value), xChar, expandVector);
    }