35 std::vector<std::vector<T>> matrix;
38 matrix.assign(rows,std::vector<T>(cols,0));
41 if (
v.empty() ||
v[0].empty()) {
42 throw std::invalid_argument(
"Matrix is empty");
45 cols = matrix[0].size();
51 if (matrix.empty() || matrix[0].empty())
throw std::invalid_argument(
"Matrix is empty");
52 rows =
static_cast<int>(matrix.size());
53 cols =
static_cast<int>(matrix[0].size());
57 for (
const auto&
row : matrix)
58 if (
static_cast<int>(
row.size()) != cols)
59 throw std::invalid_argument(
"All rows must have the same size");
71 throw std::out_of_range(
"Matrix index out of range");
78 throw std::out_of_range(
"Matrix index out of range");
85 throw std::out_of_range(
"Row index out of range");
101 throw std::out_of_range(
"Row index out of range");
112 const std::vector<std::vector<T>>&
getMatrix()
const {
return matrix;}
113 std::vector<std::vector<T>>&
getMatrix() {
return matrix; }
116 template <
typename U>
129 for (
int i = 0;
i < rows; ++
i){
130 for (
int j = 0;
j < cols; ++
j){
150 for (
int i = 0;
i < cols;
i++){
151 for (
int j = 0;
j < rows;
j++){
152 auto &
Aij = (*this)(
i,
j);
171 for (
int i = 0;
i < rows;
i++){
173 for (
int j = 0;
j < cols;
j++){
174 auto &
Aij = matrix[
i][
j];
193 throw std::invalid_argument(
"num columns A not equal num rows B");
200 for (
int i = 0;
i < rows;
i +=
bs) {
201 for (
int k = 0;
k < this->cols;
k +=
bs) {
205 int k_end = std::min(
k +
bs, this->cols);
210 auto &
Aii = matrix[
ii];
std::ostream & operator<<(std::ostream &os, const LinearAlgebra::VectorMatrix< U > &M)
Definition VectorMatrix.hpp:126
Examples:
Definition VectorMatrix.hpp:32
std::vector< T > & operator[](int i)
Definition VectorMatrix.hpp:83
void validation()
Definition VectorMatrix.hpp:56
T & operator()(int i, int j)
Definition VectorMatrix.hpp:68
friend std::ostream & operator<<(std::ostream &os, const VectorMatrix< U > &M)
Definition VectorMatrix.hpp:126
VectorMatrix(const std::vector< std::vector< T > > &v)
Definition VectorMatrix.hpp:40
const std::vector< T > & operator[](int i) const
Return row of matrix.
Definition VectorMatrix.hpp:99
VectorMatrix< T > operator!() const
Transponse matrix.
Definition VectorMatrix.hpp:148
VectorMatrix< T > operator*(const VectorMatrix< T > &B) const
Matrix multiplication A*B where: A is matrix of VectorMatrix type B is matrix of VectorMatrix type.
Definition VectorMatrix.hpp:191
VectorMatrix(int rows, int cols)
Definition VectorMatrix.hpp:37
VectorMatrix()
Definition VectorMatrix.hpp:61
const std::vector< std::vector< T > > & getMatrix() const
Definition VectorMatrix.hpp:112
VectorMatrix(std::vector< std::vector< T > > &&v)
Definition VectorMatrix.hpp:49
int getColumns() const
return count columns
Definition VectorMatrix.hpp:110
std::vector< std::vector< T > > & getMatrix()
Definition VectorMatrix.hpp:113
int getRows() const
return count rows
Definition VectorMatrix.hpp:107
const T & operator()(int i, int j) const
Definition VectorMatrix.hpp:76
Definition DecomposeLU.hpp:9