CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CppNoddy::BandedLinearSystem< _Type > Class Template Reference

A linear system class for vector right-hand sides. More...

#include <BandedLinearSystem.h>

Public Member Functions

 BandedLinearSystem (BandedMatrix< _Type > *Aptr, DenseVector< _Type > *Bptr, std::string which="native")
 Constructor for a banded linear system object. More...
 
 ~BandedLinearSystem ()
 Destructor for a linear system object. More...
 
void solve ()
 Solve the banded system. More...
 
void re_solve_lapack ()
 Resolve the banded system. More...
 
int get_det_sign () const
 Get the sign of the determinant of the LHS matrix from the linear system just computed. More...
 
void set_monitor_det (bool flag)
 Store the sign of the determinant of the LHS matrix every time a solve is requested on a real system. More...
 
void re_solve_lapack ()
 

Detailed Description

template<typename _Type>
class CppNoddy::BandedLinearSystem< _Type >

A linear system class for vector right-hand sides.

The class is constructed for dense typed problems of the form

\[ A_{NxN} \,{\underline x}_i = B_{1xN} \]

.

Definition at line 15 of file BandedLinearSystem.h.

Constructor & Destructor Documentation

◆ BandedLinearSystem()

template<typename _Type >
CppNoddy::BandedLinearSystem< _Type >::BandedLinearSystem ( BandedMatrix< _Type > *  Aptr,
DenseVector< _Type > *  Bptr,
std::string  which = "native" 
)

Constructor for a banded linear system object.

Parameters
AptrA pointer to the 'A matrix', an NxN double/complex banded matrix
BptrA pointer to the 'B vector' a size N double/complex dense vector
whichA string that indicates which solver to use

Definition at line 18 of file BandedLinearSystem.cpp.

19 :
20 m_detSign(0), m_monitorDet(false) {
21 m_pA = Aptr;
22 m_pB = Bptr;
23 m_version = which;
24 if((m_version != "lapack") && (m_version != "native")) {
25 std::string problem;
26 problem = "The BandedLinearSystem has been instantiated with an unrecognised\n";
27 problem += "request for a solver type. Options are 'native' or 'lapack'. \n";
28 throw ExceptionRuntime(problem);
29 }
30 }

◆ ~BandedLinearSystem()

template<typename _Type >
CppNoddy::BandedLinearSystem< _Type >::~BandedLinearSystem ( )
inline

Destructor for a linear system object.

Definition at line 26 of file BandedLinearSystem.h.

27 {}

Member Function Documentation

◆ get_det_sign()

template<typename _Type >
int CppNoddy::BandedLinearSystem< _Type >::get_det_sign

Get the sign of the determinant of the LHS matrix from the linear system just computed.

Returns
The sign of the determinant of the LAST solved system.

Definition at line 239 of file BandedLinearSystem.cpp.

239 {
240 return m_detSign;
241 }

Referenced by CppNoddy::ODE_BVP< _Type, _Xtype >::arclength_solve().

◆ re_solve_lapack() [1/2]

template<typename _Type >
void CppNoddy::BandedLinearSystem< _Type >::re_solve_lapack ( )

Resolve the banded system.

◆ re_solve_lapack() [2/2]

void CppNoddy::BandedLinearSystem< double >::re_solve_lapack ( )

Definition at line 89 of file BandedLinearSystem.cpp.

89 {
90#ifndef LAPACK
91 std::string problem = "The BandedLinearSystem<double>::re_solve_lapack method has been called\n";
92 problem += "but the compiler option -DLAPACK was not provided when\n";
93 problem += "the library was built and so LAPACK support is not available.";
94 throw ExceptionExternal(problem);
95#else
96 const std::size_t N = m_pA -> nrows();
97 const std::size_t K = 1;
98 const std::size_t L = m_pA -> noffdiag();
99 const std::size_t LDAB = 3 * L + 1;
100 // warning info
101 int info(0);
102 // LAPACK_DGBSV( N, L, L, K, m_pA -> base(), LDAB, &pivots[ 0 ], &( m_pB -> operator[] ( 0 ) ), N, info );
103 LAPACK_DGBTRS((char*) "N", N, L, L, K, m_pA -> base(), LDAB, &m_pivots[ 0 ], &(m_pB -> operator[](0)), N, info);
104 if(0 != info) {
105 std::string problem(" The BandedLinearSystem::re_solve_lapack method has detected a failure. \n");
106 throw ExceptionExternal(problem, info);
107 }
108#endif
109 }
double K(4.0)
bulk modulus

◆ set_monitor_det()

template<typename _Type >
void CppNoddy::BandedLinearSystem< _Type >::set_monitor_det ( bool  flag)

Store the sign of the determinant of the LHS matrix every time a solve is requested on a real system.

Parameters
flagThe boolean value to set.

Definition at line 244 of file BandedLinearSystem.cpp.

244 {
245 m_monitorDet = flag;
246 }

Referenced by CppNoddy::ODE_BVP< _Type, _Xtype >::arclength_solve().

◆ solve()

template<typename _Type >
void CppNoddy::BandedLinearSystem< _Type >::solve

Solve the banded system.

Definition at line 34 of file BandedLinearSystem.cpp.

34 {
35 if("lapack" == m_version) {
36 solve_lapack();
37 } else { // we catch incorrect m_version choices in the ctor
38 solve_native();
39 }
40 }

Referenced by CppNoddy::ODE_BVP< _Type, _Xtype >::arclength_solve(), CppNoddy::reversed_BL< _Type >::bidirectional_step2(), main(), CppNoddy::PDE_double_IBVP< _Type >::step2(), CppNoddy::PDE_IBVP< _Type >::step2(), and CppNoddy::reversed_BL< _Type >::step2().


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

© 2012

R.E. Hewitt