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

#include <naivemh.h>

Inheritance diagram for NaiveMatrixHandler:
Collaboration diagram for NaiveMatrixHandler:

Classes

class  const_iterator
 

Public Member Functions

NaiveMatrixHandler::const_iterator begin (void) const
 
const
NaiveMatrixHandler::const_iterator
end (void) const
 
 NaiveMatrixHandler (const integer n, NaiveMatrixHandler *const nmh=0)
 
virtual ~NaiveMatrixHandler (void)
 
integer iGetNumRows (void) const
 
integer iGetNumCols (void) const
 
void Reset (void)
 
virtual void Resize (integer, integer)
 
virtual const doublerealoperator() (integer iRow, integer iCol) const
 
virtual doublerealoperator() (integer iRow, integer iCol)
 
virtual MatrixHandleroperator+= (const SubMatrixHandler &SubMH)
 
virtual MatrixHandleroperator-= (const SubMatrixHandler &SubMH)
 
virtual MatrixHandleroperator+= (const VariableSubMatrixHandler &SubMH)
 
virtual MatrixHandleroperator-= (const VariableSubMatrixHandler &SubMH)
 
void MakeCCStructure (std::vector< integer > &Ai, std::vector< integer > &Ap)
 
- 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 void PutCoef (integer iRow, integer iCol, const doublereal &dCoef)
 
virtual void IncCoef (integer iRow, integer iCol, const doublereal &dCoef)
 
virtual void DecCoef (integer iRow, integer iCol, const doublereal &dCoef)
 
virtual const doublerealdGetCoef (integer iRow, integer iCol) const
 
virtual MatrixHandleroperator= (const MatrixHandler &MH)
 
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

virtual MatrixHandlerMatMatMul_base (void(MatrixHandler::*op)(integer iRow, integer iCol, const doublereal &dCoef), MatrixHandler &out, const MatrixHandler &in) const
 
virtual 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
 

Protected Attributes

integer iSize
 
bool bOwnsMemory
 
doublereal ** ppdRows
 
integer ** ppiRows
 
integer ** ppiCols
 
char ** ppnonzero
 
integerpiNzr
 
integerpiNzc
 
const_iterator m_end
 

Private Member Functions

 NaiveMatrixHandler (const NaiveMatrixHandler &)
 

Friends

class NaiveSolver
 
class ParNaiveSolver
 
class MultiThreadDataManager
 
void * sum_naive_matrices (void *arg)
 

Additional Inherited Members

- Public Types inherited from MatrixHandler
enum  Norm_t { NORM_1, NORM_INF }
 

Detailed Description

Definition at line 47 of file naivemh.h.

Constructor & Destructor Documentation

NaiveMatrixHandler::NaiveMatrixHandler ( const NaiveMatrixHandler )
private
NaiveMatrixHandler::NaiveMatrixHandler ( const integer  n,
NaiveMatrixHandler *const  nmh = 0 
)

Definition at line 48 of file naivemh.cc.

References ASSERT, bOwnsMemory, iSize, piNzc, piNzr, ppdRows, ppiCols, ppiRows, ppnonzero, and SAFENEWARR.

