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

#include <dgeequ.h>

Inheritance diagram for MatrixScaleBase:
Collaboration diagram for MatrixScaleBase:

Public Member Functions

 MatrixScaleBase (const SolutionManager::ScaleOpt &scale)
 
virtual ~MatrixScaleBase ()
 
VectorHandlerScaleRightHandSide (VectorHandler &bVH) const
 
VectorHandlerScaleSolution (VectorHandler &xVH) const
 
std::ostream & Report (std::ostream &os) const
 
const std::vector< doublereal > & GetRowScale () const
 
const std::vector< doublereal > & GetColScale () const
 
bool bGetInitialized () const
 

Protected Member Functions

MatrixHandler::Norm_t GetCondNumNorm () const
 
virtual std::ostream & vReport (std::ostream &os) const =0
 
void Prepare (const MatrixHandler &mh, integer &nrows, integer &ncols)
 
void PrepareRows (const MatrixHandler &mh, integer &nrows)
 
void PrepareCols (const MatrixHandler &mh, integer &ncols)
 
bool bReport () const
 

Protected Attributes

std::vector< doublerealrowScale
 
std::vector< doublerealcolScale
 
doublereal dCondBefore
 
doublereal dCondAfter
 
const unsigned uFlags
 
bool bOK
 

Static Private Member Functions

static VectorHandlerScaleVector (VectorHandler &v, const std::vector< doublereal > &s)
 

Detailed Description

Definition at line 49 of file dgeequ.h.

Constructor & Destructor Documentation

MatrixScaleBase::MatrixScaleBase ( const SolutionManager::ScaleOpt scale)
explicit

Definition at line 38 of file dgeequ.cc.

39 :dCondBefore(-1.),
40  dCondAfter(-1.),
41  uFlags(scale.uFlags),
42  bOK(true)
43 {
44 
45 }
doublereal dCondBefore
Definition: dgeequ.h:69
const unsigned uFlags
Definition: dgeequ.h:70
doublereal dCondAfter
Definition: dgeequ.h:69
MatrixScaleBase::~MatrixScaleBase ( )
virtual

Definition at line 47 of file dgeequ.cc.

48 {
49 
50 }

Member Function Documentation

bool MatrixScaleBase::bGetInitialized ( ) const
inline

Definition at line 59 of file dgeequ.h.

References colScale, and rowScale.

Referenced by NaiveSparseSolutionManager::ScaleMatrixAndRightHandSide().

59 { return !(rowScale.empty() && colScale.empty()); } // Allow row only or column only scaling
std::vector< doublereal > colScale
Definition: dgeequ.h:68
std::vector< doublereal > rowScale
Definition: dgeequ.h:68
bool MatrixScaleBase::bReport ( ) const
inlineprotected
const std::vector<doublereal>& MatrixScaleBase::GetColScale ( ) const
inline

Definition at line 58 of file dgeequ.h.

References colScale.

Referenced by ReportMatScale().

58 { return colScale; }
std::vector< doublereal > colScale
Definition: dgeequ.h:68
MatrixHandler::Norm_t MatrixScaleBase::GetCondNumNorm ( ) const
inlineprotected
const std::vector<doublereal>& MatrixScaleBase::GetRowScale ( ) const
inline

Definition at line 57 of file dgeequ.h.

References rowScale.

Referenced by ReportMatScale().

57 { return rowScale; }
std::vector< doublereal > rowScale
Definition: dgeequ.h:68
void MatrixScaleBase::Prepare ( const MatrixHandler mh,
integer nrows,
integer ncols 
)
inlineprotected

Definition at line 254 of file dgeequ.h.

References PrepareCols(), and PrepareRows().

Referenced by LapackMatrixScale< T >::ComputeScaleFactors().

255 {
256  PrepareRows(mh, nrows);
257  PrepareCols(mh, ncols);
258 }
void PrepareCols(const MatrixHandler &mh, integer &ncols)
Definition: dgeequ.cc:104
void PrepareRows(const MatrixHandler &mh, integer &nrows)
Definition: dgeequ.cc:82

Here is the call graph for this function:

void MatrixScaleBase::PrepareCols ( const MatrixHandler mh,
integer ncols 
)
protected

Definition at line 104 of file dgeequ.cc.

References colScale, MatrixHandler::iGetNumCols(), and MBDYN_EXCEPT_ARGS.

Referenced by ColSumMatrixScale< T >::ComputeScaleFactors(), ColMaxMatrixScale< T >::ComputeScaleFactors(), and Prepare().

105 {
106  ncols = mh.iGetNumCols();
107 
108  if (ncols <= 0) {
109  // error
111  "invalid null or negative column number");
112  }
113 
114  if (colScale.empty()) {
115  colScale.resize(ncols, 0.);
116  } else {
117  if (colScale.size() != unsigned(ncols)) {
118  // error
120  "column number mismatch");
121  }
122  colScale.assign(ncols, 0.);
123  }
124 }
virtual integer iGetNumCols(void) const =0
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
std::vector< doublereal > colScale
Definition: dgeequ.h:68

Here is the call graph for this function:

