Simple Matrix based on std::vector<double>
More...
#include <VMatrix.h>
|
unsigned int | numRows |
| Number of rows.
|
|
unsigned int | numCols |
| Number of columns.
|
|
std::vector< double > | theVec |
| Data.
|
|
Simple Matrix based on std::vector<double>
Definition at line 42 of file VMatrix.h.
◆ VMatrix() [1/2]
gbl::VMatrix::VMatrix |
( |
const unsigned int |
nRows = 0 , |
|
|
const unsigned int |
nCols = 0 |
|
) |
| |
Definition at line 15 of file VMatrix.cc.
15 :
17}
unsigned int numRows
Number of rows.
unsigned int numCols
Number of columns.
std::vector< double > theVec
Data.
◆ VMatrix() [2/2]
gbl::VMatrix::VMatrix |
( |
const VMatrix & |
aMatrix | ) |
|
Definition at line 19 of file VMatrix.cc.
19 :
21 aMatrix.theVec) {
22
23}
◆ ~VMatrix()
gbl::VMatrix::~VMatrix |
( |
| ) |
|
|
virtual |
◆ getNumCols()
unsigned int gbl::VMatrix::getNumCols |
( |
| ) |
const |
Get number of columns.
- Returns
- Number of columns.
Definition at line 65 of file VMatrix.cc.
◆ getNumRows()
unsigned int gbl::VMatrix::getNumRows |
( |
| ) |
const |
Get number of rows.
- Returns
- Number of rows.
Definition at line 57 of file VMatrix.cc.
◆ operator()() [1/2]
double & gbl::VMatrix::operator() |
( |
unsigned int |
i, |
|
|
unsigned int |
j |
|
) |
| |
|
inline |
access element (i,j)
Definition at line 84 of file VMatrix.h.
◆ operator()() [2/2]
double gbl::VMatrix::operator() |
( |
unsigned int |
i, |
|
|
unsigned int |
j |
|
) |
| const |
|
inline |
access element (i,j)
Definition at line 89 of file VMatrix.h.
◆ operator*() [1/2]
Multiplication Matrix*Matrix.
Definition at line 99 of file VMatrix.cc.
99 {
100
102 for (
unsigned int i = 0;
i <
numRows; ++
i) {
103 for (
unsigned int j = 0;
j < aMatrix.numCols; ++
j) {
104 double sum = 0.0;
105 for (
unsigned int k = 0;
k <
numCols; ++
k) {
107 }
108 aResult(i, j) = sum;
109 }
110 }
111 return aResult;
112}
VMatrix(const unsigned int nRows=0, const unsigned int nCols=0)
◆ operator*() [2/2]
Multiplication Matrix*Vector.
Definition at line 86 of file VMatrix.cc.
86 {
88 for (
unsigned int i = 0;
i < this->
numRows; ++
i) {
89 double sum = 0.0;
90 for (
unsigned int j = 0;
j < this->
numCols; ++
j) {
92 }
93 aResult(i) = sum;
94 }
95 return aResult;
96}
◆ operator+()
Addition Matrix+Matrix.
Definition at line 115 of file VMatrix.cc.
115 {
117 for (
unsigned int i = 0;
i <
numRows; ++
i) {
118 for (
unsigned int j = 0;
j <
numCols; ++
j) {
120 }
121 }
122 return aResult;
123}
◆ operator=()
Assignment Matrix=Matrix.
Definition at line 126 of file VMatrix.cc.
126 {
127 if (this != &aMatrix) {
128 numRows = aMatrix.getNumRows();
129 numCols = aMatrix.getNumCols();
131 for (
unsigned int i = 0;
i <
numRows; ++
i) {
132 for (
unsigned int j = 0;
j <
numCols; ++
j) {
134 }
135 }
136 }
137 return *this;
138}
◆ print()
void gbl::VMatrix::print |
( |
| ) |
const |
Print matrix.
Definition at line 70 of file VMatrix.cc.
70 {
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) {
74 if (j % 5 == 0) {
75 std::cout << std::endl << std::setw(4) <<
i <<
","
76 << std::setw(4) <<
j <<
"-" << std::setw(4)
77 << std::min(j + 4,
numCols) <<
":";
78 }
80 }
81 }
82 std::cout << std::endl << std::endl;
83}
◆ resize()
void gbl::VMatrix::resize |
( |
const unsigned int |
nRows, |
|
|
const unsigned int |
nCols |
|
) |
| |
Resize Matrix.
- Parameters
-
[in] | nRows | Number of rows. |
[in] | nCols | Number of columns. |
Definition at line 33 of file VMatrix.cc.
33 {
36 theVec.resize(nRows * nCols);
37}
◆ transpose()
VMatrix gbl::VMatrix::transpose |
( |
| ) |
const |
Get transposed matrix.
- Returns
- Transposed matrix.
Definition at line 43 of file VMatrix.cc.
43 {
45 for (
unsigned int i = 0;
i <
numRows; ++
i) {
46 for (
unsigned int j = 0;
j <
numCols; ++
j) {
48 }
49 }
50 return aResult;
51}
◆ numCols
unsigned int gbl::VMatrix::numCols |
|
private |
Number of columns.
Definition at line 60 of file VMatrix.h.
◆ numRows
unsigned int gbl::VMatrix::numRows |
|
private |
Number of rows.
Definition at line 59 of file VMatrix.h.
◆ theVec
std::vector<double> gbl::VMatrix::theVec |
|
private |
The documentation for this class was generated from the following files: