Hi, I can’t understand the code about matrix exponation.
I have some questions
We have the vector b and c why we declare it again and copy the same elements on that?
and when copying elements from array c to transformation matrix he wrote this code can someone explain how this code works?
if(n&1){
return pow(a,multipy(a,p-1));
}
can we write this down line instead of this line?
if(n&1){
vector<vector<ll>> s= pow(a,p/2);
return multiply(s,s);
}
How does this multipication matrix do?
why we declare 2d array c? I thought that the answer of multiplication of to matrix would be one dimensional
Multipication Function:
vector<vector<ll> > multiply(vector<vector<ll> > A,vector <vector<ll>>B){
vector<vector<ll>> C(k+1,vector<ll>(k+1));
for(int i=1;i<=k;++i){
for(int j=1;j<=k;++j){
for(int x=1;x<=k;++x){
c[i][j] = (c[i][j] + (A[i][x]*B[x][j])%MOD)%MOD;
}
}
}
return C;
}
Sorry for a lot of question Thanks.
