Skip to content

Commit

Permalink
Merge pull request #333 from hitonanode/add-matrix-tests
Browse files Browse the repository at this point in the history
Add matrix tests
  • Loading branch information
hitonanode authored May 3, 2024
2 parents dac6b5b + b12196a commit fcd5284
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions linear_algebra_matrix/test/matrix_determinant.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#define PROBLEM "https://judge.yosupo.jp/problem/matrix_det"
#include "../../modint.hpp"
#include "../matrix.hpp"
#include <iostream>
using namespace std;

int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);

int N;
cin >> N;
matrix<ModInt<998244353>> M(N, N);
cin >> M;
cout << M.gauss_jordan().determinant_of_upper_triangle() << '\n';
}
22 changes: 22 additions & 0 deletions linear_algebra_matrix/test/matrix_pow.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#define PROBLEM "https://judge.yosupo.jp/problem/pow_of_matrix"
#include "../../modint.hpp"
#include "../matrix.hpp"
#include <iostream>
using namespace std;

int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);

int N;
long long K;
cin >> N >> K;
matrix<ModInt<998244353>> M(N, N);
cin >> M;
M = M.pow(K);
for (int i = 0; i < N; ++i) {
cout << M[i][0];
for (int j = 1; j < N; ++j) cout << ' ' << M[i][j];
cout << '\n';
}
}
16 changes: 16 additions & 0 deletions linear_algebra_matrix/test/matrix_rank.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#define PROBLEM "https://judge.yosupo.jp/problem/matrix_rank"
#include "../../modint.hpp"
#include "../matrix.hpp"
#include <iostream>
using namespace std;

int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);

int N, M;
cin >> N >> M;
matrix<ModInt<998244353>> mat(N, M);
cin >> mat;
cout << mat.gauss_jordan().rank_of_gauss_jordan() << '\n';
}

0 comments on commit fcd5284

Please sign in to comment.