29 elm =
new double[ nc * nr ];
35 elm =
new double[ nc * nr ];
42 elm =
new double[nc*nr];
43 memcpy(elm,x.
elm,nc*nr*
sizeof(
double));
52 elm =
new double[size];
58 elm =
new double[size];
59 memcpy(elm,x.
elm,size*
sizeof(
double));
67 for (
int i = 1; i <= M.
nr; i++) {
68 for (
int j = 1; j <= M.
nc; j++) {
69 stream << M.
Get(i, j) <<
" ";
77 for (
int i = 1; i <= V.
size; i++) {
78 stream << V.
elm[ i - 1 ] <<
"\n";
85 THROW( ExcAssertMsg() << EI_Message(
"Number of the row is greater than number of rows in the matrix.") );
87 THROW( ExcAssertMsg() << EI_Message(
"Number of the column is greater than number of columns in the matrix.") );
88 elm[ (row - 1) * nc + col - 1 ] = value;
94 THROW( ExcAssertMsg() << EI_Message(
"Number of the row is greater than number of rows in the matrix.") );
96 THROW( ExcAssertMsg() << EI_Message(
"Number of the column is greater than number of columns in the matrix.") );
97 return elm[ (row - 1) * nc + col - 1 ];
101 if (r1 > nr || r2 > nr) {
102 THROW( ExcAssertMsg() << EI_Message(
"Number of the row is greater than number of rows in the matrix.") );
105 for (
int i = 1; i <= nc; i++) {
106 double tmp = Get(r1, i);
107 Set(r1, i, Get(r2, i));
115 if (i1 > size || i2 > size) {
116 THROW( ExcAssertMsg() << EI_Message(
"Number of the element is greater than size of the vector.") );
119 double tmp = elm[ i1 - 1 ];
120 elm[ i1 - 1 ] = elm[ i2 - 1 ];
128 THROW( ExcAssertMsg() << EI_Message(
"Number of the element is greater than size of the vector.") );
137 THROW( ExcAssertMsg() << EI_Message(
"Number of the element is greater than size of the vector.") );
138 elm[ i - 1 ] =
value;
154 for (
int i = 1; i < M.
NRows(); i++) {
155 double tmp = fabs(M.
Get(i, i));
157 for (
int j = i + 1; j <= M.
NRows(); j++)
158 if (fabs(M.
Get(j, i)) > tmp) {
159 tmp = fabs(M.
Get(j, i));
171 for (
int j = i + 1; j <= M.
NRows(); j++) {
172 tmp = M.
Get(j, i) / M.
Get(i, i);
173 for (
int k = i; k <= M.
NCols(); k++) {
174 M.
Set(j, k, M.
Get(j, k) - tmp * M.
Get(i, k));
180 for (
int i = M.
NRows(); i >= 1; i--) {
181 double tmp = b.
Get(i);
183 for (
int k = i + 1; k <= M.
NCols(); k++) {
184 tmp -= M.
Get(i, k) * X->
Get(k);
195 X->
Set(i, tmp / M.
Get(i, i));
TNSolutions Gauss(const TMatrix &A, TMVector *X, const TMVector &B)
double Get(int, int) const
static constexpr bool value
void SwapElements(int, int)
void Set(int, int, double)
std::ostream & operator<<(std::ostream &stream, const TMatrix &M)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.