81 for (
int i = 0; i <
m_nRows; i++)
90 for (
int i = 0; i <
m_nRows; i++)
113 for (
int i = 0; i <
m_nRows; i++)
122 for (
int i = 0; i <
m_nRows; i++)
132 double constantElement;
140 for (j = 0; j < newColumns; j++)
151 for (j = 0; j < newColumns; j++)
164 printf(
"error: incompatible input in CMatd::operator+(const CMatd&)\n");
169 for (
int i = 0; i <
m_nRows; i++)
179 printf(
"error: incompatible input in CMatd::operator-(const CMatd&)\n");
184 for (
int i = 0; i <
m_nRows; i++)
196 for (
int i = 0; i <
m_nRows; i++)
209 for (
int i = 0; i <
m_nRows; i++)
229 for (
int i = 0; i <
m_nRows; i++)
241 for (
int i = 0; i <
m_nRows; i++)
252 printf(
"error: input matrix must be square matrix for CMatd::Invert\n");
260 CMatd copiedMatrix(*
this);
261 CMatd resultMatrix(n, n);
265 int *pPivotRows =
new int[
n];
266 for (i = 0; i <
n; i++)
270 for (i = 0; i <
n; i++)
272 int j, nPivotColumn = 0;
279 for (j = 0; j <
n; j++)
280 if (fabs(helper1[j]) > max)
282 max = fabs(helper1[j]);
286 pPivotRows[nPivotColumn] = i;
288 const double dPivotElement = copiedMatrix.
m_ppElements[i][nPivotColumn];
290 if (fabs(dPivotElement) < 0.00001)
292 printf(
"error: input matrix is not regular for CMatd::Invert\n");
293 delete [] pPivotRows;
298 const double dFactor = 1.0 / dPivotElement;
300 for (j = 0; j <
n; j++)
302 helper1[j] *= dFactor;
303 helper2[j] *= dFactor;
306 for (j = 0; j <
n; j++)
315 for (k = 0; k <
n; k++)
316 helper1[k] -= v * helper2[k];
317 helper1[nPivotColumn] = 0;
321 for (k = 0; k <
n; k++)
322 helper1[k] -= v * helper2[k];
328 double **ppTemp =
new double*[
n];
329 for (i = 0; i <
n; i++)
332 for (i = 0; i <
n; i++)
335 delete [] pPivotRows;
347 for (
int i = 0; i <
m_nRows; i++)
354 for (
int i = 0; i < nRows; i++)
358 for (
int j = 0; j < nColumns; j++)
371 for (
int i = 0; i <
m_nRows; i++)
CMatd operator+(const CMatd &m)
void operator*=(const double s)
Data structure and operations for calculating with vectors of arbitrary dimension.
CMatd operator*(const double s)
void SetSize(int nRows, int nColumns)
double & operator()(int nRow, int nColumn) const
CMatd operator-(const CMatd &m)
Data structure and operations for calculating with matrices of arbitrary dimension.
CMatd & operator=(const CMatd &v)