50 : iSize(n), bOwnsMemory(true),
51 ppdRows(0), ppiRows(0), ppiCols(0), ppnonzero(0), piNzr(0), piNzc(0), m_end(*this, true)
52 {
53  if (nmh) {
54  bOwnsMemory = false;
55  iSize = nmh->iSize;
56  ppdRows = nmh->ppdRows;
57  ppiRows = nmh->ppiRows;
58  ppiCols = nmh->ppiCols;
59  ppnonzero = nmh->ppnonzero;
60  piNzr = nmh->piNzr;
61  piNzc = nmh->piNzc;
62 
63  } else {
64  ASSERT(iSize > 0);
65 
67  ppiRows[0] = 0;
69 
71  ppiCols[0] = 0;
73 
75  ppdRows[0] = NULL;
77 
78  SAFENEWARR(ppnonzero, char *, iSize);
79  ppnonzero[0] = NULL;
80  SAFENEWARR(ppnonzero[0], char, iSize*iSize);
81 
82  for (integer i = 1; i < iSize; i++) {
83  ppiRows[i] = ppiRows[i - 1] + iSize;
84  ppiCols[i] = ppiCols[i - 1] + iSize;
85  ppdRows[i] = ppdRows[i - 1] + iSize;
86  ppnonzero[i] = ppnonzero[i - 1] + iSize;
87  }
88 
89  SAFENEWARR(piNzr, integer, iSize);
90  SAFENEWARR(piNzc, integer, iSize);
91 
92 #ifdef HAVE_MEMSET
93  memset(ppdRows[0], 0, sizeof(doublereal)*iSize*iSize);
94  memset(ppnonzero[0], 0, sizeof(char)*iSize*iSize);
95  memset(piNzr, 0, sizeof(integer)*iSize);
96  memset(piNzc, 0, sizeof(integer)*iSize);
97 #else /* ! HAVE_MEMSET */
98  for (integer row = 0; row < iSize; row++) {
99  for (integer col = 0; col < iSize; col++) {
100  ppnonzero[row][col] = 0;
101  }
102  piNzr[row] = 0;
103  piNzc[row] = 0;
104  }
105 #endif /* ! HAVE_MEMSET */
106  }
107 }
doublereal ** ppdRows
Definition: naivemh.h:60
integer * piNzr
Definition: naivemh.h:63
integer ** ppiRows
Definition: naivemh.h:61
integer * piNzc
Definition: naivemh.h:63
char ** ppnonzero
Definition: naivemh.h:62
const_iterator m_end
Definition: naivemh.h:94
integer ** ppiCols
Definition: naivemh.h:61
#define ASSERT(expression)
Definition: colamd.c:977
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58
NaiveMatrixHandler::~NaiveMatrixHandler ( void  )
virtual

Definition at line 109 of file naivemh.cc.

References bOwnsMemory, piNzc, piNzr, ppdRows, ppiCols, ppiRows, ppnonzero, and SAFEDELETEARR.

110 {
111  if (bOwnsMemory) {
112  if (ppiRows) {
113  if (ppiRows[0]) {
115  }
117  }
118 
119  if (ppiCols) {
120  if (ppiCols[0]) {
122  }
124  }
125 
126  if (ppdRows) {
127  if (ppdRows[0]) {
129  }
131  }
132 
133  if (ppnonzero) {
134  if (ppnonzero[0]) {
136  }
138  }
139 
140  if (piNzr) {
142  }
143 
144  if (piNzc) {
146  }
147  }
148 }
doublereal ** ppdRows
Definition: naivemh.h:60
integer * piNzr
Definition: naivemh.h:63
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
integer ** ppiRows
Definition: naivemh.h:61
integer * piNzc
Definition: naivemh.h:63
char ** ppnonzero
Definition: naivemh.h:62
integer ** ppiCols
Definition: naivemh.h:61

Member Function Documentation

NaiveMatrixHandler::const_iterator NaiveMatrixHandler::begin ( void  ) const
inline

Definition at line 97 of file naivemh.h.

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

97  {
98  return const_iterator(*this);
99  };
const NaiveMatrixHandler::const_iterator& NaiveMatrixHandler::end ( void  ) const
inline

Definition at line 101 of file naivemh.h.

References m_end.

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

101  {
102  return m_end;
103  };
const_iterator m_end
Definition: naivemh.h:94
integer NaiveMatrixHandler::iGetNumCols ( void  ) const
inlinevirtual

Implements MatrixHandler.

Definition at line 115 of file naivemh.h.

References iSize.

Referenced by operator()(), and NaivePermMatrixHandler::operator()().

115  {
116  return iSize;
117  };
integer iSize
Definition: naivemh.h:58
integer NaiveMatrixHandler::iGetNumRows ( void  ) const
inlinevirtual

Implements MatrixHandler.

Definition at line 111 of file naivemh.h.

References iSize.

