CppNoddy  0.92
Loading...
Searching...
No Matches
DenseLinearSystem.h
Go to the documentation of this file.
1/// \file DenseLinearSystem.h
2/// Specification of the linear system class.
3
4#ifndef DENSELINEARSYSTEM_H
5#define DENSELINEARSYSTEM_H
6
7#include <DenseMatrix.h>
8#include <DenseVector.h>
9
10namespace CppNoddy {
11
12 /// A linear system class for vector right-hand sides.
13 /// The class is constructed for dense typed problems of the form
14 /// \f[ A_{NxN} \,{\underline x}_i = B_{1xN} \f].
15 template <typename _Type>
17
18 protected:
19
23
27
28 public:
29
30 /// Constructor for a dense linear system object.
31 /// \param m_pA A pointer to the 'A matrix', an nxn double/complex dense matrix
32 /// \param m_pB A pointer to the 'B vector' a size n double/complex dense vector
33 /// \param which A string that indicates which solver to use
34 DenseLinearSystem(DenseMatrix<_Type>* m_pA, DenseVector<_Type>* m_pB, std::string which = "native");
35
36 /// Destructor for a linear system object.
38 {}
39
40 /// Solve the sparse system
41 void solve();
42
43 /// Get the sign of the determinant of the LHS matrix
44 /// from the linear system just computed.
45 /// \return The sign of the determinant of the
46 /// LAST solved system.
47 int get_det_sign() const;
48
49 /// Store the sign of the determinant of the LHS matrix
50 /// every time a solve is requested on a real system.
51 /// \param flag The boolean value to set.
52 void set_monitor_det(bool flag);
53
54 private:
55
56 /// Solve the linear system using LAPACK's LU solver
57 void solve_lapack();
58
59 /// Solve the linear system using the native elimination
60 void solve_native();
61
62 /// A wrapped up less_than check that throws an exception
63 /// if the matrix elements are complex.
64 bool lt(_Type value) const;
65
66 /// Back substitution routine for dense systems.
67 void backsub() const;
68
69 /// Compute the signature of the permutation vector
70 /// This is used to get the sign of the det after the
71 /// LAPACK routine has been called.
72 /// \param pivots The pivot permutation vector
73 /// \return The sign of the permutation
74 int signature(const std::vector<int> &pivots) const;
75
76 /// A lower bound on pivot size for the native elimination routine
77 double m_minPivot;
78
79 /// pointers to the associated containers
82
83 /// a string ID to pick out the appropriate solver
84 std::string m_version;
85
86 /// the sign of the determinant of the last solved system LHS
87 int m_detSign;
88
89 /// a flag that determines of the determinant sign should be monitored
90 bool m_monitorDet;
91
92
93 };
94
95 template <>
96 inline bool DenseLinearSystem<double>::lt(double value) const {
97 return (value < 0);
98 }
99
100} //end namepsace
101#endif
A matrix class that constructs a DENSE matrix as an STL Vector of DenseVectors.
Specification for a templated DenseVector class – a dense, dynamic, vector object.
A linear system class for vector right-hand sides.
DenseMatrix< _Type >::elt_iter elt_iter
DenseMatrix< _Type >::elt_citer elt_citer
DenseMatrix< _Type >::elt_riter elt_riter
DenseMatrix< _Type >::row_riter row_riter
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.
~DenseLinearSystem()
Destructor for a linear system object.
int get_det_sign() const
Get the sign of the determinant of the LHS matrix from the linear system just computed.
DenseMatrix< _Type >::row_citer row_citer
void solve()
Solve the sparse system.
DenseMatrix< _Type >::row_iter row_iter
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
Definition: DenseMatrix.h:25
std::vector< DenseVector< _Type > >::reverse_iterator row_riter
Definition: DenseMatrix.h:31
DenseVector< _Type >::elt_iter elt_iter
Definition: DenseMatrix.h:33
std::vector< DenseVector< _Type > >::iterator row_iter
Typedef iterator types.
Definition: DenseMatrix.h:29
std::vector< DenseVector< _Type > >::const_iterator row_citer
Definition: DenseMatrix.h:30
DenseVector< _Type >::elt_riter elt_riter
Definition: DenseMatrix.h:35
DenseVector< _Type >::elt_citer elt_citer
Definition: DenseMatrix.h:34
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt