//****************************************************************************** //** SCATMECH: Polarized Light Scattering C++ Class Library //** //** File: matrixmath.h //** //** Thomas A. Germer //** Optical Technology Division, National Institute of Standards and Technology //** 100 Bureau Dr. Stop 8443; Gaithersburg, MD 20899-8443 //** Phone: (301) 975-2876; FAX: (301) 975-6991 //** Email: thomas.germer@nist.gov //** //** Version: 6.00 (February 2008) //** //****************************************************************************** #ifndef EIGEN_CGEEV_H #define EIGEN_CGEEV_H #include "scatmech.h" #include namespace SCATMECH { int eigen(std::vector& A, std::vector& Q, std::vector& W,int nmat); void LUdecompose(std::vector& matrix,int nmat,std::vector& pivot); void LUbacksubstitute(std::vector& matrix,int nmat,std::vector& pivot,std::vector& b); void LUImprove(std::vector& a, std::vector& alud, int n, std::vector& indx, std::vector& b, std::vector& x); void Inverse(std::vector& matrix, int nmat); namespace CMLIB { // // The template class FARRAY is a Fortran-like array. // template class FARRAY { public: FARRAY() {p = NULL; step=0; dealloc_on_destroy=false;} FARRAY(T* t) {p = t; step=0; dealloc_on_destroy=false;} FARRAY(T& t) {p = &t; step=0; dealloc_on_destroy=false;} FARRAY(std::vector& t) {p = &t[0],step=0;dealloc_on_destroy=false;} FARRAY(const FARRAY& a) {p = a.p; step = a.step; dealloc_on_destroy=false;} ~FARRAY() {if (dealloc_on_destroy) delete[] p;} T& operator()(int i) {return p[i-1];} T& operator()(int i,int j) {return p[(i-1)+step*(j-1)];} T& operator[](int i) {return p[i];} void array(int i,int j) { step = i; } void array(int i) { step = 0; } void allocate(int i,int j) { if (dealloc_on_destroy) delete[] p; step = i; p = new T[i*j]; dealloc_on_destroy=true; } void allocate(int i) { if (dealloc_on_destroy) delete[] p; step = 0; p = new T[i]; dealloc_on_destroy=true; } void deallocate() { if (dealloc_on_destroy) delete[] p; } T& operator=(const T& v) {*p = v; return *p;} operator T() const {return *p;} private: bool dealloc_on_destroy; int step; T* p; }; typedef FARRAY DFARRAY; typedef FARRAY CFARRAY; typedef FARRAY IFARRAY; void CGEEV(DFARRAY A,int LDA, int N, DFARRAY E0,DFARRAY V, int LDV, DFARRAY WORK, int JOB, int& INFO); void CGEFA(CFARRAY A, int LDA, int N, IFARRAY IPVT, int& INFO); void CGESL(CFARRAY A, int LDA, int N, IFARRAY IPVT, CFARRAY B, int JOB); void CGEDI(CFARRAY A, int LDA, int N, IFARRAY IPVT, CFARRAY DET, CFARRAY WORK, int JOB); } } #endif