/* $Id: shoot_expm3.c 4875 2012-08-30 20:04:30Z john $ */ /* (c) John Ashburner (2011) */ #include #include #include extern double log(double x); extern double exp(double x); static int pow2(int k) { int j0, td = 1; for(j0=0; j0rm) rm = r; r = fabs(a[6]) + fabs(a[7]) + fabs(a[8]); if (r>rm) rm = r; return(rm); } static float *assign33(float *a, float *b) { int i; for(i=0; i<9; i++) b[i] = a[i]; return(b); } void expm33(float *a, float *l) { /* See expm.m in MATLAB or http://mathworld.wolfram.com/PadeApproximant.html */ int K; K = (int)ceil(log((double)(norm1(a)*2.3481))*1.44269504088896); if (K>0) { float b[9]; float s = 1.0/pow2(K); int i; scale33(a,s,b); pade33(b, l); for(i=0; i0) { float b[9]; float s = 1.0/pow2(K); int i; scale33(a,s,b); pade22(b, l); for(i=0; i