Python Matrix Exponentiation -


this question has answer here:

i use python 2.x or 3.x raise 2x2 matrix initially

0 1 1 1 

to exponent of 1019 or less. (that is, let m = matrix, m1019).

however, don't want use numpy.

(by way, is fibonacci generator )

ok, way you're asking question means stand no chance of achieving this. i'll explain; please don't offended:

  1. python wrong tool, , you're trying exclude helpers make little less wrong. you're trying numerical math in purest form -- , python scripting language can take advantage of numerical efficiency when using native libraries. 1 of these numpy, you've noticed (but didn't write) doesn't work, because numbers big fast when calculating mn larger n.
  2. even if there magic way optimize algorithm in matter allow matrix-matrix multiplication in single instruction , you'd need instruction count , check whether still should multiplying calculate mn, calculation take 2*1019 instructions. assuming have 8 cpus can 4 billions of per second, still take little less 20 years. need here proper math. like, strong math. can find diagonal form such m = u d u-1; u being unitary , d being diagonal matrix. then, using matrix exponential e, can em = u ed u. classical exponential rules apply, can calculate em1019. that's still ugly, terminate @ time can consider safer. however, luck implementing without degree in numerical mathematics.

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -