MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
SpMapMatrixHandler Class Reference

#include <spmapmh.h>

Inheritance diagram for SpMapMatrixHandler:
Collaboration diagram for SpMapMatrixHandler:

Classes

class  const_iterator
 

Public Member Functions

SpMapMatrixHandler::const_iterator begin (void) const
 
const
SpMapMatrixHandler::const_iterator
end (void) const
 
 SpMapMatrixHandler (const integer &n=0, const integer &nn=0)
 
virtual ~SpMapMatrixHandler (void)
 
doublerealoperator() (integer i_row, integer i_col)
 
void IncCoef (integer ix, integer iy, const doublereal &inc)
 
void DecCoef (integer ix, integer iy, const doublereal &inc)
 
void PutCoef (integer ix, integer iy, const doublereal &val)
 
const doublerealdGetCoef (integer ix, integer iy) const
 
const doublerealoperator() (integer ix, integer iy) const
 
integer MakeCompressedColumnForm (doublereal *const Ax, integer *const Ai, integer *const Ap, int offset=0) const
 
integer MakeCompressedColumnForm (std::vector< doublereal > &Ax, std::vector< integer > &Ai, std::vector< integer > &Ap, int offset=0) const
 
integer MakeIndexForm (doublereal *const Ax, integer *const Arow, integer *const Acol, integer *const AcolSt, int offset=0) const
 
integer MakeIndexForm (std::vector< doublereal > &Ax, std::vector< integer > &Arow, std::vector< integer > &Acol, std::vector< integer > &AcolSt, int offset=0) const
 
void Reset (void)
 
void Resize (integer ir, integer ic)
 
VectorHandlerGetCol (integer icol, VectorHandler &out) const
 
MatrixHandlerMulAndSumWithShift (MatrixHandler &out, doublereal s=1., integer drow=0, integer dcol=0) const
 
MatrixHandlerFakeThirdOrderMulAndSumWithShift (MatrixHandler &out, std::vector< bool > b, doublereal s=1., integer drow=0, integer dcol=0) const
 
- Public Member Functions inherited from SparseMatrixHandler
const integer Nz () const
 
 SparseMatrixHandler (const integer &n, const integer &nn=0)
 
virtual ~SparseMatrixHandler (void)
 
integer iGetNumRows (void) const
 
integer iGetNumCols (void) const
 
- Public Member Functions inherited from MatrixHandler
virtual ~MatrixHandler (void)
 
virtual void ResizeReset (integer, integer)
 
virtual const doublerealpdGetMat (void) const
 
virtual doublerealpdGetMat (void)
 
virtual integerpiGetRows (void) const
 
virtual integerpiGetCols (void) const
 
virtual integer PacMat (void)
 
virtual MatrixHandleroperator= (const MatrixHandler &MH)
 
virtual MatrixHandleroperator+= (const SubMatrixHandler &SubMH)
 
virtual MatrixHandleroperator-= (const SubMatrixHandler &SubMH)
 
virtual MatrixHandleroperator+= (const VariableSubMatrixHandler &SubMH)
 
virtual MatrixHandleroperator-= (const VariableSubMatrixHandler &SubMH)
 
virtual MatrixHandlerScalarMul (const doublereal &d)
 
virtual MatrixHandlerMatMatMul (MatrixHandler &out, const MatrixHandler &in) const
 
virtual MatrixHandlerMatTMatMul (MatrixHandler &out, const MatrixHandler &in) const
 
virtual MatrixHandlerMatMatIncMul (MatrixHandler &out, const MatrixHandler &in) const
 
virtual MatrixHandlerMatTMatIncMul (MatrixHandler &out, const MatrixHandler &in) const
 
virtual MatrixHandlerMatMatDecMul (MatrixHandler &out, const MatrixHandler &in) const
 
virtual MatrixHandlerMatTMatDecMul (MatrixHandler &out, const MatrixHandler &in) const
 
virtual VectorHandlerMatVecMul (VectorHandler &out, const VectorHandler &in) const
 
virtual VectorHandlerMatTVecMul (VectorHandler &out, const VectorHandler &in) const
 
virtual VectorHandlerMatVecIncMul (VectorHandler &out, const VectorHandler &in) const
 
virtual VectorHandlerMatTVecIncMul (VectorHandler &out, const VectorHandler &in) const
 
virtual VectorHandlerMatVecDecMul (VectorHandler &out, const VectorHandler &in) const
 
virtual VectorHandlerMatTVecDecMul (VectorHandler &out, const VectorHandler &in) const
 
virtual doublereal ConditionNumber (enum Norm_t eNorm=NORM_1) const
 
virtual doublereal Norm (enum Norm_t eNorm=NORM_1) const
 

Protected Member Functions

MatrixHandlerMatMatMul_base (void(MatrixHandler::*op)(integer iRow, integer iCol, const doublereal &dCoef), MatrixHandler &out, const MatrixHandler &in) const
 
MatrixHandlerMatTMatMul_base (void(MatrixHandler::*op)(integer iRow, integer iCol, const doublereal &dCoef), MatrixHandler &out, const MatrixHandler &in) const
 
virtual VectorHandlerMatVecMul_base (void(VectorHandler::*op)(integer iRow, const doublereal &dCoef), VectorHandler &out, const VectorHandler &in) const
 
virtual VectorHandlerMatTVecMul_base (void(VectorHandler::*op)(integer iRow, const doublereal &dCoef), VectorHandler &out, const VectorHandler &in) const
 

Private Types

typedef std::map< integer,
doublereal
row_cont_type
 

Private Member Functions

 SpMapMatrixHandler (const SpMapMatrixHandler &)
 

Private Attributes

std::vector< row_cont_typecol_indices
 
const_iterator m_end
 

Additional Inherited Members

- Public Types inherited from MatrixHandler
enum  Norm_t { NORM_1, NORM_INF }
 
- Protected Attributes inherited from SparseMatrixHandler
integer NRows
 
integer NCols
 
integer NZ
 

Detailed Description

Definition at line 76 of file spmapmh.h.

Member Typedef Documentation

Definition at line 78 of file spmapmh.h.

Constructor & Destructor Documentation

SpMapMatrixHandler::SpMapMatrixHandler ( const SpMapMatrixHandler )
private
SpMapMatrixHandler::SpMapMatrixHandler ( const integer n = 0,
const integer nn = 0 
)

Definition at line 68 of file spmapmh.cc.

References col_indices, and SparseMatrixHandler::NCols.

69 : SparseMatrixHandler(n, nn), m_end(*this, true)
70 {
71  col_indices.resize(NCols);
72 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
SparseMatrixHandler(const integer &n, const integer &nn=0)
Definition: spmh.cc:38
const_iterator m_end
Definition: spmapmh.h:113
integer NCols
Definition: spmh.h:46
SpMapMatrixHandler::~SpMapMatrixHandler ( void  )
virtual

Definition at line 74 of file spmapmh.cc.

References NO_OP.

75 {
76  NO_OP;
77 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

void SpMapMatrixHandler::DecCoef ( integer  ix,
integer  iy,
const doublereal inc 
)
inlinevirtual

Reimplemented from MatrixHandler.

Definition at line 170 of file spmapmh.h.

References ASSERTMSGBREAK, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, and operator()().

Referenced by SchurMatrixHandler::DecCoef(), and SchurMatrixHandlerUm::DecCoef().

170  {
171  ASSERTMSGBREAK(ix > 0 && ix <= NRows,
172  "Error in SpMapMatrixHandler::DecCoef(), "
173  "row index out of range");
174  ASSERTMSGBREAK(iy > 0 && iy <= NCols,
175  "Error in SpMapMatrixHandler::DecCoef(), "
176  "col index out of range");
177 #ifdef MBDYN_X_KEEP_SPARSITY
178  /* try to keep sparsity */
179  if (inc != 0.) {
180 #endif /* MBDYN_X_KEEP_SPARSITY */
181  operator()(ix,iy) -= inc;
182 #ifdef MBDYN_X_KEEP_SPARSITY
183  }
184 #endif /* MBDYN_X_KEEP_SPARSITY */
185  };
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
doublereal & operator()(integer i_row, integer i_col)
Definition: spmapmh.h:129
integer NRows
Definition: spmh.h:45
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

const doublereal& SpMapMatrixHandler::dGetCoef ( integer  ix,
integer  iy 
) const
inlinevirtual

Reimplemented from MatrixHandler.

Definition at line 211 of file spmapmh.h.

References ASSERTMSGBREAK, col_indices, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, and Zero1.

211  {
212  ASSERTMSGBREAK(ix > 0 && ix <= NRows,
213  "Error in SpMapMatrixHandler::dGetCoef(), "
214  "row index out of range");
215  ASSERTMSGBREAK(iy > 0 && iy <= NCols,
216  "Error in SpMapMatrixHandler::dGetCoef(), "
217  "col index out of range");
218  row_cont_type::iterator i;
219  row_cont_type& row = col_indices[iy - 1];
220  i = row.find(ix - 1);
221  if (i == row.end()) {
223 
224  } else {
225  return i->second;
226  }
227  };
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::map< integer, doublereal > row_cont_type
Definition: spmapmh.h:78
const doublereal Zero1
integer NRows
Definition: spmh.h:45
integer NCols
Definition: spmh.h:46
const SpMapMatrixHandler::const_iterator& SpMapMatrixHandler::end ( void  ) const
inline

Definition at line 120 of file spmapmh.h.

References m_end.

Referenced by main(), and DataManager::OutputEigSparseMatrices().

120  {
121  return m_end;
122  };
const_iterator m_end
Definition: spmapmh.h:113
MatrixHandler & SpMapMatrixHandler::FakeThirdOrderMulAndSumWithShift ( MatrixHandler out,
std::vector< bool b,
doublereal  s = 1.,
integer  drow = 0,
integer  dcol = 0 
) const

Definition at line 296 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), MatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), MatrixHandler::iGetNumRows(), MatrixHandler::IncCoef(), MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::NCols.

