MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / pow

Method pow

code/data-structures/matrix.cpp:26–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 res(i, j) += at(i, k) * other.data[k * other.cols + j];
25 return res; }
26 matrix<T> pow(ll p) {
27 matrix<T> res(rows, cols), sq(*this);
28 rep(i,0,rows) res(i, i) = T(1);
29 while (p) {
30 if (p & 1) res = res * sq;
31 p >>= 1;
32 if (p) sq = sq * sq;
33 } return res; }
34 matrix<T> rref(T &det, int &rank) {
35 matrix<T> mat(*this); det = T(1), rank = 0;
36 for (int r = 0, c = 0; c < cols; c++) {

Callers 1

testFunction · 0.45

Calls

no outgoing calls

Tested by 1

testFunction · 0.36