'Find negative fractional power of a matrix in Armadillo

In Matlab I do A ^ -0.5 to find the negative fractional power of matrix A. What is the equivalent in Armadillo C++ library? The pow() function performs element wise operation.



Solution 1:[1]

You can do

expmat(-0.5 * logmat(A))

Solution 2:[2]

Use the powmat() function, like so:

mat A(5,5,fill::randu);
cx_mat B = powmat(A, -0.5);

Or use a combination of inv() and sqrtmat().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stéphane Laurent
Solution 2 hbrerkere