Referenced by main(), operator()(), and NaivePermMatrixHandler::operator()().

111  {
112  return iSize;
113  };
integer iSize
Definition: naivemh.h:58
void NaiveMatrixHandler::MakeCCStructure ( std::vector< integer > &  Ai,
std::vector< integer > &  Ap 
)

Definition at line 353 of file naivemh.cc.

References iSize, piNzr, and ppiRows.

354  {
355  integer nnz = 0;
356  for (integer i = 0; i < iSize; i++) {
357  nnz += piNzr[i];
358  }
359  Ai.resize(nnz);
360  Ap.resize(iSize + 1);
361  integer x_ptr = 0;
362  for (integer col = 0; col < iSize; col++) {
363  Ap[col] = x_ptr;
364  integer nzr = piNzr[col];
365  for (integer row = 0; row < nzr; row++) {
366  Ai[x_ptr] = ppiRows[col][row];
367  x_ptr++;
368  }
369  }
370  Ap[iSize] = nnz;
371 };
integer * piNzr
Definition: naivemh.h:63
integer ** ppiRows
Definition: naivemh.h:61
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58
MatrixHandler & NaiveMatrixHandler::MatMatMul_base ( void(MatrixHandler::*)(integer iRow, integer iCol, const doublereal &dCoef)  op,
MatrixHandler out,
const MatrixHandler in 
) const
protectedvirtual

Reimplemented from MatrixHandler.

Reimplemented in NaivePermMatrixHandler.

Definition at line 375 of file naivemh.cc.

References ASSERT, MatrixHandler::iGetNumCols(), MatrixHandler::iGetNumRows(), iSize, piNzc, ppdRows, and ppiCols.

378 {
379  ASSERT(in.iGetNumRows() == iSize);
380  ASSERT(out.iGetNumRows() == iSize);
381  ASSERT(out.iGetNumCols() == in.iGetNumCols());
382 
383  integer in_ncols = in.iGetNumCols();
384 
385  for (integer ir = 0; ir < iSize; ir++) {
386  for (integer idx = 0; idx < piNzc[ir]; idx++) {
387  integer ic = ppiCols[ir][idx];
388  for (integer ik = 1; ik <= in_ncols; ik++) {
389  (out.*op)(ir + 1, ik, ppdRows[ir][ic]*in(ic + 1, ik));
390  }
391  }
392  }
393 
394  return out;
395 }
doublereal ** ppdRows
Definition: naivemh.h:60
virtual integer iGetNumCols(void) const =0
integer * piNzc
Definition: naivemh.h:63
integer ** ppiCols
Definition: naivemh.h:61
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

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

Reimplemented from MatrixHandler.

Reimplemented in NaivePermMatrixHandler.

Definition at line 398 of file naivemh.cc.

References ASSERT, MatrixHandler::iGetNumCols(), MatrixHandler::iGetNumRows(), iSize, piNzr, ppdRows, and ppiRows.

401 {
402  ASSERT(in.iGetNumRows() == iSize);
403  ASSERT(out.iGetNumRows() == iSize);
404  ASSERT(out.iGetNumCols() == in.iGetNumCols());
405 
406  integer in_ncols = in.iGetNumCols();
407 
408  for (integer ic = 0; ic < iSize; ic++) {
409  for (integer idx = 0; idx < piNzr[ic]; idx++) {
410  integer ir = ppiRows[ic][idx];
411  for (integer ik = 1; ik <= in_ncols; ik++) {
412  (out.*op)(ic + 1, ik, ppdRows[ir][ic]*in(ir + 1, ik));
413  }
414  }
415  }
416 
417  return out;
418 }
doublereal ** ppdRows
Definition: naivemh.h:60
integer * piNzr
Definition: naivemh.h:63
virtual integer iGetNumCols(void) const =0
integer ** ppiRows
Definition: naivemh.h:61
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

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

Reimplemented from MatrixHandler.

Reimplemented in NaivePermMatrixHandler.

Definition at line 440 of file naivemh.cc.

