void FirstOrderType1R::initComponents(Interaction& inter, VectorOfBlockVectors& DSlink, VectorOfVectors& workV, VectorOfSMatrices& workM) { // Check if an Interaction is connected to the Relation. unsigned int sizeY = inter.getSizeOfY(); unsigned int sizeDS = inter.getSizeOfDS(); unsigned int sizeZ = DSlink[FirstOrderR::z]->size(); workV.resize(FirstOrderR::workVecSize); workV[FirstOrderR::vec_z].reset(new SiconosVector(sizeZ)); workV[FirstOrderR::vec_x].reset(new SiconosVector(sizeDS)); workV[FirstOrderR::vec_r].reset(new SiconosVector(sizeDS)); workM.resize(FirstOrderR::mat_workMatSize); if (!_C) workM[FirstOrderR::mat_C].reset(new SimpleMatrix(sizeY, sizeDS)); if (!_D) workM[FirstOrderR::mat_D].reset(new SimpleMatrix(sizeY, sizeY)); if (!_F) workM[FirstOrderR::mat_F].reset(new SimpleMatrix(sizeY, sizeZ)); if (!_B) workM[FirstOrderR::mat_B].reset(new SimpleMatrix(sizeDS, sizeY)); }
void FirstOrderR::initialize(Interaction& inter, VectorOfBlockVectors& DSlink, VectorOfVectors& workV, VectorOfSMatrices& workM) { workV.resize(FirstOrderR::workVecSize); workM.resize(FirstOrderR::mat_workMatSize); initComponents(inter, DSlink, workV, workM); }
void FirstOrderLinearR::initComponents(Interaction& inter, VectorOfBlockVectors& DSlink, VectorOfVectors& workV, VectorOfSMatrices& workM) { // Note: do not call FirstOrderR::initialize to avoid jacobianH and jacobianG allocation. // get interesting size unsigned int sizeY = inter.getSizeOfY(); unsigned int sizeX = inter.getSizeOfDS(); unsigned int sizeZ = DSlink[FirstOrderR::z]->size(); // Update workV (copy of DS variables) workV.resize(FirstOrderR::workVecSize); workV[FirstOrderR::vec_z].reset(new SiconosVector(sizeZ)); workM.resize(FirstOrderR::mat_workMatSize); if (!_C && _pluginJachx->fPtr) workM[FirstOrderR::mat_C].reset(new SimpleMatrix(sizeY, sizeX)); if (!_D && _pluginJachlambda->fPtr) workM[FirstOrderR::mat_D].reset(new SimpleMatrix(sizeY, sizeY)); if (!_B && _pluginJacglambda->fPtr) workM[FirstOrderR::mat_B].reset(new SimpleMatrix(sizeX, sizeY)); if (!_F && _pluginf->fPtr) { workM[FirstOrderR::mat_F].reset(new SimpleMatrix(sizeY, sizeZ)); } if (!_e && _plugine->fPtr) { workV[FirstOrderR::e].reset(new SiconosVector(sizeY)); } // Check if various operators sizes are consistent. // Reference: interaction. if (_C) { if (_C->size(0) == 0) _C->resize(sizeX, sizeY); else assert((_C->size(0) == sizeY && _C->size(1) == sizeX) && "FirstOrderLinearR::initialize , inconsistent size between C and Interaction."); } if (_B) { if (_B->size(0) == 0) _B->resize(sizeY, sizeX); else assert((_B->size(1) == sizeY && _B->size(0) == sizeX) && "FirstOrderLinearR::initialize , inconsistent size between B and interaction."); } // C and B are the minimum inputs. The others may remain null. if (_D) { if (_D->size(0) == 0) _D->resize(sizeY, sizeY); else assert((_D->size(0) == sizeY || _D->size(1) == sizeY) && "FirstOrderLinearR::initialize , inconsistent size between C and D."); } if (_F) { if (_F->size(0) == 0) _F->resize(sizeY, sizeZ); else assert(((_F->size(0) == sizeY) && (_F->size(1) == sizeZ)) && "FirstOrderLinearR::initialize , inconsistent size between C and F."); } if (_e) { if (_e->size() == 0) _e->resize(sizeY); else assert(_e->size() == sizeY && "FirstOrderLinearR::initialize , inconsistent size between C and e."); } }