Referenced by ThirdOrderIntegrator::Jacobian().

299 {
300  if ((out.iGetNumCols() < iGetNumCols() + dcol)
301  || (out.iGetNumRows() < iGetNumRows() + drow))
302  {
303  silent_cerr("Assertion fault "
304  "in SpMapMatrixHandler::MulAndSumWithShift"
305  << std::endl);
307  }
308 
309  drow = drow + 1;
310 
311  for (integer col = 0; col < NCols; col++) {
312  row_cont_type::const_iterator ri, re;
313  re = col_indices[col].end();
314  integer newcol = col + dcol + 1;
315  for (ri = col_indices[col].begin(); ri != re; ++ri) {
316  if (b[ri->first]) {
317  out.IncCoef(ri->first + drow,
318  newcol, ri->second*s);
319  }
320  }
321  }
322 
323  return out;
324 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
virtual integer iGetNumCols(void) const =0
virtual void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: mh.cc:374
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

VectorHandler & SpMapMatrixHandler::GetCol ( integer  icol,
VectorHandler out 
) const
virtual

Implements SparseMatrixHandler.

Definition at line 194 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), and MBDYN_EXCEPT_ARGS.

195 {
196  if (icol > iGetNumCols()) {
198  }
199 
200  row_cont_type::const_iterator ri, re;
201  re = col_indices[icol].end();
202  for (ri = col_indices[icol].begin(); ri != re; ++ri) {
203  out(ri->first + 1) = ri->second;
204  }
205  return out;
206 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116

Here is the call graph for this function:

void SpMapMatrixHandler::IncCoef ( integer  ix,
integer  iy,
const doublereal inc 
)
inlinevirtual

Reimplemented from MatrixHandler.

Definition at line 153 of file spmapmh.h.

References ASSERTMSGBREAK, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, and operator()().

Referenced by SchurMatrixHandler::IncCoef(), and SchurMatrixHandlerUm::IncCoef().

153  {
154  ASSERTMSGBREAK(ix > 0 && ix <= NRows,
155  "Error in SpMapMatrixHandler::IncCoef(), "
156  "row index out of range");
157  ASSERTMSGBREAK(iy > 0 && iy <= NCols,
158  "Error in SpMapMatrixHandler::IncCoef(), "
159  "col index out of range");
160 #ifdef MBDYN_X_KEEP_SPARSITY
161  /* try to keep sparsity */
162  if (inc != 0.) {
163 #endif /* MBDYN_X_KEEP_SPARSITY */
164  operator()(ix,iy) += inc;
165 #ifdef MBDYN_X_KEEP_SPARSITY
166  }
167 #endif /* MBDYN_X_KEEP_SPARSITY */
168  };
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
doublereal & operator()(integer i_row, integer i_col)
Definition: spmapmh.h:129
integer NRows
Definition: spmh.h:45
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

integer SpMapMatrixHandler::MakeCompressedColumnForm ( doublereal *const  Ax,
integer *const  Ai,
integer *const  Ap,
int  offset = 0 
) const
virtual

Implements SparseMatrixHandler.

Definition at line 80 of file spmapmh.cc.

References ASSERTMSGBREAK, begin(), col_indices, SparseMatrixHandler::NCols, SparseMatrixHandler::NZ, and SparseMatrixHandler::Nz().

Referenced by main(), and MakeCompressedColumnForm().

82 {
83  integer x_ptr = 0;
84 
85  row_cont_type::iterator ri;
86  row_cont_type::const_iterator re;
87 
88  for (integer col = 0; col < NCols; col++) {
89  Ap[col] = x_ptr + offset;
90  re = col_indices[col].end();
91  for (ri = col_indices[col].begin(); ri != re; ++ri) {
92  Ax[x_ptr] = ri->second;
93  Ai[x_ptr] = ri->first + offset;
94  x_ptr++;
95  }
96  }
97 
98  ASSERTMSGBREAK(x_ptr == NZ, "Error in "
99  "SpMapMatrixHandler::MakeCompressedColumnForm");
100 
101  Ap[NCols] = x_ptr + offset;
102 
103  return Nz();
104 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
const integer Nz() const
Definition: spmh.h:104
integer NZ
Definition: spmh.h:47
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

integer SpMapMatrixHandler::MakeCompressedColumnForm ( std::vector< doublereal > &  Ax,
std::vector< integer > &  Ai,
std::vector< integer > &  Ap,
int  offset = 0 
) const
virtual

Implements SparseMatrixHandler.

Definition at line 107 of file spmapmh.cc.

References SparseMatrixHandler::iGetNumCols(), MakeCompressedColumnForm(), and SparseMatrixHandler::Nz().

110 {
111  Ax.resize(Nz());
112  Ai.resize(Nz());
113  Ap.resize(iGetNumCols() + 1);
114 
115  return MakeCompressedColumnForm(&Ax[0], &Ai[0], &Ap[0], offset);
116 }
integer MakeCompressedColumnForm(doublereal *const Ax, integer *const Ai, integer *const Ap, int offset=0) const
Definition: spmapmh.cc:80
const integer Nz() const
Definition: spmh.h:104
integer iGetNumCols(void) const
Definition: spmh.h:117

Here is the call graph for this function:

integer SpMapMatrixHandler::MakeIndexForm ( doublereal *const  Ax,
integer *const  Arow,
integer *const  Acol,
integer *const  AcolSt,
int  offset = 0 
) const
virtual

Implements SparseMatrixHandler.

Definition at line 119 of file spmapmh.cc.

References ASSERTMSGBREAK, begin(), col_indices, SparseMatrixHandler::NCols, SparseMatrixHandler::NZ, and SparseMatrixHandler::Nz().

Referenced by MakeIndexForm().

122 {
123  integer x_ptr = 0;
124 
125  row_cont_type::iterator ri;
126  row_cont_type::const_iterator re;
127 
128  for (integer col = 0; col < NCols; col++) {
129  Ap[col] = x_ptr + offset;
130  re = col_indices[col].end();
131  for (ri = col_indices[col].begin(); ri != re; ++ri) {
132  Ax[x_ptr] = ri->second;
133  Arow[x_ptr] = ri->first + offset;
134  Acol[x_ptr] = col + offset;
135  x_ptr++;
136  }
137  }
138 
139  ASSERTMSGBREAK(x_ptr == NZ, "Error in "
140  "SpMapMatrixHandler::MakeIndexForm");
141 
142  Ap[NCols] = x_ptr + offset;
143 
144  return Nz();
145 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
const integer Nz() const
Definition: spmh.h:104
integer NZ
Definition: spmh.h:47
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

integer SpMapMatrixHandler::MakeIndexForm ( std::vector< doublereal > &  Ax,
std::vector< integer > &  Arow,
std::vector< integer > &  Acol,
std::vector< integer > &  AcolSt,
int  offset = 0 
) const
virtual

Implements SparseMatrixHandler.

Definition at line 148 of file spmapmh.cc.

References SparseMatrixHandler::iGetNumCols(), MakeIndexForm(), and SparseMatrixHandler::Nz().

151 {
152  Ax.resize(Nz());
153  Arow.resize(Nz());
154  Acol.resize(Nz());
155  Ap.resize(iGetNumCols() + 1);
156 
157  return MakeIndexForm(&Ax[0], &Arow[0], &Acol[0], &Ap[0], offset);
158 }
const integer Nz() const
Definition: spmh.h:104
integer iGetNumCols(void) const
Definition: spmh.h:117
integer MakeIndexForm(doublereal *const Ax, integer *const Arow, integer *const Acol, integer *const AcolSt, int offset=0) const
Definition: spmapmh.cc:119

Here is the call graph for this function:

MatrixHandler & SpMapMatrixHandler::MatMatMul_base ( void(MatrixHandler::*)(integer iRow, integer iCol, const doublereal &dCoef)  op,
MatrixHandler out,
const MatrixHandler in 
) const
protectedvirtual

Reimplemented from MatrixHandler.

Definition at line 210 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), MatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), MatrixHandler::iGetNumRows(), MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::NCols.

213 {
214  if ((in.iGetNumRows() != iGetNumCols())
215  || (in.iGetNumCols() != out.iGetNumCols())
216  || (out.iGetNumRows() != iGetNumRows()))
217  {
218  silent_cerr("Assertion fault "
219  "in SpMapMatrixHandler::MatMatIncMul" << std::endl);
221  }
222 
223  integer ncols_in = in.iGetNumCols();
224  for (integer row_in = 0; row_in < NCols; row_in++) {
225  row_cont_type::const_iterator ri, re;
226  re = col_indices[row_in].end();
227  for (ri = col_indices[row_in].begin(); ri != re; ++ri) {
228  for (integer col_in = 1; col_in <= ncols_in; col_in++) {
229  (out.*op)(ri->first + 1, col_in,
230  ri->second*in(row_in + 1, col_in));
231  }
232  }
233  }
234 
235  return out;
236 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
virtual integer iGetNumCols(void) const =0
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

MatrixHandler & SpMapMatrixHandler::MatTMatMul_base ( void(MatrixHandler::*)(integer iRow, integer iCol, const doublereal &dCoef)  op,
MatrixHandler out,
const MatrixHandler in 
) const
protectedvirtual

Reimplemented from MatrixHandler.

Definition at line 239 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), MatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), MatrixHandler::iGetNumRows(), MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::NCols.

242 {
243  if ((in.iGetNumRows() != iGetNumCols())
244  || (in.iGetNumCols() != out.iGetNumCols())
245  || (out.iGetNumRows() != iGetNumRows()))
246  {
247  silent_cerr("Assertion fault "
248  "in SpMapMatrixHandler::MatTMatMul_base" << std::endl);
250  }
251 
252  integer ncols_in = in.iGetNumCols();
253  for (integer row_out = 0; row_out < NCols; row_out++) {
254  row_cont_type::const_iterator ri, re;
255  re = col_indices[row_out].end();
256  for (ri = col_indices[row_out].begin(); ri != re; ++ri) {
257  for (integer col_in = 1; col_in <= ncols_in; col_in++) {
258  (out.*op)(row_out + 1, col_in,
259  ri->second*in(ri->first + 1, col_in));
260  }
261  }
262  }
263 
264  return out;
265 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
virtual integer iGetNumCols(void) const =0
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

VectorHandler & SpMapMatrixHandler::MatTVecMul_base ( void(VectorHandler::*)(integer iRow, const doublereal &dCoef)  op,
VectorHandler out,
const VectorHandler in 
) const
protectedvirtual

Reimplemented from MatrixHandler.

Definition at line 351 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), VectorHandler::iGetSize(), MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::NCols.

