c - Inverting a matrix of any size -


i'm using gnu scientific library in implementing calculator needs able raise matrices powers. unfortunately, there doesn't seem such function available in gsl multiplying matrices (the gsl_matrix_mul_elements() function multiplies using addition process), , extension, no raising powers.

i want able raise negative powers, requires ability take inverse. searching around, have not been able find sound code calculating inverses of arbitrary matrices (only ones defined dimensions), , guides found doing hand use clever "on-paper tricks" don't work in code.

is there common algorithm can used compute inverse of matrix of size (failing of course when inverse cannot calculated)?

as mentioned in comments, power of matrices can computed square matrices integer exponents. n power of a a^n = a*a*...a a appears n times. if b inverse of a, -n power of a a^(-n) = (a^-1)^n = b^n = b*b*...b.

so in order compute n power of a can suggest following algorithm using gsl:

gsl_matrix_set_identity();         // initialize for(i=0;i<n;i++) gsl_blas_dgemm(); // compute recursive product of 

for computing b matrix can use following routine

gsl_linalg_lu_decomp();       // compute decomposition gsl_linalg_complex_lu_invert  // comput inverse decomposition 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -