38 numRows(nRows), numCols(nCols), theVec(nRows * nCols) {
42 numRows(aMatrix.numRows), numCols(aMatrix.numCols), theVec(
58 theVec.resize(nRows * nCols);
72 for (
unsigned int i = 0; i <
numRows; ++i) {
73 for (
unsigned int j = 0; j <
numCols; ++j) {
98 std::cout <<
" VMatrix: " <<
numRows <<
"*" <<
numCols << std::endl;
99 for (
unsigned int i = 0; i <
numRows; ++i) {
100 for (
unsigned int j = 0; j <
numCols; ++j) {
102 std::cout << std::endl << std::setw(4) << i <<
","
103 << std::setw(4) << j <<
"-" << std::setw(4)
104 << std::min(j + 4,
numCols) <<
":";
109 std::cout << std::endl << std::endl;
115 for (
unsigned int i = 0; i < this->
numRows; ++i) {
117 for (
unsigned int j = 0; j < this->
numCols; ++j) {
129 for (
unsigned int i = 0; i <
numRows; ++i) {
130 for (
unsigned int j = 0; j < aMatrix.
numCols; ++j) {
132 for (
unsigned int k = 0; k <
numCols; ++k) {
144 for (
unsigned int i = 0; i <
numRows; ++i) {
145 for (
unsigned int j = 0; j <
numCols; ++j) {
154 if (
this != &aMatrix) {
158 for (
unsigned int i = 0; i <
numRows; ++i) {
159 for (
unsigned int j = 0; j <
numCols; ++j) {
170 numRows(nRows), theVec((nRows * nRows + nRows) / 2) {
182 theVec.resize((nRows * nRows + nRows) / 2);
200 std::cout <<
" VSymMatrix: " <<
numRows <<
"*" <<
numRows << std::endl;
201 for (
unsigned int i = 0; i <
numRows; ++i) {
202 for (
unsigned int j = 0; j <= i; ++j) {
204 std::cout << std::endl << std::setw(4) << i <<
","
205 << std::setw(4) << j <<
"-" << std::setw(4)
206 << std::min(j + 4, i) <<
":";
208 std::cout << std::setw(13) <<
theVec[(i * i + i) / 2 + j];
211 std::cout << std::endl << std::endl;
217 for (
unsigned int i = 0; i <
numRows; ++i) {
218 for (
unsigned int j = 0; j <= i; ++j) {
219 aResult(i, j) =
theVec[(i * i + i) / 2 + j] - aMatrix(i, j);
228 for (
unsigned int i = 0; i <
numRows; ++i) {
229 aResult(i) =
theVec[(i * i + i) / 2 + i] * aVector(i);
230 for (
unsigned int j = 0; j < i; ++j) {
231 aResult(j) +=
theVec[(i * i + i) / 2 + j] * aVector(i);
232 aResult(i) +=
theVec[(i * i + i) / 2 + j] * aVector(j);
242 for (
unsigned int l = 0; l < nCol; ++l) {
243 for (
unsigned int i = 0; i <
numRows; ++i) {
244 aResult(i, l) =
theVec[(i * i + i) / 2 + i] * aMatrix(i, l);
245 for (
unsigned int j = 0; j < i; ++j) {
246 aResult(j, l) +=
theVec[(i * i + i) / 2 + j] * aMatrix(i, l);
247 aResult(i, l) +=
theVec[(i * i + i) / 2 + j] * aMatrix(j, l);
257 numRows(nRows), theVec(nRows) {
261 numRows(aVector.numRows), theVec(aVector.theVec) {
290 std::memcpy(&aResult.
theVec[0], &
theVec[start],
sizeof(
double) * len);
301 sizeof(
double) * aVector.
numRows);
314 std::cout <<
" VVector: " <<
numRows << std::endl;
315 for (
unsigned int i = 0; i <
numRows; ++i) {
318 std::cout << std::endl << std::setw(4) << i <<
"-" << std::setw(4)
319 << std::min(i + 4,
numRows) <<
":";
321 std::cout << std::setw(13) <<
theVec[i];
323 std::cout << std::endl << std::endl;
329 for (
unsigned int i = 0; i <
numRows; ++i) {
330 aResult(i) =
theVec[i] - aVector(i);
337 if (
this != &aVector) {
340 for (
unsigned int i = 0; i <
numRows; ++i) {
365 const double eps = 1.0E-10;
367 std::vector<int> next(aSize);
368 std::vector<double> diag(aSize);
372 for (
int i = 1; i <= nSize; ++i) {
374 diag[i - 1] = fabs(
theVec[(i * i + i) / 2 - 1]);
376 next[aSize - 1] = -1;
378 unsigned int nrank = 0;
379 for (
int i = 1; i <= nSize; ++i) {
388 int jj = (jp * jp + jp) / 2 - 1;
389 if (fabs(
theVec[jj]) > std::max(fabs(vkk), eps * diag[jp - 1])) {
399 int kk = (kp * kp + kp) / 2 - 1;
401 first = next[kp - 1];
403 next[last - 1] = next[kp - 1];
412 for (
int j = 1; j <= nSize; ++j) {
427 for (
int l = 1; l <= kp - 1; ++l) {
434 for (
int l = kp + 1; l <= j; ++l) {
440 for (
int l = 1; l <= j; ++l) {
449 for (
int k = 1; k <= nSize; ++k) {
450 if (next[k - 1] >= 0) {
451 int kk = (k * k - k) / 2 - 1;
452 for (
int j = 1; j <= nSize; ++j) {
453 if (next[j - 1] >= 0) {
462 for (
int ij = 0; ij < (nSize * nSize + nSize) / 2; ++ij) {
Simple Matrix based on std::vector<double>
unsigned int getNumCols() const
Get number of columns.
VMatrix transpose() const
Get transposed matrix.
VVector operator*(const VVector &aVector) const
Multiplication Matrix*Vector.
unsigned int numRows
Number of rows.
unsigned int getNumRows() const
Get number of rows.
void resize(const unsigned int nRows, const unsigned int nCols)
Resize Matrix.
VMatrix operator+(const VMatrix &aMatrix) const
Addition Matrix+Matrix.
unsigned int numCols
Number of columns.
VMatrix & operator=(const VMatrix &aMatrix)
Assignment Matrix=Matrix.
VMatrix(const unsigned int nRows=0, const unsigned int nCols=0)
std::vector< double > theVec
Data.
void print() const
Print matrix.
void setZero()
Set content to 0.
Simple symmetric Matrix based on std::vector<double>
VSymMatrix(const unsigned int nRows=0)
VVector operator*(const VVector &aVector) const
Multiplication SymMatrix*Vector.
void print() const
Print matrix.
unsigned int invert()
Matrix inversion.
unsigned int getNumRows() const
Get number of rows (= number of colums).
std::vector< double > theVec
Data (symmetric storage)
unsigned int numRows
Number of rows.
void resize(const unsigned int nRows)
Resize symmetric matrix.
VSymMatrix operator-(const VMatrix &aMatrix) const
Subtraction SymMatrix-(sym)Matrix.
void setZero()
Set content to 0.
Simple Vector based on std::vector<double>
void putVec(const VVector &aVector, unsigned int start=0)
Put part of vector.
std::vector< double > theVec
Data.
VVector getVec(unsigned int len, unsigned int start=0) const
Get part of vector.
VVector operator-(const VVector &aVector) const
Subtraction Vector-Vector.
void setZero()
Set content to 0.
void resize(const unsigned int nRows)
Resize vector.
VVector(const unsigned int nRows=0)
unsigned int numRows
Number of rows.
void print() const
Print vector.
VVector & operator=(const VVector &aVector)
Assignment Vector=Vector.
unsigned int getNumRows() const
Get number of rows.
Namespace for the general broken lines package.