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

#include <spmh.h>

Inheritance diagram for CompactSparseMatrixHandler:
Collaboration diagram for CompactSparseMatrixHandler:

Public Member Functions

 CompactSparseMatrixHandler (const integer &n, const integer &nn, std::vector< doublereal > &x, const std::vector< integer > &i, const std::vector< integer > &p)
 
virtual ~CompactSparseMatrixHandler ()
 
virtual
CompactSparseMatrixHandler
Copy (void) const =0
 
void AddUnchecked (const CompactSparseMatrixHandler &m)
 
virtual const doublerealpdGetMat (void) const
 
void Reset (void)
 
virtual integer MakeCompressedColumnForm (doublereal *const Ax, integer *const Ai, integer *const Ap, int offset=0) const
 
virtual integer MakeCompressedColumnForm (std::vector< doublereal > &Ax, std::vector< integer > &Ai, std::vector< integer > &Ap, int offset=0) const
 
virtual integer MakeIndexForm (doublereal *const Ax, integer *const Arow, integer *const Acol, integer *const AcolSt, int offset=0) const
 
virtual integer MakeIndexForm (std::vector< doublereal > &Ax, std::vector< integer > &Arow, std::vector< integer > &Acol, std::vector< integer > &AcolSt, int offset=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
 
virtual VectorHandlerGetCol (integer icol, VectorHandler &out) const =0
 
- Public Member Functions inherited from MatrixHandler
virtual ~MatrixHandler (void)
 
virtual void Resize (integer, integer)=0
 
virtual void ResizeReset (integer, integer)
 
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 const doublerealoperator() (integer iRow, integer iCol) const =0
 
virtual doublerealoperator() (integer iRow, integer iCol)=0
 
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 Attributes

bool bMatDuplicate
 
std::vector< doublereal > & Ax
 
const std::vector< integer > & Ai
 
const std::vector< integer > & Ap
 
- Protected Attributes inherited from SparseMatrixHandler
integer NRows
 
integer NCols
 
integer NZ
 

Additional Inherited Members

- Public Types inherited from MatrixHandler
enum  Norm_t { NORM_1, NORM_INF }
 
- Protected Member Functions inherited from MatrixHandler
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
 

Detailed Description

Definition at line 149 of file spmh.h.

Constructor & Destructor Documentation

CompactSparseMatrixHandler::CompactSparseMatrixHandler ( const integer n,
const integer nn,
std::vector< doublereal > &  x,
const std::vector< integer > &  i,
const std::vector< integer > &  p 
)

Definition at line 49 of file spmh.cc.

References Ax, and SparseMatrixHandler::NZ.

54 : SparseMatrixHandler(n, nn),
55 bMatDuplicate(false),
56 Ax(x),
57 Ai(i),
58 Ap(p)
59 {
60  NZ = Ax.size();
61 }
const std::vector< integer > & Ap
Definition: spmh.h:154
SparseMatrixHandler(const integer &n, const integer &nn=0)
Definition: spmh.cc:38
const std::vector< integer > & Ai
Definition: spmh.h:153
std::vector< doublereal > & Ax
Definition: spmh.h:152
integer NZ
Definition: spmh.h:47
CompactSparseMatrixHandler::~CompactSparseMatrixHandler ( )
virtual

Definition at line 63 of file spmh.cc.

References Ax, and bMatDuplicate.

64 {
65  if (bMatDuplicate) {
66  delete &Ax;
67  }
68 }
std::vector< doublereal > & Ax
Definition: spmh.h:152

Member Function Documentation

void CompactSparseMatrixHandler::AddUnchecked ( const CompactSparseMatrixHandler m)

Definition at line 72 of file spmh.cc.

References Ai, Ap, ASSERT, Ax, and MBDYN_EXCEPT_ARGS.

73 {
74  /* FIXME: put in stl-ish form;
75  * see if we can use something from optimized blas,
76  * e.g. ATLAS, goto or so... */
77 
78  /* checks - uncomment to enable */
79 #ifdef DEBUG
80  ASSERT(Ax.size() == m.Ax.size());
81  ASSERT(Ai.size() == m.Ai.size());
82  ASSERT(Ap.size() == m.Ap.size());
83  for (std::vector<doublereal>::size_type i = 0; i < Ai.size(); i++) {
84  if (Ai[i] != m.Ai[i]) {
85  silent_cerr("AddUnchecked: Ai[" << i << "] differs" << std::endl);
87  }
88  }
89 
90  for (std::vector<doublereal>::size_type i = 0; i < Ap.size(); i++) {
91  if (Ap[i] != m.Ap[i]) {
92  silent_cerr("AddUnchecked: Ap[" << i << "] differs" << std::endl);
94  }
95  }
96 #endif /* DEBUG */
97 
98  doublereal *d = &Ax[0], *s = &m.Ax[0];
99  std::vector<doublereal>::size_type n = Ax.size();
100  for (std::vector<doublereal>::size_type i = 0; i < n; i++) {
101  d[i] += s[i];
102  }
103 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
const std::vector< integer > & Ap
Definition: spmh.h:154
const std::vector< integer > & Ai
Definition: spmh.h:153
std::vector< doublereal > & Ax
Definition: spmh.h:152
#define ASSERT(expression)
Definition: colamd.c:977
double doublereal
Definition: colamd.c:52
virtual CompactSparseMatrixHandler* CompactSparseMatrixHandler::Copy ( void  ) const
pure virtual
integer CompactSparseMatrixHandler::MakeCompressedColumnForm ( doublereal *const  Ax,
integer *const  Ai,
integer *const  Ap,
int  offset = 0 
) const
virtual

Implements SparseMatrixHandler.

Definition at line 112 of file spmh.cc.

References MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::Nz().

115 {
117  return Nz();
118 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
const integer Nz() const
Definition: spmh.h:104

Here is the call graph for this function:

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

Implements SparseMatrixHandler.

Definition at line 121 of file spmh.cc.

References MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::Nz().

124 {
126  return Nz();
127 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
const integer Nz() const
Definition: spmh.h:104

Here is the call graph for this function:

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

Implements SparseMatrixHandler.

Definition at line 130 of file spmh.cc.

References MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::Nz().

133 {
135  return Nz();
136 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
const integer Nz() const
Definition: spmh.h:104

Here is the call graph for this function:

integer CompactSparseMatrixHandler::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 139 of file spmh.cc.

References MBDYN_EXCEPT_ARGS, and SparseMatrixHandler::Nz().

142 {
144  return Nz();
145 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
const integer Nz() const
Definition: spmh.h:104

Here is the call graph for this function:

virtual const doublereal* CompactSparseMatrixHandler::pdGetMat ( void  ) const
inlinevirtual

Reimplemented from MatrixHandler.

Definition at line 178 of file spmh.h.

References Ax.

178  {
179  return &Ax[0];
180  };
std::vector< doublereal > & Ax
Definition: spmh.h:152
void CompactSparseMatrixHandler::Reset ( void  )
virtual

Implements MatrixHandler.

Definition at line 106 of file spmh.cc.

References Ax.

107 {
108  std::fill(Ax.begin(), Ax.end(), 0.);
109 }
std::vector< doublereal > & Ax
Definition: spmh.h:152

Member Data Documentation

const std::vector<integer>& CompactSparseMatrixHandler::Ai
protected

Definition at line 153 of file spmh.h.

Referenced by AddUnchecked().

const std::vector<integer>& CompactSparseMatrixHandler::Ap
protected

Definition at line 154 of file spmh.h.

Referenced by AddUnchecked().

std::vector<doublereal>& CompactSparseMatrixHandler::Ax
protected
bool CompactSparseMatrixHandler::bMatDuplicate
protected

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