pow¶
-
template<typename Mat>
Mat pow(Mat const &x, typename Mat::scalar_type e)¶ Returns the matrix
x
to the powere
. This function template is defined in namespacematrix_helpers
.- Parameters
x – the matrix (must have equal number of rows and columns)
e – the exponent (must be \(\geq 0\))
- Returns
A value of type
Mat
. Ife
is0
, then the identity matrix is returned; ife
is1
, then a copy of the parameterx
is returned.- Throws
LibsemigroupsException
iftypename Mat::scalar_type
is a signed type and the parametere
is less than0
.This function does not to throw any other
LibsemigroupsException
s. It might throwstd::bad_alloc
if the algorithm cannot allocate enough memory.- Complexity
\(O(m\log_2(e))\) where \(m\) is the dimension of the matrix
x
and \(e\) is the parametere
.
Example
auto x == ProjMaxPlusMat<>::make({{-2, 2, 0}, {-1, 0, 0}, {1, -3, 1}})); matrix_helpers::pow(x, 100); // returns {{-1, 0, -1}, {-2, -1, -2}, {-1, 0, -1}}