References ASSERT, VectorHandler::iGetSize(), iSize, piNzr, ppdRows, and ppiRows.

443 {
444  ASSERT(in.iGetSize() == iSize);
445  ASSERT(out.iGetSize() == iSize);
446 
447  for (integer ic = 0; ic < iSize; ic++) {
448  for (integer idx = 0; idx < piNzr[ic]; idx++) {
449  integer ir = ppiRows[ic][idx];
450  (out.*op)(ic + 1, ppdRows[ir][ic]*in(ir + 1));
451  }
452  }
453 
454  return out;
455 }
doublereal ** ppdRows
Definition: naivemh.h:60
integer * piNzr
Definition: naivemh.h:63
integer ** ppiRows
Definition: naivemh.h:61
virtual integer iGetSize(void) const =0
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58

Here is the call graph for this function:

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

Reimplemented from MatrixHandler.

Reimplemented in NaivePermMatrixHandler.

Definition at line 422 of file naivemh.cc.

References ASSERT, VectorHandler::iGetSize(), iSize, piNzc, ppdRows, and ppiCols.

425 {
426  ASSERT(in.iGetSize() == iSize);
427  ASSERT(out.iGetSize() == iSize);
428 
429  for (integer ir = 0; ir < iSize; ir++) {
430  for (integer idx = 0; idx < piNzc[ir]; idx++) {
431  integer ic = ppiCols[ir][idx];
432  (out.*op)(ir + 1, ppdRows[ir][ic]*in(ic + 1));
433  }
434  }
435 
436  return out;
437 }
doublereal ** ppdRows
Definition: naivemh.h:60
integer * piNzc
Definition: naivemh.h:63
virtual integer iGetSize(void) const =0
integer ** ppiCols
Definition: naivemh.h:61
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58

Here is the call graph for this function:

const doublereal & NaiveMatrixHandler::operator() ( integer  iRow,
integer  iCol 
) const
inlinevirtual

Implements MatrixHandler.

Reimplemented in NaivePermMatrixHandler.

Definition at line 173 of file naivemh.h.

References ASSERT, iGetNumCols(), iGetNumRows(), ppdRows, ppnonzero, and Zero1.

Referenced by NaivePermMatrixHandler::operator()(), operator+=(), and operator-=().

174 {
175  ASSERT(iRow > 0);
176  ASSERT(iRow <= iGetNumRows());
177  ASSERT(iCol > 0);
178  ASSERT(iCol <= iGetNumCols());
179 
180  --iRow;
181  --iCol;
182  if (ppnonzero[iRow][iCol]) {
183  return ppdRows[iRow][iCol];
184  }
186 }
integer iGetNumRows(void) const
Definition: naivemh.h:111
doublereal ** ppdRows
Definition: naivemh.h:60
integer iGetNumCols(void) const
Definition: naivemh.h:115
char ** ppnonzero
Definition: naivemh.h:62
const doublereal Zero1
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

doublereal & NaiveMatrixHandler::operator() ( integer  iRow,
integer  iCol 
)
inlinevirtual

Implements MatrixHandler.

Reimplemented in NaivePermMatrixHandler.

Definition at line 189 of file naivemh.h.

References ASSERT, iGetNumCols(), iGetNumRows(), piNzc, piNzr, ppdRows, ppiCols, ppiRows, and ppnonzero.

190 {
191  ASSERT(iRow > 0);
192  ASSERT(iRow <= iGetNumRows());
193  ASSERT(iCol > 0);
194  ASSERT(iCol <= iGetNumCols());
195 
196  --iRow;
197  --iCol;
198  if (!(ppnonzero[iRow][iCol])) {
199  ppnonzero[iRow][iCol] = 1;
200  ppiRows[iCol][piNzr[iCol]] = iRow;
201  ppiCols[iRow][piNzc[iRow]] = iCol;
202  piNzr[iCol]++;
203  piNzc[iRow]++;
204  ppdRows[iRow][iCol] = 0.;
205  }
206 
207  return ppdRows[iRow][iCol];
208 }
integer iGetNumRows(void) const
Definition: naivemh.h:111
doublereal ** ppdRows
Definition: naivemh.h:60
integer * piNzr
Definition: naivemh.h:63
integer iGetNumCols(void) const
Definition: naivemh.h:115
integer ** ppiRows
Definition: naivemh.h:61
integer * piNzc
Definition: naivemh.h:63
char ** ppnonzero
Definition: naivemh.h:62
integer ** ppiCols
Definition: naivemh.h:61
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

MatrixHandler & NaiveMatrixHandler::operator+= ( const SubMatrixHandler SubMH)
virtual

Reimplemented from MatrixHandler.

Definition at line 168 of file naivemh.cc.

References SubMatrixHandler::iGetColIndex(), MatrixHandler::iGetNumCols(), MatrixHandler::iGetNumRows(), SubMatrixHandler::iGetRowIndex(), and operator()().

169 {
170  integer nr = SubMH.iGetNumRows();
171  integer nc = SubMH.iGetNumCols();
172 
173  for (integer ir = 1; ir <= nr; ir++) {
174  integer iRow = SubMH.iGetRowIndex(ir);
175 
176  for (integer ic = 1; ic <= nc; ic++) {
177  doublereal d = SubMH(ir, ic);
178 
179 #ifdef CHECK_FOR_ZERO
180  if (d != 0.)
181 #endif /* CHECK_FOR_ZERO */
182  {
183  integer iCol = SubMH.iGetColIndex(ic);
184 
185  operator()(iRow, iCol) += d;
186  }
187  }
188  }
189 
190  return *this;
191 }
virtual integer iGetColIndex(integer) const =0
virtual integer iGetNumCols(void) const =0
virtual integer iGetRowIndex(integer) const =0
virtual const doublereal & operator()(integer iRow, integer iCol) const
Definition: naivemh.h:173
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

MatrixHandler & NaiveMatrixHandler::operator+= ( const VariableSubMatrixHandler SubMH)
virtual

Reimplemented from MatrixHandler.

Definition at line 224 of file naivemh.cc.

References VariableSubMatrixHandler::eStatus, VariableSubMatrixHandler::FULL, FullSubMatrixHandler::iGetNumCols(), FullSubMatrixHandler::iGetNumRows(), SparseSubMatrixHandler::iNumItems, operator()(), SparseSubMatrixHandler::pdMatm1, FullSubMatrixHandler::piColm1, SparseSubMatrixHandler::piColm1, FullSubMatrixHandler::piRowm1, SparseSubMatrixHandler::piRowm1, FullMatrixHandler::ppdCols, and VariableSubMatrixHandler::SPARSE.

