diff --git a/nonclass.cc b/nonclass.cc index 5810159..44b4189 100644 --- a/nonclass.cc +++ b/nonclass.cc @@ -30,6 +30,7 @@ INSTANTIZE(short) INSTANTIZE(char) INSTANTIZE(unsigned char) INSTANTIZE(unsigned long) +INSTANTIZE(unsigned int) #define EPSDET 1e-300 @@ -440,6 +441,8 @@ void gdiagonalize(NRMat &a, NRVec &wr, NRVec &wi, else FORNAME(dgeev)(&jobvr, &jobvl, &n, a, &lda, wr, wi, vr?vr[0]:(double *)0, &ldvr, vl?vl[0]:(double *)0, &ldvl, work, &lwork, &r); delete[] work; +//@@@ +//cout <<"TEST dgeev\n"< 0) laerror("convergence problem in ggev/geev in gdiagonalize()"); @@ -614,10 +617,20 @@ NRMat matrixfunction(NRMat a, complex int n = a.nrows(); NRMat< complex > u(n, n), v(n, n); NRVec< complex > w(n); - gdiagonalize(a, w, &u, &v); +NRMat > a0=complexify(a); + gdiagonalize(a, w, &u, &v);//a gets destroyed, eigenvectors are rows NRVec< complex > z = diagofproduct(u, v, 1, 1); +/* +cout <<"TEST matrixfunction\n"< > wz(n); +for (int i=0; i > r(n, n); @@ -688,6 +701,12 @@ complex myclog (const complex &x) return log(x); } +complex mycexp (const complex &x) +{ + return exp(x); +} + + complex sqrtinv (const complex &x) { return 1./sqrt(x); @@ -704,6 +723,12 @@ NRMat log(const NRMat &a) return matrixfunction(a, &myclog, 1); } +NRMat exp0(const NRMat &a) +{ + return matrixfunction(a, &mycexp, 1); +} + + const NRVec diagofproduct(const NRMat &a, const NRMat &b, bool trb, bool conjb) @@ -773,10 +798,24 @@ double trace2(const NRSMat &a, const NRSMat &b, double r = 2.0*cblas_ddot(a.nrows()*(a.nrows()+1)/2, a, 1, b, 1); if (diagscaled) return r; - for (int i=0; i &a, const NRMat &b, const bool diagscaled) +{ + if (a.nrows() != b.nrows()||b.nrows()!=b.ncols()) laerror("incompatible SMats in trace2()"); +double r=0; + int i, j, k=0; + for (i=0; i &a, NRVec &w, NRMat b, int n)