MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
LapackMatrixScale< T > Class Template Reference

#include <dgeequ.h>

Inheritance diagram for LapackMatrixScale< T >:
Collaboration diagram for LapackMatrixScale< T >:

Public Member Functions

 LapackMatrixScale (const SolutionManager::ScaleOpt &scale)
 
virtual ~LapackMatrixScale ()
 
- Public Member Functions inherited from MatrixScale< T >
 MatrixScale (const SolutionManager::ScaleOpt &scale)
 
virtual ~MatrixScale ()
 
T & ScaleMatrix (T &mh) const
 
bool ComputeScaleFactors (const T &mh)
 
- Public Member Functions inherited from MatrixScaleBase
 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

virtual bool ComputeScaleFactors (const T &mh, std::vector< doublereal > &rowScale, std::vector< doublereal > &colScale)
 
virtual std::ostream & vReport (std::ostream &os) const
 
- Protected Member Functions inherited from MatrixScaleBase
MatrixHandler::Norm_t GetCondNumNorm () const
 
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
 

Private Attributes

doublereal SMLNUM
 
doublereal BIGNUM
 
doublereal rowcnd
 
doublereal colcnd
 
doublereal amax
 

Additional Inherited Members

- Static Public Member Functions inherited from MatrixScale< T >
static MatrixScale< T > * Allocate (const SolutionManager::ScaleOpt &scale)
 
- Protected Attributes inherited from MatrixScaleBase
std::vector< doublerealrowScale
 
std::vector< doublerealcolScale
 
doublereal dCondBefore
 
doublereal dCondAfter
 
const unsigned uFlags
 
bool bOK
 

Detailed Description

template<typename T>
class LapackMatrixScale< T >

Definition at line 156 of file dgeequ.h.

Constructor & Destructor Documentation

template<typename T >
LapackMatrixScale< T >::LapackMatrixScale ( const SolutionManager::ScaleOpt scale)
inline

Definition at line 548 of file dgeequ.h.

References LapackMatrixScale< T >::amax, LapackMatrixScale< T >::BIGNUM, LapackMatrixScale< T >::colcnd, LapackMatrixScale< T >::rowcnd, and LapackMatrixScale< T >::SMLNUM.

549  :MatrixScale<T>(scale)
550 {
551 #if defined(HAVE_DLAMCH) || defined(HAVE_DLAMCH_)
552  // Use dlamch according to Netlib's dgeequ.f
553  SMLNUM = __FC_DECL__(dlamch)("S");
554 #else
555  // According to Netlib's dlamch for x86-64 machines
556  SMLNUM = std::numeric_limits<doublereal>::min();
557 #endif
558  BIGNUM = 1./SMLNUM;
559 
560  rowcnd = colcnd = amax = -1;
561 }
doublereal amax
Definition: dgeequ.h:168
doublereal rowcnd
Definition: dgeequ.h:168
doublereal SMLNUM
Definition: dgeequ.h:167
doublereal colcnd
Definition: dgeequ.h:168
doublereal BIGNUM
Definition: dgeequ.h:167
template<typename T >
LapackMatrixScale< T >::~LapackMatrixScale ( )
virtual

Definition at line 564 of file dgeequ.h.

565 {
566 
567 }

Member Function Documentation

template<typename T >
bool LapackMatrixScale< T >::ComputeScaleFactors ( const T &  mh,
std::vector< doublereal > &  rowScale,
std::vector< doublereal > &  colScale 
)
protectedvirtual

Implements MatrixScale< T >.

Definition at line 570 of file dgeequ.h.

References MBDYN_EXCEPT_ARGS, and MatrixScaleBase::Prepare().

