-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmatrix.sublime-snippet
59 lines (59 loc) · 1.33 KB
/
matrix.sublime-snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<snippet>
<content><![CDATA[
const int sz = 3;
struct vec{
int arr[SZ];
void reset(){
memset(arr , 0 , sizeof(arr));
}
};
struct matrix{
int arr[SZ][SZ];
void reset(){
memset(arr , 0 , sizeof(arr));
}
void makeiden(){
reset();
for(int i = 0 ; i < SZ ; ++i){
arr[i][i] = 1;
}
}
matrix operator + (const matrix &o) const {
matrix res;
for(int i = 0 ; i < SZ ; ++i){
for(int j = 0 ; j < SZ ; ++j){
res.arr[i][j] = arr[i][j] + o.arr[i][j];
res.arr[i][j] -= (res.arr[i][j] >= mod) * mod;
}
}
return res;
}
matrix operator * (const matrix &o) const {
matrix res;
for(int i = 0 ; i < SZ ; ++i){
for(int j = 0 ; j < SZ ; ++j){
res.arr[i][j] = 0;
for(int k = 0 ; k < SZ ; ++k){
res.arr[i][j] = (res.arr[i][j] + 1LL * arr[i][k] * o.arr[k][j]) % mod;
}
}
}
return res;
}
vec operator * (const vec &o) const {
vec res;
for(int i = 0 ; i < SZ ; ++i){
res.arr[i] = 0;
for(int k = 0 ; k < SZ ; ++k){
res.arr[i] = (res.arr[i] + 1LL * arr[i][k] * o.arr[k]) % mod;
}
}
return res;
}
};
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>matrix</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.cpp , source.cxx , source.c , source.c++ , source.h , source.hpp</scope>
</snippet>