in reply to Re^4: In PDL, how to raise a matrix $m to a power $v
in thread In PDL, how to raise a matrix $m to a power $v

Right, but couple of corrections/nitpicks, if I may:

if( $n < 0 ) { return matrix_power( inv( $M ), -$n ); } elsif ( $n == 0 ) { return identity( $M ); } elsif ( $n == 1 ) { return copy( $M ); # (1) # # ...

As to (1), I'm not sure about numpy, whether its function in question returns copy or clone in this case, or maybe they don't think it's important. But then, whole can of worms is there, e.g. data type of return piddle, what to do for singular matrices and negative exponent, and perhaps some others.

Replies are listed 'Best First'.
Re^6: In PDL, how to raise a matrix $m to a power $v
by pryrt (Abbot) on Feb 02, 2019 at 18:47 UTC
    Indeed. I did a rather naive interpretation of the wiki pseudocode. It would definitely need improvements (including those you showed) to be production-worthy.