| 48 | return ans; |
| 49 | } |
| 50 | inline Mat pow(long long k) { |
| 51 | assert(n == m); |
| 52 | Mat ans(n, n), t = a; ans.make_unit(); |
| 53 | while (k) { |
| 54 | if (k & 1) ans = ans * t; |
| 55 | t = t * t; |
| 56 | k >>= 1; |
| 57 | } |
| 58 | return ans; |
| 59 | } |
| 60 | inline Mat& operator += (const Mat& b) { return *this = (*this) + b; } |
| 61 | inline Mat& operator -= (const Mat& b) { return *this = (*this) - b; } |
| 62 | inline Mat& operator *= (const Mat& b) { return *this = (*this) * b; } |