354 {
355  if (out.iGetSize() != iGetNumCols()
356  || in.iGetSize() != iGetNumRows())
357  {
359  }
360 
361  row_cont_type::const_iterator ri, re;
362 
363  for (integer col = 0; col < NCols; col++) {
364  doublereal d = 0.;
365  re = col_indices[col].end();
366  for (ri = col_indices[col].begin(); ri != re; ++ri) {
367  d += ri->second*in(ri->first + 1);
368  }
369  (out.*op)(col+1, d);
370  }
371 
372  return out;
373 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
virtual integer iGetSize(void) const =0
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

VectorHandler & SpMapMatrixHandler::MatVecMul_base ( void(VectorHandler::*)(integer iRow, const doublereal &dCoef)  op,
VectorHandler out,
const VectorHandler in 
) const
protectedvirtual

Reimplemented from MatrixHandler.

Definition at line 327 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), VectorHandler::iGetSize(), MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::NCols.

330 {
331  if (in.iGetSize() != iGetNumCols()
332  || out.iGetSize() != iGetNumRows())
333  {
335  }
336 
337  row_cont_type::const_iterator ri, re;
338 
339  for (integer col = 0; col < NCols; col++) {
340  re = col_indices[col].end();
341  for (ri = col_indices[col].begin(); ri != re; ++ri) {
342  doublereal d = ri->second*in(col + 1);
343  (out.*op)(ri->first + 1, d);
344  }
345  }
346 
347  return out;
348 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
virtual integer iGetSize(void) const =0
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

MatrixHandler & SpMapMatrixHandler::MulAndSumWithShift ( MatrixHandler out,
doublereal  s = 1.,
integer  drow = 0,
integer  dcol = 0 
) const

Definition at line 269 of file spmapmh.cc.

References begin(), col_indices, SparseMatrixHandler::iGetNumCols(), MatrixHandler::iGetNumCols(), SparseMatrixHandler::iGetNumRows(), MatrixHandler::iGetNumRows(), MatrixHandler::IncCoef(), MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::NCols.

Referenced by ThirdOrderIntegrator::Jacobian().

271 {
272  if ((out.iGetNumCols() < iGetNumCols() + dcol)
273  || (out.iGetNumRows() < iGetNumRows() + drow))
274  {
275  silent_cerr("Assertion fault "
276  "in SpMapMatrixHandler::MulAndSumWithShift"
277  << std::endl);
279  }
280 
281  drow = drow + 1;
282 
283  for (integer col = 0; col < NCols; col++) {
284  row_cont_type::const_iterator ri, re;
285  re = col_indices[col].end();
286  integer newcol = col + dcol + 1;
287  for (ri = col_indices[col].begin(); ri != re; ++ri) {
288  out.IncCoef(ri->first + drow, newcol, ri->second*s);
289  }
290  }
291 
292  return out;
293 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
virtual integer iGetNumCols(void) const =0
virtual void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: mh.cc:374
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
integer iGetNumRows(void) const
Definition: spmh.h:113
integer iGetNumCols(void) const
Definition: spmh.h:117
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

doublereal& SpMapMatrixHandler::operator() ( integer  i_row,
integer  i_col 
)
inlinevirtual

Implements MatrixHandler.

Definition at line 129 of file spmapmh.h.

References ASSERTMSGBREAK, col_indices, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, and SparseMatrixHandler::NZ.

Referenced by DecCoef(), IncCoef(), and PutCoef().

129  {
130  ASSERTMSGBREAK(i_row > 0 && i_row <= NRows,
131  "Error in SpMapMatrixHandler::operator(), "
132  "row index out of range");
133  ASSERTMSGBREAK(i_col > 0 && i_col <= NCols,
134  "Error in SpMapMatrixHandler::operator(), "
135  "col index out of range");
136  i_row--;
137  i_col--;
138  row_cont_type::iterator i;
139  row_cont_type& row = col_indices[i_col];
140  i = row.find(i_row);
141  if (i == row.end()) {
142  NZ++;
143 
144  row[i_row] = 0.;
145 
146  return row[i_row];
147 
148  } else {
149  return i->second;
150  }
151  };
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::map< integer, doublereal > row_cont_type
Definition: spmapmh.h:78
integer NZ
Definition: spmh.h:47
integer NRows
Definition: spmh.h:45
integer NCols
Definition: spmh.h:46
const doublereal& SpMapMatrixHandler::operator() ( integer  ix,
integer  iy 
) const
inlinevirtual

Implements MatrixHandler.

Definition at line 229 of file spmapmh.h.

References ASSERTMSGBREAK, col_indices, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, and Zero1.

229  {
230  ASSERTMSGBREAK(ix > 0 && ix <= NRows,
231  "Error in SpMapMatrixHandler::operator(), "
232  "row index out of range");
233  ASSERTMSGBREAK(iy > 0 && iy <= NCols,
234  "Error in SpMapMatrixHandler::operator(), "
235  "col index out of range");
236  row_cont_type::iterator i;
237  row_cont_type& row = col_indices[iy - 1];
238  i = row.find(ix - 1);
239  if (i == row.end()) {
241 
242  } else {
243  return i->second;
244  }
245  };
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::map< integer, doublereal > row_cont_type
Definition: spmapmh.h:78
const doublereal Zero1
integer NRows
Definition: spmh.h:45
integer NCols
Definition: spmh.h:46
void SpMapMatrixHandler::PutCoef ( integer  ix,
integer  iy,
const doublereal val 
)
inlinevirtual

Reimplemented from MatrixHandler.

Definition at line 187 of file spmapmh.h.

References ASSERTMSGBREAK, col_indices, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, and operator()().

Referenced by SchurMatrixHandler::PutCoef(), SchurMatrixHandlerUm::PutCoef(), and ReadAerodynamicModal().

187  {
188  ASSERTMSGBREAK(ix - 1 < NRows,
189  "Error in SpMapMatrixHandler::PutCoef(), "
190  "row index out of range");
191  ASSERTMSGBREAK(iy - 1 < NCols,
192  "Error in SpMapMatrixHandler::PutCoef(), "
193  "col index out of range");
194 #ifdef MBDYN_X_KEEP_SPARSITY
195  /* try to keep sparsity */
196  if (val != 0.) {
197 #endif /* MBDYN_X_KEEP_SPARSITY */
198  operator()(ix,iy) = val;
199 #ifdef MBDYN_X_KEEP_SPARSITY
200  } else {
201  row_cont_type::iterator i;
202  row_cont_type& row = col_indices[iy-1];
203  i = row.find(ix - 1);
204  if (i != row.end()) {
205  i->second = val;
206  }
207  }
208 #endif /* MBDYN_X_KEEP_SPARSITY */
209  };
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::map< integer, doublereal > row_cont_type
Definition: spmapmh.h:78
doublereal & operator()(integer i_row, integer i_col)
Definition: spmapmh.h:129
integer NRows
Definition: spmh.h:45
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

void SpMapMatrixHandler::Reset ( void  )
virtual

Implements MatrixHandler.

Definition at line 161 of file spmapmh.cc.

References begin(), col_indices, and SparseMatrixHandler::NCols.

Referenced by main(), SchurMatrixHandler::MatEFCReset(), SchurMatrixHandlerUm::MatEFCReset(), and ReadAerodynamicModal().

162 {
163  row_cont_type::const_iterator re;
164  row_cont_type::iterator ri;
165  for (integer col = 0; col < NCols; col++) {
166  re = col_indices[col].end();
167  for (ri = col_indices[col].begin(); ri != re; ++ri) {
168  ri->second = 0.;
169  }
170  }
171 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
SpMapMatrixHandler::const_iterator begin(void) const
Definition: spmapmh.h:116
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

void SpMapMatrixHandler::Resize ( integer  ir,
integer  ic 
)
virtual

Implements MatrixHandler.

Definition at line 174 of file spmapmh.cc.

References col_indices, m_end, SparseMatrixHandler::NCols, SparseMatrixHandler::NRows, SparseMatrixHandler::NZ, and SpMapMatrixHandler::const_iterator::reset().

Referenced by ThirdOrderIntegrator::Advance().

175 {
176  if (nn == 0) {
177  nn = n;
178  }
179 
180  for (integer col = 0; col < NCols; col++) {
181  col_indices[col].clear();
182  }
183 
184  col_indices.resize(nn);
185  NRows = n;
186  NCols = nn;
187  NZ = 0;
188 
189  m_end.reset();
190 }
std::vector< row_cont_type > col_indices
Definition: spmapmh.h:79
integer NZ
Definition: spmh.h:47
void reset(bool is_end=false)
Definition: spmapmh.cc:376
const_iterator m_end
Definition: spmapmh.h:113
integer NRows
Definition: spmh.h:45
long int integer
Definition: colamd.c:51
integer NCols
Definition: spmh.h:46

Here is the call graph for this function:

Member Data Documentation

const_iterator SpMapMatrixHandler::m_end
private

Definition at line 113 of file spmapmh.h.

Referenced by end(), and Resize().


The documentation for this class was generated from the following files: