Skip to content

Commit

Permalink
Use array instead of vector in Matrix (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrvideckis authored Dec 1, 2024
1 parent bbfaefb commit 0f8a6aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions content/data-structures/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Basic operations on square matrices.
* Usage: Matrix<int, 3> A;
* A.d = {{{{1,2,3}}, {{4,5,6}}, {{7,8,9}}}};
* vector<int> vec = {1,2,3};
* array<int, 3> vec = {1,2,3};
* vec = (A^N) * vec;
* Status: tested
*/
Expand All @@ -21,8 +21,8 @@ template<class T, int N> struct Matrix {
rep(k,0,N) a.d[i][j] += d[i][k]*m.d[k][j];
return a;
}
vector<T> operator*(const vector<T>& vec) const {
vector<T> ret(N);
array<T, N> operator*(const array<T, N>& vec) const {
array<T, N> ret{};
rep(i,0,N) rep(j,0,N) ret[i] += d[i][j] * vec[j];
return ret;
}
Expand Down

0 comments on commit 0f8a6aa

Please sign in to comment.