void fillNumericsMatrix(NumericsMatrix* M, int storageType, int size0, int size1, void* data) { M->storageType = storageType; M->size0 = size0; M->size1 = size1; NM_null(M); if (data) { switch (storageType) { case NM_DENSE: M->matrix0 = (double*) data; break; case NM_SPARSE_BLOCK: M->matrix1 = (SparseBlockStructuredMatrix*) data; break; case NM_SPARSE: M->matrix2 = (NumericsSparseMatrix*) data; break; default: printf("fillNumericsMatrix :: storageType value %d not implemented yet !", storageType); exit(EXIT_FAILURE); } } }
// construct by copy of SiconosMatrix OSNSMatrix::OSNSMatrix(const SiconosMatrix& MSource): _dimRow(MSource.size(0)), _dimColumn(MSource.size(1)), _storageType(NM_DENSE) { _numericsMat.reset(new NumericsMatrix); NM_null(_numericsMat.get()); _M1.reset(new SimpleMatrix(MSource)); }
OSNSMatrix::OSNSMatrix(unsigned int n, unsigned int m, int stor): _dimRow(n), _dimColumn(m), _storageType(stor) { // Note: // for _storageType = NM_DENSE (dense) n represents the real dimension of // the matrix and for sparse storage (_storageType == 1) the number // of interactionBlocks in a row or column. DEBUG_BEGIN("OSNSMatrix::OSNSMatrix(unsigned int n, unsigned int m, int stor)\n"); switch(_storageType) { case NM_DENSE: { // A zero matrix M of size nXn is built. interactionBlocksPositions // remains empty (=NULL) since we have no information concerning // the Interaction. _M1.reset(new SimpleMatrix(n, n)); break; } case NM_SPARSE_BLOCK: { _M2.reset(new BlockCSRMatrix(n)); break; } default: {} // do nothing here } _numericsMat.reset(new NumericsMatrix); NM_null(_numericsMat.get()); DEBUG_END("OSNSMatrix::OSNSMatrix(unsigned int n, unsigned int m, int stor)\n"); }
// Basic constructor OSNSMatrix::OSNSMatrix(SP::InteractionsGraph indexSet, int stor): _dimRow(0), _dimColumn(0), _storageType(stor) { _numericsMat.reset(new NumericsMatrix); NM_null(_numericsMat.get()); fill(indexSet); }
NumericsMatrix* newNumericsMatrix(void) { NumericsMatrix* M = (NumericsMatrix*) malloc(sizeof(NumericsMatrix)); M->storageType = -1; M->size0 = 0; M->size1 = 0; NM_null(M); return M; }