示例#1
0
文件: stc.cpp 项目: nvmd/itpp
itpp::mat STC::mat_pow(const itpp::mat &in_mat, int in_exp)
//square matrix power of integer exponent
{
    if (in_exp==0)
    {
        return itpp::eye(in_mat.rows());
    }
    itpp::mat out = in_mat;
    int abs_in_exp = std::abs(in_exp);
    register int n;
    for (n=1; n<abs_in_exp; n++)
    {
        out *= in_mat;
    }
    return (in_exp>0)?out:itpp::inv(out);
}