|
Isis 3.0 Developer's Reference (API) |
Home |
00001 #ifndef GSLUtility_h 00002 #define GSLUtility_h 00003 00027 #include <iostream> 00028 #include <sstream> 00029 #include <string> 00030 #include <vector> 00031 #include <algorithm> 00032 00033 #include <QString> 00034 00035 #include <tnt/tnt_array1d.h> 00036 #include <tnt/tnt_array1d_utils.h> 00037 #include <tnt/tnt_array2d.h> 00038 #include <tnt/tnt_array2d_utils.h> 00039 00040 #include <gsl/gsl_vector.h> 00041 #include <gsl/gsl_matrix.h> 00042 00043 // Some GSL optimization on by default, off if DEBUG or SAFE_GSL is defined 00044 #ifndef DEBUG 00045 #ifndef SAFE_GSL 00046 #define GSL_RANGE_CHECK_OFF 1 00047 #endif 00048 #endif 00049 00050 #include "IException.h" 00051 00052 namespace Isis { 00053 namespace GSL { 00054 00086 class GSLUtility { 00087 public: 00088 typedef TNT::Array1D<double> GSLVector; 00089 typedef TNT::Array2D<double> GSLMatrix; 00090 00091 static GSLUtility *getInstance(); 00092 00094 inline bool success(int status) const { 00095 return (status == GSL_SUCCESS); 00096 } 00097 00104 inline QString status(int gsl_errno) const { 00105 return (QString(gsl_strerror(gsl_errno))); 00106 } 00107 00108 void check(int gsl_status, const char *src = __FILE__, int line = __LINE__) 00109 const; 00110 00111 00112 size_t Rows(const gsl_matrix *m) const; 00113 size_t Columns(const gsl_matrix *m) const; 00114 00115 size_t Rows(const GSLMatrix &m) const; 00116 size_t Columns(const GSLMatrix &m) const; 00117 00118 size_t size(const gsl_vector *v) const; 00119 size_t size(const gsl_matrix *m) const; 00120 00121 gsl_vector *vector(size_t n, bool zero = false) const; 00122 gsl_matrix *matrix(size_t n1, size_t n2, bool zero = false) const; 00123 gsl_matrix *identity(size_t n1, size_t n2) const; 00124 void setIdentity(gsl_matrix *m) const; 00125 00126 void free(gsl_vector *v) const; 00127 void free(gsl_matrix *m) const; 00128 00129 GSLVector gslToGSL(const gsl_vector *v) const; 00130 GSLMatrix gslToGSL(const gsl_matrix *m) const; 00131 gsl_vector *GSLTogsl(const GSLVector &v, gsl_vector *gv = 0) const; 00132 gsl_matrix *GSLTogsl(const GSLMatrix &m, gsl_matrix *gm = 0) const; 00133 00134 00135 private: 00136 // Private Constructor/Destructor makes this a singleton 00137 GSLUtility(); 00138 ~GSLUtility() { } 00139 00140 static GSLUtility *_instance; 00141 00142 static void handler(const char *reason, const char *file, int line, 00143 int gsl_errno); 00144 00145 00146 }; 00147 00148 } // namespace GSL 00149 } // namespace Isis 00150 #endif 00151