28 elm =
new double[ nc * nr ];
34 elm =
new double[ nc * nr ];
41 elm =
new double[nc*nr];
42 memcpy(elm,x.
elm,nc*nr*
sizeof(
double));
51 elm =
new double[size];
57 elm =
new double[size];
58 memcpy(elm,x.
elm,size*
sizeof(
double));
66 for (
int i = 1; i <= M.
nr; i++) {
67 for (
int j = 1; j <= M.
nc; j++) {
68 stream << M.
Get(i, j) <<
" ";
76 for (
int i = 1; i <= V.
size; i++) {
77 stream << V.
elm[ i - 1 ] <<
"\n";
84 THROW( ExcAssertMsg() << EI_Message(
"Number of the row is greater than number of rows in the matrix.") );
86 THROW( ExcAssertMsg() << EI_Message(
"Number of the column is greater than number of columns in the matrix.") );
87 elm[ (row - 1) * nc + col - 1 ] = value;
93 THROW( ExcAssertMsg() << EI_Message(
"Number of the row is greater than number of rows in the matrix.") );
95 THROW( ExcAssertMsg() << EI_Message(
"Number of the column is greater than number of columns in the matrix.") );
96 return elm[ (row - 1) * nc + col - 1 ];
100 if (r1 > nr || r2 > nr) {
101 THROW( ExcAssertMsg() << EI_Message(
"Number of the row is greater than number of rows in the matrix.") );
104 for (
int i = 1; i <= nc; i++) {
105 double tmp = Get(r1, i);
106 Set(r1, i, Get(r2, i));
114 if (i1 > size || i2 > size) {
115 THROW( ExcAssertMsg() << EI_Message(
"Number of the element is greater than size of the vector.") );
118 double tmp = elm[ i1 - 1 ];
119 elm[ i1 - 1 ] = elm[ i2 - 1 ];
127 THROW( ExcAssertMsg() << EI_Message(
"Number of the element is greater than size of the vector.") );
136 THROW( ExcAssertMsg() << EI_Message(
"Number of the element is greater than size of the vector.") );
137 elm[ i - 1 ] = value;
153 for (
int i = 1; i < M.
NRows(); i++) {
154 double tmp = fabs(M.
Get(i, i));
156 for (
int j = i + 1; j <= M.
NRows(); j++)
157 if (fabs(M.
Get(j, i)) > tmp) {
158 tmp = fabs(M.
Get(j, i));
170 for (
int j = i + 1; j <= M.
NRows(); j++) {
171 tmp = M.
Get(j, i) / M.
Get(i, i);
172 for (
int k = i; k <= M.
NCols(); k++) {
173 M.
Set(j, k, M.
Get(j, k) - tmp * M.
Get(i, k));
179 for (
int i = M.
NRows(); i >= 1; i--) {
180 double tmp = b.
Get(i);
182 for (
int k = i + 1; k <= M.
NCols(); k++) {
183 tmp -= M.
Get(i, k) * X->
Get(k);
194 X->
Set(i, tmp / M.
Get(i, i));
TNSolutions Gauss(const TMatrix &A, TMVector *X, const TMVector &B)
double Get(int, int) const
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.