num/mat.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <array> | ||
| 4 | #include <cstddef> | ||
| 5 | |||
| 6 | namespace wala { | ||
| 7 | |||
| 8 | // Small NxN matrix over num, row-major | ||
| 9 | template <typename num, int N> struct mat { | ||
| 10 | 2826 | std::array<num, size_t(N) * N> a{}; | |
| 11 | 1277580 | num& operator[](std::array<int, 2> rc) { return a[size_t(rc[0]) * N + rc[1]]; } | |
| 12 | 2439792 | const num& operator[](std::array<int, 2> rc) const { return a[size_t(rc[0]) * N + rc[1]]; } | |
| 13 | 31152 | num* data() { return a.data(); } | |
| 14 | 23908 | const num* data() const { return a.data(); } | |
| 15 |
6/6wala::mat<wala::modnum<1000000007>, 2>::operator+=(wala::mat<wala::modnum<1000000007>, 2> const&):
✓ Branch 15 → 3 taken 24840 times.
✓ Branch 15 → 16 taken 6210 times.
wala::mat<wala::modnum<1000000007>, 3>::operator+=(wala::mat<wala::modnum<1000000007>, 3> const&):
✓ Branch 15 → 3 taken 61650 times.
✓ Branch 15 → 16 taken 6850 times.
wala::mat<wala::modnum<998244353>, 3>::operator+=(wala::mat<wala::modnum<998244353>, 3> const&):
✓ Branch 15 → 3 taken 61650 times.
✓ Branch 15 → 16 taken 6850 times.
|
168050 | mat& operator+=(const mat& o) { for (int i = 0; i < N*N; i++) a[i] += o.a[i]; return *this; } |
| 16 | 340 | friend mat operator+(mat x, const mat& y) { x += y; return x; } | |
| 17 |
6/6wala::mat<wala::modnum<1000000007>, 2>::operator-=(wala::mat<wala::modnum<1000000007>, 2> const&):
✓ Branch 15 → 3 taken 80 times.
✓ Branch 15 → 16 taken 20 times.
wala::mat<wala::modnum<1000000007>, 3>::operator-=(wala::mat<wala::modnum<1000000007>, 3> const&):
✓ Branch 15 → 3 taken 450 times.
✓ Branch 15 → 16 taken 50 times.
wala::mat<wala::modnum<998244353>, 3>::operator-=(wala::mat<wala::modnum<998244353>, 3> const&):
✓ Branch 15 → 3 taken 450 times.
✓ Branch 15 → 16 taken 50 times.
|
1100 | mat& operator-=(const mat& o) { for (int i = 0; i < N*N; i++) a[i] -= o.a[i]; return *this; } |
| 18 | 120 | friend mat operator-(mat x, const mat& y) { x -= y; return x; } | |
| 19 | 19460 | friend mat operator*(const mat& x, const mat& y) { | |
| 20 | 19460 | mat r; | |
| 21 |
18/18wala::operator*(wala::mat<wala::modnum<1000000007>, 2> const&, wala::mat<wala::modnum<1000000007>, 2> const&):
✓ Branch 56 → 5 taken 50016 times.
✓ Branch 56 → 57 taken 25008 times.
✓ Branch 58 → 59 taken 25008 times.
✓ Branch 58 → 60 taken 12504 times.
✓ Branch 61 → 62 taken 12504 times.
✓ Branch 61 → 63 taken 6252 times.
wala::operator*(wala::mat<wala::modnum<1000000007>, 3> const&, wala::mat<wala::modnum<1000000007>, 3> const&):
✓ Branch 55 → 4 taken 178308 times.
✓ Branch 55 → 56 taken 59436 times.
✓ Branch 57 → 58 taken 59436 times.
✓ Branch 57 → 59 taken 19812 times.
✓ Branch 60 → 61 taken 19812 times.
✓ Branch 60 → 62 taken 6604 times.
wala::operator*(wala::mat<wala::modnum<998244353>, 3> const&, wala::mat<wala::modnum<998244353>, 3> const&):
✓ Branch 55 → 4 taken 178308 times.
✓ Branch 55 → 56 taken 59436 times.
✓ Branch 57 → 58 taken 59436 times.
✓ Branch 57 → 59 taken 19812 times.
✓ Branch 60 → 61 taken 19812 times.
✓ Branch 60 → 62 taken 6604 times.
|
622100 | for (int i = 0; i < N; i++) for (int k = 0; k < N; k++) for (int j = 0; j < N; j++) |
| 22 | 1626528 | r[{i, j}] += x[{i, k}] * y[{k, j}]; | |
| 23 | 19460 | return r; | |
| 24 | } | ||
| 25 | ✗ | mat& operator*=(const mat& o) { return *this = *this * o; } | |
| 26 |
1/2✓ Branch 20 → 21 taken 2694 times.
✗ Branch 20 → 25 not taken.
|
5652 | friend bool operator==(const mat&, const mat&) = default; |
| 27 | }; | ||
| 28 | |||
| 29 | } // namespace wala | ||
| 30 |