15 Matrix(
const MatNxNd a_Mat)
16 : m_Mat(a_Mat), m_Rows(a_Mat.size()), m_Cols(a_Mat[0].size()){}
18 Matrix(
const int a_Rows,
const int a_Cols)
19 : m_Rows(a_Rows), m_Cols(a_Cols)
21 initMatrix(m_Mat, m_Rows, m_Cols);
24 int getRows()
const {
return m_Rows; }
25 int getCols()
const {
return m_Cols; }
27 std::vector<double>& operator()(
int a_Row)
32 const std::vector<double>& operator()(
int a_Row)
const
37 double& operator()(
int a_Row,
int a_Col)
39 return m_Mat[a_Row][a_Col];
42 const double& operator()(
int a_Row,
int a_Col)
const
44 return m_Mat[a_Row][a_Col];
47 Matrix operator*(Matrix a_Input)
const
50 if(m_Cols!=a_Input.getRows())
52 std::cout <<
"Can't multiply two matrices!" << std::endl;
55 Matrix t_Output = Matrix(m_Rows, a_Input.getCols());
57 for(
int i=0; i < m_Rows; i++)
59 for(
int j=0; j < a_Input.getCols(); j++)
61 for (
int k=0; k < m_Cols; k++)
63 t_Output(i, j) += m_Mat[i][k] * a_Input(k, j);
70 Matrix& operator=(
const Matrix& a_Input)
74 m_Rows = a_Input.getRows();
75 m_Cols = a_Input.getCols();
76 m_Mat = a_Input.m_Mat;
85 void initMatrix(MatNxNd& a_Mat,
const int a_Rows,
const int a_Cols)
87 for(
int i=0; i<a_Rows; i++)
89 std::vector<double> t_RowVec;
90 for(
int j=0; j<a_Cols; j++)
92 t_RowVec.push_back(0);
94 a_Mat.push_back(t_RowVec);