pow

template<typename Mat>
Mat pow(Mat const &x, typename Mat::scalar_type e)

Returns the matrix x to the power e. This function template is defined in namespace matrix_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. If e is 0, then the identity matrix is returned; if e is 1, then a copy of the parameter x is returned.

Throws

LibsemigroupsException if typename Mat::scalar_type is a signed type and the parameter e is less than 0.

This function does not to throw any other LibsemigroupsException s. It might throw std::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 parameter e.

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}}