Jpp
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
JMATH::JMatrixND::JMatrixHelper Struct Reference

Auxiliary class for matrix decomposition. More...

#include <JMatrixND.hh>

Inheritance diagram for JMATH::JMatrixND::JMatrixHelper:
JMATH::JMatrixND_t JLANG::JSingleton< T > std::vector< std::vector< double > >

Public Types

typedef std::vector< std::vector< double > > matrix_type
 
typedef matrix_type::const_iterator const_row_type
 
typedef std::vector< double >::const_iterator const_col_type
 
typedef matrix_type::iterator row_type
 
typedef std::vector< double >::iterator col_type
 
typedef T data_type
 

Public Member Functions

const JMatrixHelperset (const JMatrixND &A)
 Set matrix helper. More...
 
void decompose (const JMatrixND &A)
 LU decomposition. More...
 
int getSign () const
 Get sign corresponding to permutation matrix. More...
 

Static Public Member Functions

static data_typegetInstance ()
 Get unique instance of template class. More...
 

Private Attributes

int sign
 

Detailed Description

Auxiliary class for matrix decomposition.

Definition at line 547 of file JMatrixND.hh.

Member Typedef Documentation

◆ matrix_type

Definition at line 44 of file JMatrixND.hh.

◆ const_row_type

typedef matrix_type::const_iterator JMATH::JMatrixND_t::const_row_type
inherited

Definition at line 46 of file JMatrixND.hh.

◆ const_col_type

typedef std::vector<double>::const_iterator JMATH::JMatrixND_t::const_col_type
inherited

Definition at line 47 of file JMatrixND.hh.

◆ row_type

typedef matrix_type::iterator JMATH::JMatrixND_t::row_type
inherited

Definition at line 49 of file JMatrixND.hh.

◆ col_type

Definition at line 50 of file JMatrixND.hh.

◆ data_type

template<class T>
typedef T JLANG::JSingleton< T >::data_type
inherited

Definition at line 20 of file JSingleton.hh.

Member Function Documentation

◆ set()

const JMatrixHelper& JMATH::JMatrixND::JMatrixHelper::set ( const JMatrixND A)
inline

Set matrix helper.

Parameters
Amatrix
Returns
this matrix helper

Definition at line 557 of file JMatrixND.hh.

558  {
559  static_cast<JMatrixND_t&>(*this) = A;
560 
561  return *this;
562  }

◆ decompose()

void JMATH::JMatrixND::JMatrixHelper::decompose ( const JMatrixND A)
inline

LU decomposition.

Parameters
Amatrix

Definition at line 570 of file JMatrixND.hh.

571  {
572  set(A);
573 
574  sign = +1;
575 
576  size_t k;
577  double val, del;
578  row_type row, root;
579  col_type col, cursor;
580 
581  // LU decomposition
582 
583  for (root = this->begin(), k = 0; root != this->end(); ++root, ++k) {
584 
585  row_type pivot;
586 
587  val = (*root)[k];
588  pivot = root;
589 
590  for (row = root; ++row != this->end(); ) {
591  if (fabs((*row)[k]) > fabs(val)) {
592  val = (*row)[k];
593  pivot = row;
594  }
595  }
596 
597  if (val == 0) {
598  throw JDivisionByZero("LU decomposition zero pivot");
599  }
600 
601  if (pivot != root) {
602 
603  iter_swap(root, pivot);
604 
605  sign = -sign;
606  }
607 
608 
609  // decompose in LU
610 
611  for (row = root; ++row != this->end(); ) {
612 
613  del = (*row)[k] /= val;
614 
615  for (col = row->begin() + k, cursor = root->begin() + k; ++col != row->end(); )
616  (*col) -= del * (*(++cursor));
617  }
618  }
619  }

◆ getSign()

int JMATH::JMatrixND::JMatrixHelper::getSign ( ) const
inline

Get sign corresponding to permutation matrix.

Definition at line 625 of file JMatrixND.hh.

626  {
627  return sign;
628  }

◆ getInstance()

template<class T>
static data_type& JLANG::JSingleton< T >::getInstance ( )
inlinestaticinherited

Get unique instance of template class.

Returns
object

Definition at line 27 of file JSingleton.hh.

28  {
29  static data_type value;
30 
31  return value;
32  }

Member Data Documentation

◆ sign

int JMATH::JMatrixND::JMatrixHelper::sign
private

Definition at line 631 of file JMatrixND.hh.


The documentation for this struct was generated from the following file:
JMATH::JMatrixND_t::col_type
std::vector< double >::iterator col_type
Definition: JMatrixND.hh:50
JMATH::JMatrixND::JMatrixHelper::set
const JMatrixHelper & set(const JMatrixND &A)
Set matrix helper.
Definition: JMatrixND.hh:557
JLANG::JSingleton::data_type
T data_type
Definition: JSingleton.hh:20
JMATH::JMatrixND_t::row_type
matrix_type::iterator row_type
Definition: JMatrixND.hh:49
JMATH::JMatrixND::JMatrixHelper::sign
int sign
Definition: JMatrixND.hh:631