void MatrixScaleBase::PrepareRows ( const MatrixHandler mh,
integer nrows 
)
protected

Definition at line 82 of file dgeequ.cc.

References MatrixHandler::iGetNumRows(), MBDYN_EXCEPT_ARGS, and rowScale.

Referenced by RowSumMatrixScale< T >::ComputeScaleFactors(), RowMaxMatrixScale< T >::ComputeScaleFactors(), and Prepare().

83 {
84  nrows = mh.iGetNumRows();
85 
86  if (nrows <= 0) {
87  // error
89  "invalid null or negative row number");
90  }
91 
92  if (rowScale.empty()) {
93  rowScale.resize(nrows, 0.);
94  } else {
95  if (rowScale.size() != unsigned(nrows)) {
96  // error
98  "row number mismatch");
99  }
100  rowScale.assign(nrows, 0.);
101  }
102 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
std::vector< doublereal > rowScale
Definition: dgeequ.h:68
virtual integer iGetNumRows(void) const =0

Here is the call graph for this function:

std::ostream & MatrixScaleBase::Report ( std::ostream &  os) const

Definition at line 52 of file dgeequ.cc.

References bOK, dCondAfter, dCondBefore, SolutionManager::SCALEF_COND_NUM, SolutionManager::SCALEF_VERBOSE, SolutionManager::SCALEF_WARN, uFlags, and vReport().

Referenced by ReportMatScale(), and NaiveSparseSolutionManager::ScaleMatrixAndRightHandSide().

53 {
55  && dCondBefore > 0 && dCondAfter > 0) {
56  os << "cond: (" << dCondBefore << ") " << dCondAfter << std::endl;
57  }
58 
61  vReport(os);
62  }
63 
64  return os;
65 }
doublereal dCondBefore
Definition: dgeequ.h:69
const unsigned uFlags
Definition: dgeequ.h:70
doublereal dCondAfter
Definition: dgeequ.h:69
virtual std::ostream & vReport(std::ostream &os) const =0

Here is the call graph for this function:

VectorHandler & MatrixScaleBase::ScaleRightHandSide ( VectorHandler bVH) const
inline

Definition at line 216 of file dgeequ.h.

References rowScale, and ScaleVector().

Referenced by NaiveSparseSolutionManager::ScaleMatrixAndRightHandSide().

217 {
218  if (!rowScale.empty()) {
219  ScaleVector(bVH, rowScale);
220  }
221 
222  return bVH;
223 }
static VectorHandler & ScaleVector(VectorHandler &v, const std::vector< doublereal > &s)
Definition: dgeequ.cc:68
std::vector< doublereal > rowScale
Definition: dgeequ.h:68

Here is the call graph for this function:

VectorHandler & MatrixScaleBase::ScaleSolution ( VectorHandler xVH) const
inline

Definition at line 225 of file dgeequ.h.

References colScale, and ScaleVector().

Referenced by NaiveSparseSolutionManager::ScaleSolution().

226 {
227  if (!colScale.empty()) {
228  ScaleVector(xVH, colScale);
229  }
230 
231  return xVH;
232 }
std::vector< doublereal > colScale
Definition: dgeequ.h:68
static VectorHandler & ScaleVector(VectorHandler &v, const std::vector< doublereal > &s)
Definition: dgeequ.cc:68

Here is the call graph for this function:

VectorHandler & MatrixScaleBase::ScaleVector ( VectorHandler v,
const std::vector< doublereal > &  s 
)
staticprivate

Definition at line 68 of file dgeequ.cc.

References ASSERT, VectorHandler::iGetSize(), and MBDYN_EXCEPT_ARGS.

Referenced by ScaleRightHandSide(), and ScaleSolution().

69 {
70  if (static_cast<size_t>(v.iGetSize()) != s.size()) {
71  ASSERT(0);
73  }
74 
75  for (int i = 0; i < v.iGetSize(); ++i) {
76  v(i + 1) *= s[i];
77  }
78 
79  return v;
80 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer iGetSize(void) const =0
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

virtual std::ostream& MatrixScaleBase::vReport ( std::ostream &  os) const
protectedpure virtual

Member Data Documentation

bool MatrixScaleBase::bOK
protected
std::vector<doublereal> MatrixScaleBase::colScale
protected

Definition at line 68 of file dgeequ.h.

Referenced by bGetInitialized(), GetColScale(), PrepareCols(), and ScaleSolution().

doublereal MatrixScaleBase::dCondAfter
mutableprotected

Definition at line 69 of file dgeequ.h.

Referenced by Report().

doublereal MatrixScaleBase::dCondBefore
mutableprotected

Definition at line 69 of file dgeequ.h.

Referenced by Report().

std::vector<doublereal> MatrixScaleBase::rowScale
protected

Definition at line 68 of file dgeequ.h.

Referenced by bGetInitialized(), GetRowScale(), PrepareRows(), and ScaleRightHandSide().

const unsigned MatrixScaleBase::uFlags
protected

Definition at line 70 of file dgeequ.h.

Referenced by bReport(), GetCondNumNorm(), and Report().


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