225 {
226  switch (SubMH.eStatus) {
228  {
229  const FullSubMatrixHandler& SMH =
230  *dynamic_cast<const FullSubMatrixHandler *>(&SubMH);
231  /* NOTE: pirm1 is 1-based, for optimization purposes */
232  integer *pirm1 = SMH.piRowm1;
233  /* NOTE: pic is 0-based, for optimization purposes */
234  integer *pic = SMH.piColm1 + 1;
235 
236  /* NOTE: ppd is 1-based for rows; access to SMH(iRow, iCol)
237  * results in ppd[iCol - 1][iRow] */
238  doublereal **ppd = SMH.ppdCols;
239 
240  integer nr = SMH.iGetNumRows();
241  integer nc = SMH.iGetNumCols();
242  /* NOTE: iR is 1-based, for optimization purposes */
243  for (integer iR = 1; iR <= nr; iR++) {
244  integer iRow = pirm1[iR];
245 
246  /* NOTE: ic is 0-based, for optimization purposes */
247  for (integer ic = 0; ic < nc; ic++) {
248  doublereal d = ppd[ic][iR];
249 
250 #ifdef CHECK_FOR_ZERO
251  if (d != 0.)
252 #endif /* CHECK_FOR_ZERO */
253  {
254  integer iCol = pic[ic];
255 
256  operator()(iRow, iCol) += d;
257  }
258  }
259  }
260  break;
261  }
262 
264  {
265  const SparseSubMatrixHandler& SMH =
266  *dynamic_cast<const SparseSubMatrixHandler *>(&SubMH);
267 
268  for (integer i = 1; i <= SMH.iNumItems; i++) {
269  doublereal d = SMH.pdMatm1[i];
270 
271 #ifdef CHECK_FOR_ZERO
272  if (d != 0.)
273 #endif /* CHECK_FOR_ZERO */
274  {
275  integer iRow = SMH.piRowm1[i];
276  integer iCol = SMH.piColm1[i];
277 
278  operator()(iRow, iCol) += d;
279  }
280  }
281  break;
282  }
283 
284  default:
285  break;
286  }
287 
288  return *this;
289 }
integer * piRowm1
Definition: submat.h:189
integer iGetNumRows(void) const
Definition: submat.h:233
integer iGetNumCols(void) const
Definition: submat.h:240
integer * piRowm1
Definition: submat.h:768
integer * piColm1
Definition: submat.h:191
doublereal * pdMatm1
Definition: submat.h:772
enum VariableSubMatrixHandler::@13 eStatus
doublereal ** ppdCols
Definition: fullmh.h:71
virtual const doublereal & operator()(integer iRow, integer iCol) const
Definition: naivemh.h:173
integer * piColm1
Definition: submat.h:770
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

MatrixHandler & NaiveMatrixHandler::operator-= ( const SubMatrixHandler SubMH)
virtual

Reimplemented from MatrixHandler.

Definition at line 195 of file naivemh.cc.

References SubMatrixHandler::iGetColIndex(), MatrixHandler::iGetNumCols(), MatrixHandler::iGetNumRows(), SubMatrixHandler::iGetRowIndex(), and operator()().

196 {
197  integer nr = SubMH.iGetNumRows();
198  integer nc = SubMH.iGetNumCols();
199 
200  for (integer ir = 1; ir <= nr; ir++) {
201  integer iRow = SubMH.iGetRowIndex(ir);
202 
203  for (integer ic = 1; ic <= nc; ic++) {
204  doublereal d = SubMH(ir, ic);
205 
206 #ifdef CHECK_FOR_ZERO
207  if (d != 0.)
208 #endif /* CHECK_FOR_ZERO */
209  {
210  integer iCol = SubMH.iGetColIndex(ic);
211 
212  operator()(iRow, iCol) -= d;
213  }
214  }
215  }
216 
217  return *this;
218 }
virtual integer iGetColIndex(integer) const =0
virtual integer iGetNumCols(void) const =0
virtual integer iGetRowIndex(integer) const =0
virtual const doublereal & operator()(integer iRow, integer iCol) const
Definition: naivemh.h:173
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

MatrixHandler & NaiveMatrixHandler::operator-= ( const VariableSubMatrixHandler SubMH)
virtual

Reimplemented from MatrixHandler.

Definition at line 292 of file naivemh.cc.

References VariableSubMatrixHandler::eStatus, VariableSubMatrixHandler::FULL, FullSubMatrixHandler::iGetNumCols(), FullSubMatrixHandler::iGetNumRows(), SparseSubMatrixHandler::iNumItems, operator()(), SparseSubMatrixHandler::pdMatm1, FullSubMatrixHandler::piColm1, SparseSubMatrixHandler::piColm1, FullSubMatrixHandler::piRowm1, SparseSubMatrixHandler::piRowm1, FullMatrixHandler::ppdCols, and VariableSubMatrixHandler::SPARSE.

293 {
294  switch (SubMH.eStatus) {
296  {
297  const FullSubMatrixHandler& SMH =
298  *dynamic_cast<const FullSubMatrixHandler *>(&SubMH);
299  integer *pirm1 = SMH.piRowm1;
300  integer *pic = SMH.piColm1 + 1;
301  doublereal **ppd = SMH.ppdCols;
302 
303  integer nr = SMH.iGetNumRows();
304  integer nc = SMH.iGetNumCols();
305  for (integer iR = 1; iR <= nr; iR++) {
306  integer iRow = pirm1[iR];
307 
308  for (integer ic = 0; ic < nc; ic++) {
309  doublereal d = ppd[ic][iR];
310 
311 #ifdef CHECK_FOR_ZERO
312  if (d != 0.)
313 #endif /* CHECK_FOR_ZERO */
314  {
315  integer iCol = pic[ic];
316 
317  operator()(iRow, iCol) -= d;
318  }
319  }
320  }
321  break;
322  }
323 
325  {
326  const SparseSubMatrixHandler& SMH =
327  *dynamic_cast<const SparseSubMatrixHandler *>(&SubMH);
328 
329  for (integer i = 1; i <= SMH.iNumItems; i++) {
330  doublereal d = SMH.pdMatm1[i];
331 
332 #ifdef CHECK_FOR_ZERO
333  if (d != 0.)
334 #endif /* CHECK_FOR_ZERO */
335  {
336  integer iRow = SMH.piRowm1[i];
337  integer iCol = SMH.piColm1[i];
338 
339  operator()(iRow, iCol) -= d;
340  }
341  }
342  break;
343  }
344 
345  default:
346  break;
347  }
348 
349  return *this;
350 }
integer * piRowm1
Definition: submat.h:189
integer iGetNumRows(void) const
Definition: submat.h:233
integer iGetNumCols(void) const
Definition: submat.h:240
integer * piRowm1
Definition: submat.h:768
integer * piColm1
Definition: submat.h:191
doublereal * pdMatm1
Definition: submat.h:772
enum VariableSubMatrixHandler::@13 eStatus
doublereal ** ppdCols
Definition: fullmh.h:71
virtual const doublereal & operator()(integer iRow, integer iCol) const
Definition: naivemh.h:173
integer * piColm1
Definition: submat.h:770
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void NaiveMatrixHandler::Reset ( void  )
virtual

Implements MatrixHandler.

Definition at line 151 of file naivemh.cc.

References iSize, piNzc, piNzr, ppiCols, and ppnonzero.

Referenced by StepNIntegrator::Jacobian(), and main().

152 {
153  for (integer row = 0; row < iSize; row++) {
154  integer ncols = piNzc[row];
155  integer *piCols = ppiCols[row];
156  char *pnonzero = ppnonzero[row];
157  for (integer col = 0; col < ncols; col++) {
158  pnonzero[piCols[col]] = 0;
159  }
160 
161  piNzr[row] = 0;
162  piNzc[row] = 0;
163  }
164 }
integer * piNzr
Definition: naivemh.h:63
integer * piNzc
Definition: naivemh.h:63
char ** ppnonzero
Definition: naivemh.h:62
integer ** ppiCols
Definition: naivemh.h:61
long int integer
Definition: colamd.c:51
integer iSize
Definition: naivemh.h:58
virtual void NaiveMatrixHandler::Resize ( integer  ,
integer   
)
inlinevirtual

Implements MatrixHandler.

Definition at line 122 of file naivemh.h.

References MBDYN_EXCEPT_ARGS.

122  {
124  };
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63

Friends And Related Function Documentation

friend class MultiThreadDataManager
friend

Definition at line 51 of file naivemh.h.

friend class NaiveSolver
friend

Definition at line 49 of file naivemh.h.

Referenced by NaiveSparseSolutionManager::NaiveSparseSolutionManager().

friend class ParNaiveSolver
friend

Definition at line 50 of file naivemh.h.

void* sum_naive_matrices ( void *  arg)
friend

Member Data Documentation

bool NaiveMatrixHandler::bOwnsMemory
protected

Definition at line 59 of file naivemh.h.

Referenced by NaiveMatrixHandler(), and ~NaiveMatrixHandler().

const_iterator NaiveMatrixHandler::m_end
protected

Definition at line 94 of file naivemh.h.

Referenced by end().

char** NaiveMatrixHandler::ppnonzero
protected

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