Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: In PDL, how to raise a matrix $m to a power $v

by vr (Curate)
on Feb 02, 2019 at 17:57 UTC ( [id://1229295]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229295]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found