16 numRows(nRows), numCols(nCols), theVec(nRows * nCols) {
20 numRows(aMatrix.numRows), numCols(aMatrix.numCols), theVec(
36 theVec.resize(nRows * nCols);
45 for (
unsigned int i = 0; i <
numRows; ++i) {
46 for (
unsigned int j = 0; j <
numCols; ++j) {
71 std::cout <<
" VMatrix: " <<
numRows <<
"*" <<
numCols << std::endl;
72 for (
unsigned int i = 0; i <
numRows; ++i) {
73 for (
unsigned int j = 0; j <
numCols; ++j) {
75 std::cout << std::endl << std::setw(4) << i <<
","
76 << std::setw(4) << j <<
"-" << std::setw(4)
77 << std::min(j + 4,
numCols) <<
":";
82 std::cout << std::endl << std::endl;
88 for (
unsigned int i = 0; i < this->
numRows; ++i) {
90 for (
unsigned int j = 0; j < this->
numCols; ++j) {
102 for (
unsigned int i = 0; i <
numRows; ++i) {
103 for (
unsigned int j = 0; j < aMatrix.
numCols; ++j) {
105 for (
unsigned int k = 0; k <
numCols; ++k) {
117 for (
unsigned int i = 0; i <
numRows; ++i) {
118 for (
unsigned int j = 0; j <
numCols; ++j) {
127 if (
this != &aMatrix) {
131 for (
unsigned int i = 0; i <
numRows; ++i) {
132 for (
unsigned int j = 0; j <
numCols; ++j) {
143 numRows(nRows), theVec((nRows * nRows + nRows) / 2) {
155 theVec.resize((nRows * nRows + nRows) / 2);
168 std::cout <<
" VSymMatrix: " <<
numRows <<
"*" <<
numRows << std::endl;
169 for (
unsigned int i = 0; i <
numRows; ++i) {
170 for (
unsigned int j = 0; j <= i; ++j) {
172 std::cout << std::endl << std::setw(4) << i <<
","
173 << std::setw(4) << j <<
"-" << std::setw(4)
174 << std::min(j + 4, i) <<
":";
176 std::cout << std::setw(13) <<
theVec[(i * i + i) / 2 + j];
179 std::cout << std::endl << std::endl;
185 for (
unsigned int i = 0; i <
numRows; ++i) {
186 for (
unsigned int j = 0; j <= i; ++j) {
187 aResult(i, j) =
theVec[(i * i + i) / 2 + j] - aMatrix(i, j);
196 for (
unsigned int i = 0; i <
numRows; ++i) {
197 aResult(i) =
theVec[(i * i + i) / 2 + i] * aVector(i);
198 for (
unsigned int j = 0; j < i; ++j) {
199 aResult(j) +=
theVec[(i * i + i) / 2 + j] * aVector(i);
200 aResult(i) +=
theVec[(i * i + i) / 2 + j] * aVector(j);
210 for (
unsigned int l = 0; l < nCol; ++l) {
211 for (
unsigned int i = 0; i <
numRows; ++i) {
212 aResult(i, l) =
theVec[(i * i + i) / 2 + i] * aMatrix(i, l);
213 for (
unsigned int j = 0; j < i; ++j) {
214 aResult(j, l) +=
theVec[(i * i + i) / 2 + j] * aMatrix(i, l);
215 aResult(i, l) +=
theVec[(i * i + i) / 2 + j] * aMatrix(j, l);
225 numRows(nRows), theVec(nRows) {
229 numRows(aVector.numRows), theVec(aVector.theVec) {
253 std::memcpy(&aResult.
theVec[0], &
theVec[start],
sizeof(
double) * len);
264 sizeof(
double) * aVector.
numRows);
277 std::cout <<
" VVector: " <<
numRows << std::endl;
278 for (
unsigned int i = 0; i <
numRows; ++i) {
281 std::cout << std::endl << std::setw(4) << i <<
"-" << std::setw(4)
282 << std::min(i + 4,
numRows) <<
":";
284 std::cout << std::setw(13) <<
theVec[i];
286 std::cout << std::endl << std::endl;
292 for (
unsigned int i = 0; i <
numRows; ++i) {
293 aResult(i) =
theVec[i] - aVector(i);
300 if (
this != &aVector) {
303 for (
unsigned int i = 0; i <
numRows; ++i) {
328 const double eps = 1.0E-10;
330 std::vector<int> next(aSize);
331 std::vector<double> diag(aSize);
335 for (
int i = 1; i <= nSize; ++i) {
337 diag[i - 1] = fabs(
theVec[(i * i + i) / 2 - 1]);
339 next[aSize - 1] = -1;
341 unsigned int nrank = 0;
342 for (
int i = 1; i <= nSize; ++i) {
346 int jCandidate = first;
350 while (jCandidate > 0) {
351 int jj = (jCandidate * jCandidate + jCandidate) / 2 - 1;
352 if (fabs(
theVec[jj]) > std::max(fabs(vkk), eps * diag[jCandidate - 1])) {
357 previous = jCandidate;
358 jCandidate = next[jCandidate - 1];
362 int kk = (k * k + k) / 2 - 1;
366 next[last - 1] = next[k - 1];
375 for (
int j = 1; j <= nSize; ++j) {
390 for (
int l = 1; l <= k - 1; ++l) {
397 for (
int l = k + 1; l <= j; ++l) {
403 for (
int l = 1; l <= j; ++l) {
412 for (
int n = 1; n <= nSize; ++n) {
413 if (next[n - 1] >= 0) {
414 int nn = (n * n - n) / 2 - 1;
415 for (
int j = 1; j <= nSize; ++j) {
416 if (next[j - 1] >= 0) {
425 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.
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.
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 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.