5template <
int Rows,
int Cols,
int X,
typename Scalar>
7 const Matrix<Rows, X, Scalar>& lhs,
8 const Matrix<X, Cols, Scalar>& rhs
10 Matrix<Rows, Cols, Scalar> result(0);
12 for (
int i = 0;
i < Rows;
i++) {
13 for (
int j = 0;
j < Cols;
j++) {
14 for (
int k = 0;
k <
X;
k++) {
15 result(i, j) += lhs(i, k) *
rhs(k, j);
24template <
int Rows,
int Cols,
int X,
typename Scalar>
26 const Matrix<Rows, X, Scalar>& lhs,
27 const Matrix<X, Cols, Scalar>& rhs
29 Matrix<Rows, Cols, Scalar> result;
31 for (
int i = 0;
i < Rows;
i++) {
32 for (
int j = 0;
j < Cols;
j++) {
33 result(i, j) = lhs(i, j) *
rhs(i, j);
40template <
int Rows,
int Cols,
int X,
typename Scalar>
42 const Matrix<Rows, X, Scalar>& lhs,
43 const Matrix<X, Cols, Scalar>& rhs
57template <
int Rows,
int Cols,
int X>
59 const Matrix<Rows, X, double>& lhs,
60 const Matrix<X, Cols, double>& rhs
62 Matrix<Rows, Cols, double> output;
83template <
int Rows,
int Cols,
typename Scalar>
88 for (
int i = 0; i < Rows; i++) {
89 for (
int j = 0; j < Cols; j++) {
90 if (lhs(i, j) != rhs(i, j)) {
99template <
int Rows,
int Cols,
typename Scalar>
103 const Scalar& tolerance
105 for (
int i = 0; i < Rows; i++) {
106 for (
int j = 0; j < Cols; j++) {
107 if (!equals(lhs(i, j), rhs(i, j), tolerance)) {
116template <
int Rows,
int Cols,
typename Scalar>
118 const Matrix<Rows, Cols, Scalar>& lhs,
119 const Matrix<Rows, Cols, Scalar>& rhs
125 for (
int i = 0; i < Rows; i++) {
126 for (
int j = 0; j < Cols; j++) {
127 result(i, j) = lhs(i, j) + rhs(i, j);
134template <
int Rows,
int Cols,
typename Scalar>
136 const Matrix<Rows, Cols, Scalar>& lhs,
137 const Matrix<Rows, Cols, Scalar>& rhs
143 for (
int i = 0;
i < Rows;
i++) {
144 for (
int j = 0;
j < Cols;
j++) {
145 result(i, j) = lhs(i, j) -
rhs(i, j);
152template <
int Rows,
int Cols,
typename Scalar>
156 const Scalar& tolerance
158 for (
int i = 0; i < Rows; i++) {
159 for (
int j = 0; j < Cols; j++) {
160 if (
std::abs(lhs(i, j) - rhs(i, j)) > tolerance)
161 return std::pair<int, int>(i, j);
164 return std::pair<int, int>(-1, -1);
Matrix< Rows, Cols, Scalar > multiply(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)
Performs a matrix x matrix multiplication.
bool operator==(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs)
Bitwise comparison of the components of two matrices on equality.
Matrix< Rows, Cols, Scalar > operator-(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs)
Matrix< Rows, Cols, Scalar > operator+(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs)
Matrix< Rows, Cols, Scalar > operator*(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.
std::pair< int, int > equalsReturnIndex(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Return Index of element which is not equals.
Matrix< Rows, Cols, Scalar > multiplyComponents(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)