571 {
572  integer nrows, ncols;
573  MatrixScale<T>::Prepare(mh, nrows, ncols);
574 
575  doublereal rcmin;
576  doublereal rcmax;
577 
578  for (typename T::const_iterator i = mh.begin(); i != mh.end(); ++i) {
579  doublereal d = std::abs(i->dCoef);
580  if (d > rowScale[i->iRow]) {
581  rowScale[i->iRow] = d;
582  }
583  }
584 
585  rcmin = BIGNUM;
586  rcmax = 0.;
587  for (std::vector<doublereal>::iterator i = rowScale.begin(); i != rowScale.end(); ++i) {
588  if (*i > rcmax) {
589  rcmax = *i;
590  }
591  if (*i < rcmin) {
592  rcmin = *i;
593  }
594  }
595 
596  amax = rcmax;
597 
598  if (rcmin == 0.) {
600  "null min row value in dgeequ");
601  }
602 
603  for (std::vector<doublereal>::iterator i = rowScale.begin(); i != rowScale.end(); ++i) {
604  *i = 1./(std::min(std::max(*i, SMLNUM), BIGNUM));
605  }
606 
607  rowcnd = std::max(rcmin, SMLNUM)/std::min(rcmax, BIGNUM);
608 
609  for (typename T::const_iterator i = mh.begin(); i != mh.end(); ++i) {
610  doublereal d = std::abs(i->dCoef)*rowScale[i->iRow];
611  if (d > colScale[i->iCol]) {
612  colScale[i->iCol] = d;
613  }
614  }
615 
616  rcmin = BIGNUM;
617  rcmax = 0.;
618  for (std::vector<doublereal>::iterator i = colScale.begin(); i != colScale.end(); ++i) {
619  if (*i > rcmax) {
620  rcmax = *i;
621  }
622  if (*i < rcmin) {
623  rcmin = *i;
624  }
625  }
626 
627  if (rcmin == 0.) {
629  "null min column value in dgeequ");
630  }
631 
632  for (std::vector<doublereal>::iterator i = colScale.begin(); i != colScale.end(); ++i) {
633  *i = 1./(std::min(std::max(*i, SMLNUM), BIGNUM));
634  }
635 
636  colcnd = std::max(rcmin, SMLNUM)/std::min(rcmax, BIGNUM);
637 
638  return true;
639 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal amax
Definition: dgeequ.h:168
std::vector< doublereal > colScale
Definition: dgeequ.h:68
doublereal rowcnd
Definition: dgeequ.h:168
void Prepare(const MatrixHandler &mh, integer &nrows, integer &ncols)
Definition: dgeequ.h:254
std::vector< doublereal > rowScale
Definition: dgeequ.h:68
doublereal SMLNUM
Definition: dgeequ.h:167
doublereal colcnd
Definition: dgeequ.h:168
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal BIGNUM
Definition: dgeequ.h:167

Here is the call graph for this function:

template<typename T >
std::ostream & LapackMatrixScale< T >::vReport ( std::ostream &  os) const
protectedvirtual

Implements MatrixScaleBase.

Definition at line 642 of file dgeequ.h.

643 {
644  if (amax < std::numeric_limits<doublereal>::epsilon()
645  || amax > 1./std::numeric_limits<doublereal>::epsilon())
646  {
647  os << "Warning: The matrix should be scaled\n";
648  }
649 
650  if (colcnd >= 0.1) {
651  os << "Warning: it is not worth scaling the columns\n";
652  }
653 
654  if (rowcnd >= 0.1
655  && amax >= std::numeric_limits<doublereal>::epsilon()
656  && amax <= 1./std::numeric_limits<doublereal>::epsilon())
657  {
658  os << "Warning: it is not worth scaling the rows\n";
659  }
660 
661  return os;
662 }
doublereal amax
Definition: dgeequ.h:168
doublereal rowcnd
Definition: dgeequ.h:168
doublereal colcnd
Definition: dgeequ.h:168

Member Data Documentation

template<typename T >
doublereal LapackMatrixScale< T >::amax
private

Definition at line 168 of file dgeequ.h.

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

template<typename T >
doublereal LapackMatrixScale< T >::BIGNUM
private

Definition at line 167 of file dgeequ.h.

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

template<typename T >
doublereal LapackMatrixScale< T >::colcnd
private

Definition at line 168 of file dgeequ.h.

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

template<typename T >
doublereal LapackMatrixScale< T >::rowcnd
private

Definition at line 168 of file dgeequ.h.

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

template<typename T >
doublereal LapackMatrixScale< T >::SMLNUM
private

Definition at line 167 of file dgeequ.h.

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


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