def f(Q, t, ipiv=ipiv, wsp=wsp): x = dgpadm(ideg, t, Q, wsp, ipiv) print x i = x[0]-1 print nstates, i p = wsp[i:i+ncells].reshape((nstates,nstates)) return p.T
def dexpm(h, t): ideg = 4 nstates = h.shape[0] lwsp = 4*nstates**2+ideg+1 ipiv = zeros(nstates, dtype=int) hsize = nstates**2 wsp = empty(lwsp) i = dgpadm(ideg, t, h, wsp, ipiv)[0]-1 print 'i =', i p = wsp[i:i+hsize].reshape(h.shape) return p.T
def expf(n, t, A, LDA): """to compute: exp( t * A(1:n, 1:n) ) where on input: t is a real scalar (positive or negative) A(LDA,*) is real n-by-n note: LDAC is to be provided on input and represent the so-called leading-dimension of A. """ ideg = 6; lwsp = 4 * n * n + ideg + 1 wsp = zeros(lwsp, float64) iexp = n * n + ideg + 1 iwsp = zeros(n) ns = 0 iflag = 0 dgpadm(ideg, t, A, wsp, iwsp, iexp, ns, iflag) return wsp[iexp:(iexp+n*n)].reshape((n,n)).T