00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_UMATRIX_CX_TLATE_H 00024 #define O2SCL_UMATRIX_CX_TLATE_H 00025 00026 /** \file umatrix_cx_tlate.h 00027 \brief File for definitions of matrices 00028 */ 00029 00030 #include <iostream> 00031 #include <cstdlib> 00032 #include <string> 00033 #include <fstream> 00034 #include <sstream> 00035 00036 #include <gsl/gsl_matrix.h> 00037 #include <gsl/gsl_ieee_utils.h> 00038 00039 #include <o2scl/err_hnd.h> 00040 #include <o2scl/uvector_tlate.h> 00041 #include <o2scl/uvector_cx_tlate.h> 00042 00043 #ifndef DOXYGENP 00044 namespace o2scl { 00045 #endif 00046 00047 /** 00048 \brief A matrix view of complex numbers 00049 */ 00050 template<class data_t, class complex_t> class umatrix_cx_view_tlate { 00051 00052 #ifndef DOXYGEN_INTERNAL 00053 00054 protected: 00055 00056 /// The data 00057 data_t *data; 00058 /// The number of rows 00059 size_t size1; 00060 /// The number of columns 00061 size_t size2; 00062 /// Zero if memory is owned elsewhere, 1 otherwise 00063 int owner; 00064 00065 #endif 00066 00067 public: 00068 00069 /// \name Copy constructors 00070 //@{ 00071 /// So2scllow copy constructor - create a new view of the same matrix 00072 umatrix_cx_view_tlate(const umatrix_cx_view_tlate &v) { 00073 data=v.data; 00074 size1=v.size1; 00075 size2=v.size2; 00076 owner=0; 00077 } 00078 00079 /// So2scllow copy constructor - create a new view of the same matrix 00080 umatrix_cx_view_tlate& operator=(const umatrix_cx_view_tlate &v) { 00081 data=v.data; 00082 size1=v.size1; 00083 size2=v.size2; 00084 owner=0; 00085 00086 return *this; 00087 } 00088 //@} 00089 00090 ~umatrix_cx_view_tlate() {}; 00091 00092 /// \name Get and set methods 00093 //@{ 00094 /** 00095 \brief Array-like indexing 00096 */ 00097 complex_t *operator[](size_t i) { 00098 #if O2SCL_NO_RANGE_CHECK 00099 #else 00100 if (i>=size1) { 00101 O2SCL_ERR((((std::string)"Array index ")+itos(i)+" out of bounds" 00102 +" in umatrix_cx_view_tlate::operator[]. Size: "+ 00103 itos(size1)+ 00104 " (index should be less than size).").c_str(),gsl_eindex); 00105 return (complex_t *)data; 00106 } 00107 #endif 00108 return (complex_t *)(data+2*i*size2); 00109 } 00110 00111 /** 00112 \brief Array-like indexing 00113 */ 00114 const complex_t *operator[](size_t i) const { 00115 #if O2SCL_NO_RANGE_CHECK 00116 #else 00117 if (i>=size1) { 00118 O2SCL_ERR((((std::string)"Array index ")+itos(i)+" out of bounds" 00119 +" in umatrix_cx_view_tlate::operator[] const. Size: "+ 00120 itos(size1)+ 00121 " (index should be less than size).").c_str(),gsl_eindex); 00122 return (const complex_t *)data; 00123 } 00124 #endif 00125 return (const complex_t *)(data+2*i*size2); 00126 } 00127 00128 /** 00129 \brief Array-like indexing 00130 */ 00131 complex_t &operator()(size_t i, size_t j) { 00132 #if O2SCL_NO_RANGE_CHECK 00133 #else 00134 if (i>=size1 || j>=size2) { 00135 O2SCL_ERR((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00136 ") out of bounds" 00137 +" in umatrix_cx_view_tlate::operator(). Sizes: ("+ 00138 itos(size1)+","+itos(size2)+ 00139 ") (index should be less than size).").c_str(),gsl_eindex); 00140 return *(complex_t *)data; 00141 } 00142 #endif 00143 return *(complex_t *)(data+2*(i*size2+j)); 00144 } 00145 00146 /** 00147 \brief Array-like indexing 00148 */ 00149 const complex_t &operator()(size_t i, size_t j) const { 00150 #if O2SCL_NO_RANGE_CHECK 00151 #else 00152 if (i>=size1 || j>=size2) { 00153 O2SCL_ERR((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00154 ") out of bounds" 00155 +" in umatrix_cx_view_tlate::operator() const. Sizes: ("+ 00156 itos(size1)+","+itos(size2)+ 00157 ") (index should be less than size).").c_str(),gsl_eindex); 00158 return *(const complex_t *)data; 00159 } 00160 #endif 00161 return *(const complex_t *)(data+2*(i*size2+j)); 00162 } 00163 00164 /** \brief Get (with optional range-checking) */ 00165 complex_t get(size_t i, size_t j) const { 00166 #if O2SCL_NO_RANGE_CHECK 00167 #else 00168 if (i>=size1 || j>=size2) { 00169 O2SCL_ERR((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00170 ") out of bounds" 00171 +" in umatrix_cx_view_tlate::get(). Sizes: ("+ 00172 itos(size1)+","+itos(size2)+ 00173 ") (index should be less than size).").c_str(),gsl_eindex); 00174 return *(complex_t *)data; 00175 } 00176 #endif 00177 return *(complex_t *)(data+2*(i*size2+j)); 00178 } 00179 00180 /** \brief Get pointer (with optional range-checking) */ 00181 complex_t *get_ptr(size_t i, size_t j) { 00182 #if O2SCL_NO_RANGE_CHECK 00183 #else 00184 if (i>=size1 || j>=size2) { 00185 O2SCL_ERR((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00186 ") out of bounds" 00187 +" in umatrix_cx_view_tlate::get_ptr(). Sizes: ("+ 00188 itos(size1)+","+itos(size2)+ 00189 ") (index should be less than size).").c_str(),gsl_eindex); 00190 return (complex_t *)data; 00191 } 00192 #endif 00193 return (complex_t *)(data+2*(i*size2+j)); 00194 } 00195 00196 /** \brief Get pointer (with optional range-checking) */ 00197 const complex_t *get_const_ptr(size_t i, size_t j) const { 00198 #if O2SCL_NO_RANGE_CHECK 00199 #else 00200 if (i>=size1 || j>=size2) { 00201 O2SCL_ERR((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00202 ") out of bounds" 00203 +" in umatrix_cx_view_tlate::get_const_ptr(). Sizes: ("+ 00204 itos(size1)+","+itos(size2)+ 00205 ") (index should be less than size).").c_str(),gsl_eindex); 00206 return (const complex_t *)data; 00207 } 00208 #endif 00209 return (const complex_t *)(data+2*(i*size2+j)); 00210 } 00211 00212 /** \brief Set (with optional range-checking) */ 00213 int set(size_t i, size_t j, complex_t val) { 00214 #if O2SCL_NO_RANGE_CHECK 00215 #else 00216 if (i>=size1 || j>=size2) { 00217 O2SCL_ERR_RET((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00218 ") out of bounds" 00219 +" in umatrix_cx_view_tlate::set(i,j,val). Sizes: ("+ 00220 itos(size1)+","+itos(size2)+ 00221 ") (index should be less than size).").c_str(), 00222 gsl_eindex); 00223 } 00224 #endif 00225 *(data+2*(i*size2+j))=GSL_REAL(val); 00226 *(data+2*(i*size2+j)+1)=GSL_IMAG(val); 00227 return 0; 00228 } 00229 00230 /** \brief Set (with optional range-checking) */ 00231 int set(size_t i, size_t j, data_t re, data_t im) { 00232 #if O2SCL_NO_RANGE_CHECK 00233 #else 00234 if (i>=size1 || j>=size2) { 00235 O2SCL_ERR_RET((((std::string)"Indices (")+itos(i)+","+itos(j)+ 00236 ") out of bounds" 00237 +" in umatrix_cx_view_tlate::set(i,j,re,im). Sizes: ("+ 00238 itos(size1)+","+itos(size2)+ 00239 ") (index should be less than size).").c_str(), 00240 gsl_eindex); 00241 } 00242 #endif 00243 *(data+2*(i*size2+j))=re; 00244 *(data+2*(i*size2+j)+1)=im; 00245 return 0; 00246 } 00247 00248 /** \brief Set all of the value to be the value \c val */ 00249 int set_all(complex_t val) { 00250 for(size_t i=0;i<size1;i++) { 00251 for(size_t j=0;j<size2;j++) { 00252 *(data+2*(i*size2+j))=GSL_REAL(val); 00253 *(data+2*(i*size2+j)+1)=GSL_IMAG(val); 00254 } 00255 } 00256 return 0; 00257 } 00258 00259 /** 00260 \brief Method to return number of rows 00261 00262 If no memory has been allocated, this will quietly 00263 return zero. 00264 */ 00265 size_t rows() const { 00266 return size1; 00267 } 00268 00269 /** 00270 \brief Method to return number of columns 00271 00272 If no memory has been allocated, this will quietly 00273 return zero. 00274 */ 00275 size_t cols() const { 00276 return size2; 00277 } 00278 //@} 00279 00280 /// \name Other methods 00281 //@{ 00282 /// Return true if this object owns the data it refers to 00283 bool is_owner() const { 00284 if (owner==1) return true; 00285 return false; 00286 } 00287 //@} 00288 00289 /// \name Arithmetic 00290 //@{ 00291 /** \brief operator+= */ 00292 umatrix_cx_view_tlate<data_t,complex_t> &operator+= 00293 (const umatrix_cx_view_tlate<data_t,complex_t> &x) { 00294 size_t lsize=x.size1; 00295 if (lsize>size1) lsize=size1; 00296 size_t lsize2=x.size2; 00297 if (lsize2>size2) lsize2=size2; 00298 for(size_t i=0;i<lsize;i++) { 00299 for(size_t j=0;j<lsize2;j++) { 00300 (*this)[i][j]+=x[i][j]; 00301 } 00302 } 00303 00304 return *this; 00305 } 00306 00307 /** \brief operator-= */ 00308 umatrix_cx_view_tlate<data_t,complex_t> &operator-= 00309 (const umatrix_cx_view_tlate<data_t,complex_t> &x) { 00310 size_t lsize=x.size1; 00311 if (lsize>size1) lsize=size1; 00312 size_t lsize2=x.size2; 00313 if (lsize2>size2) lsize2=size2; 00314 for(size_t i=0;i<lsize;i++) { 00315 for(size_t j=0;j<lsize2;j++) { 00316 (*this)[i][j]+=x[i][j]; 00317 } 00318 } 00319 00320 return *this; 00321 } 00322 00323 /** \brief operator+= */ 00324 umatrix_cx_view_tlate<data_t,complex_t> &operator+=(const data_t &y) { 00325 for(size_t i=0;i<size1;i++) { 00326 for(size_t j=0;j<size2;j++) { 00327 (*this)[i][j]+=y; 00328 } 00329 } 00330 00331 return *this; 00332 } 00333 00334 /** \brief operator-= */ 00335 umatrix_cx_view_tlate<data_t,complex_t> &operator-=(const data_t &y) { 00336 for(size_t i=0;i<size1;i++) { 00337 for(size_t j=0;j<size2;j++) { 00338 (*this)[i][j]-=y; 00339 } 00340 } 00341 00342 return *this; 00343 } 00344 00345 /** \brief operator*= */ 00346 umatrix_cx_view_tlate<data_t,complex_t> &operator*=(const data_t &y) { 00347 for(size_t i=0;i<size1;i++) { 00348 for(size_t j=0;j<size2;j++) { 00349 (*this)[i][j]*=y; 00350 } 00351 } 00352 00353 return *this; 00354 } 00355 //@} 00356 00357 #ifndef DOXYGEN_INTERNAL 00358 00359 protected: 00360 00361 /** \brief Empty constructor provided for use by 00362 umatrix_cx_tlate(const umatrix_cx_tlate &v) 00363 */ 00364 umatrix_cx_view_tlate() {}; 00365 00366 #endif 00367 00368 }; 00369 00370 /** 00371 \brief A matrix of double-precision numbers 00372 00373 */ 00374 template<class data_t, class complex_t> class umatrix_cx_tlate : 00375 public umatrix_cx_view_tlate<data_t,complex_t> { 00376 public: 00377 00378 /// \name Standard constructor 00379 //@{ 00380 /** \brief Create an umatrix of size \c n with owner as 'true' 00381 */ 00382 umatrix_cx_tlate(size_t r=0, size_t c=0) { 00383 00384 this->data=0; 00385 this->size1=0; 00386 this->size2=0; 00387 00388 // This must be set to 1 even if n=0 so that future 00389 // calls to operator= work properly 00390 this->owner=1; 00391 00392 if (r>0 && c>0) { 00393 this->data=(data_t *)malloc(2*r*c*sizeof(data_t)); 00394 if (this->data) { 00395 this->size1=r; 00396 this->size2=c; 00397 } else { 00398 O2SCL_ERR("No memory for data in umatrix_cx_tlate constructor", 00399 gsl_enomem); 00400 } 00401 } 00402 } 00403 //@} 00404 00405 /// \name Copy constructors 00406 //@{ 00407 /// Deep copy constructor, allocate new space and make a copy 00408 umatrix_cx_tlate(const umatrix_cx_tlate &v) : 00409 umatrix_cx_view_tlate<data_t,complex_t>() { 00410 size_t n=v.size1; 00411 size_t n2=v.size2; 00412 if (n>0 && n2>0) { 00413 this->data=(data_t *)malloc(2*n*n2*sizeof(data_t)); 00414 if (this->data) { 00415 this->size1=n; 00416 this->size2=n2; 00417 this->owner=1; 00418 for(size_t i=0;i<n;i++) { 00419 for(size_t j=0;j<n2;j++) { 00420 *(this->data+i*this->size2+j)=v[i][j]; 00421 } 00422 } 00423 } else { 00424 O2SCL_ERR("No memory for data in umatrix_cx_tlate constructor", 00425 gsl_enomem); 00426 } 00427 } else { 00428 this->size1=0; 00429 this->size2=0; 00430 } 00431 } 00432 00433 /// Deep copy constructor, allocate new space and make a copy 00434 umatrix_cx_tlate 00435 (const umatrix_cx_view_tlate<data_t,complex_t> &v) : 00436 umatrix_cx_view_tlate<data_t,complex_t>() { 00437 size_t r=v.rows(); 00438 size_t c=v.cols(); 00439 if (r>0 && c>0) { 00440 this->data=(data_t *)malloc(2*r*c*sizeof(data_t)); 00441 if (this->data) { 00442 this->size1=v.size1; 00443 this->size2=v.size2; 00444 this->owner=1; 00445 for(size_t i=0;i<r;i++) { 00446 for(size_t j=0;i<c;j++) { 00447 *(this->data+i*this->size2+j)=v[i][j]; 00448 } 00449 } 00450 } else { 00451 O2SCL_ERR("No memory for data in umatrix_cx_tlate constructor", 00452 gsl_enomem); 00453 } 00454 } else { 00455 this->size1=0; 00456 this->size2=0; 00457 } 00458 } 00459 00460 /** \brief Deep copy constructor, if owner is true, allocate space and 00461 make a new copy, otherwise, just copy into the view 00462 */ 00463 umatrix_cx_tlate& operator=(const umatrix_cx_tlate &v) { 00464 00465 // Check for self-assignment 00466 if (this==&v) return *this; 00467 00468 size_t sze=v.size1; 00469 size_t sze2=v.size2; 00470 if (this->owner) { 00471 allocate(sze,sze2); 00472 } else { 00473 if (this->size1!=sze || this->size2!=sze2) { 00474 O2SCL_ERR("Sizes don't match in umatrix_cx_tlate::operator=()", 00475 gsl_ebadlen); 00476 return *this; 00477 } 00478 } 00479 for(size_t i=0;i<sze;i++) { 00480 for(size_t j=0;j<sze2;j++) { 00481 *(this->data+i*this->size2+j)=v[i][j]; 00482 } 00483 } 00484 return *this; 00485 } 00486 00487 /** \brief Deep copy constructor, if owner is true, allocate space and 00488 make a new copy, otherwise, just copy into the view 00489 */ 00490 umatrix_cx_tlate& operator= 00491 (const umatrix_cx_view_tlate<data_t,complex_t> &v) { 00492 00493 // Check for self-assignment 00494 if (this==&v) return *this; 00495 00496 size_t sze=v.rows(); 00497 size_t sze2=v.cols(); 00498 if (this->owner) { 00499 allocate(sze,sze2); 00500 } else { 00501 if (this->size1!=sze || this->size2!=sze2) { 00502 O2SCL_ERR("Sizes don't match in umatrix_cx_tlate::operator=()", 00503 gsl_ebadlen); 00504 return *this; 00505 } 00506 } 00507 for(size_t i=0;i<sze;i++) { 00508 for(size_t j=0;j<sze2;j++) { 00509 *(this->data+i*this->size2+j)=v[i][j]; 00510 } 00511 } 00512 return *this; 00513 } 00514 00515 /** \brief Deep copy from an array of uvectors 00516 */ 00517 umatrix_cx_tlate(size_t n, 00518 uvector_cx_view_tlate<data_t,complex_t> uva[]) { 00519 if (n>0) { 00520 size_t n2=uva[0]; 00521 if (n2>0) { 00522 allocate(n,n2); 00523 for(size_t i=0;i<n;i++) { 00524 for(size_t j=0;j<n2;j++) { 00525 (*this)[i][j]=uva[i][j]; 00526 } 00527 } 00528 } 00529 } 00530 } 00531 00532 /** \brief Deep copy from a C-style 2-d array 00533 */ 00534 umatrix_cx_tlate(size_t n, size_t n2, data_t **csa) { 00535 if (n>0 && n2>0) { 00536 allocate(n,n2); 00537 for(size_t i=0;i<n;i++) { 00538 for(size_t j=0;j<n2;j++) { 00539 (*this)[i][j]=csa[i][j]; 00540 } 00541 } 00542 } 00543 } 00544 00545 //@} 00546 00547 ~umatrix_cx_tlate() { 00548 if (this->size1>0) { 00549 if (this->owner==1) { 00550 std::free(this->data); 00551 this->size1=0; 00552 this->size2=0; 00553 } 00554 } 00555 } 00556 00557 /// \name Memory allocation 00558 //@{ 00559 /** 00560 \brief Allocate memory after freeing any memory presently in use 00561 */ 00562 int allocate(size_t nrows, size_t ncols) { 00563 if (this->size1>0 || this->size2>0) free(); 00564 00565 if (nrows>0 && ncols>0) { 00566 this->data=(data_t *)malloc(2*nrows*ncols*sizeof(data_t)); 00567 if (this->data) { 00568 this->size1=nrows; 00569 this->size2=ncols; 00570 this->owner=1; 00571 } else { 00572 O2SCL_ERR2_RET("No memory for data in ", 00573 "umatrix_cx_tlate::allocate()", 00574 gsl_enomem); 00575 } 00576 } else { 00577 O2SCL_ERR_RET("Zero size in umatrix::allocate()",gsl_einval); 00578 } 00579 return 0; 00580 } 00581 00582 /** 00583 \brief Free the memory 00584 00585 This function will safely do nothing if used without first 00586 allocating memory or if called multiple times in succession. 00587 */ 00588 int free() { 00589 if (this->size1>0) { 00590 if (this->owner==1) { 00591 std::free(this->data); 00592 } 00593 this->size1=0; 00594 this->size2=0; 00595 } 00596 return 0; 00597 } 00598 //@} 00599 00600 /// \name Other methods 00601 //@{ 00602 /// \brief Compute the transpose (even if matrix is not square) 00603 umatrix_cx_tlate<data_t,complex_t> transpose() { 00604 umatrix_cx_tlate<data_t,complex_t> result(this->size2,this->size1); 00605 for(size_t i=0;i<this->size1;i++) { 00606 for(size_t j=0;j<this->size2;j++) { 00607 result[j][i]=(*this)[i][j]; 00608 } 00609 } 00610 } 00611 //@} 00612 00613 }; 00614 00615 /** \brief Create a vector from a row of a matrix 00616 */ 00617 template<class data_t, class complex_t> class umatrix_cx_row_tlate : 00618 public uvector_cx_view_tlate<data_t,complex_t> { 00619 public: 00620 /** \brief Create a vector from row \c i of matrix \c m */ 00621 umatrix_cx_row_tlate(umatrix_cx_view_tlate<data_t,complex_t> &m, 00622 size_t i) { 00623 if (i<m.rows()) { 00624 this->sz=m.cols(); 00625 this->data=m[0]+m.cols()*i; 00626 this->owner=0; 00627 } 00628 } 00629 }; 00630 00631 /** \brief Create a const vector from a row of a matrix 00632 */ 00633 template<class data_t, class complex_t> class umatrix_cx_const_row_tlate : 00634 public uvector_cx_view_tlate<data_t,complex_t> { 00635 public: 00636 /** \brief Create a vector from row \c i of matrix \c m */ 00637 umatrix_cx_const_row_tlate 00638 (const umatrix_cx_view_tlate<data_t,complex_t> &m, 00639 size_t i) { 00640 if (i<m.size1) { 00641 this->sz=m.cols(); 00642 this->data=m[0]+m.cols()*i; 00643 this->owner=0; 00644 } 00645 } 00646 }; 00647 00648 /// umatrix_cx typedef 00649 typedef umatrix_cx_tlate<double,gsl_complex> umatrix_cx; 00650 /// umatrix_cx_view typedef 00651 typedef umatrix_cx_view_tlate<double,gsl_complex> umatrix_cx_view; 00652 /// umatrix_cx_row typedef 00653 typedef umatrix_cx_row_tlate<double,gsl_complex> umatrix_cx_row; 00654 /// umatrix_cx_const_row typedef 00655 typedef umatrix_cx_const_row_tlate<double,gsl_complex> 00656 umatrix_cx_const_row; 00657 00658 /** \brief A operator for naive matrix output 00659 00660 This outputs all of the matrix elements. Each row is output with 00661 an endline character at the end of each row. Positive values are 00662 preceeded by an extra space. A 2x2 example: 00663 \verbatim 00664 -3.751935e-05 -6.785864e-04 00665 -6.785864e-04 1.631984e-02 00666 \endverbatim 00667 00668 The function \c gsl_ieee_double_to_rep() is used to determine 00669 the sign of a number, so that "-0.0" as distinct from "+0.0" 00670 is handled correctly. 00671 00672 \note At the moment, this function assumes that scientific 00673 mode is on and showpos is off. 00674 00675 \future Make this function work even when scientific mode is 00676 not on, either by converting to scientific mode and converting 00677 back, or by leaving scientific mode off and padding with spaces 00678 */ 00679 template<class data_t, class complex_t> std::ostream &operator<< 00680 (std::ostream &os, const umatrix_cx_view_tlate<data_t,complex_t> &v) { 00681 size_t i; 00682 gsl_ieee_double_rep r; 00683 for(i=0;i<v.rows()-1;i++) { 00684 for(size_t j=0;j<v.cols();j++) { 00685 gsl_ieee_double_to_rep(&(v[i][j]), &r); 00686 if (r.sign==1) os << v[i][j] << ' '; 00687 else os << ' ' << v[i][j] << ' '; 00688 } 00689 os << '\n'; 00690 } 00691 i=v.rows()-1; 00692 if (i>0) { 00693 for(size_t j=0;j<v.cols();j++) { 00694 gsl_ieee_double_to_rep(&(v[i][j]), &r); 00695 if (r.sign==1) os << v[i][j] << ' '; 00696 else os << ' ' << v[i][j] << ' '; 00697 } 00698 } 00699 return os; 00700 } 00701 00702 /** \brief A simple class to provide an \c allocate() function 00703 for \ref umatrix_cx 00704 */ 00705 class umatrix_cx_alloc { 00706 public: 00707 /// Allocate \c v for \c i elements 00708 void allocate(umatrix_cx &o, int i, int j) { o.allocate(i,j); } 00709 /// Free memory 00710 void free(umatrix_cx &o) { o.free(); } 00711 }; 00712 00713 /** \brief A matrix where the memory allocation is performed in 00714 the constructor 00715 */ 00716 #ifdef DOXYGENP 00717 template<size_t N, size_t M> class ufmatrix_cx : 00718 public umatrix_cx_tlate<data_t,complex_t> 00719 #else 00720 template<size_t N, size_t M> class ufmatrix_cx : 00721 public umatrix_cx_tlate<double,gsl_complex> 00722 #endif 00723 { 00724 public: 00725 ufmatrix_cx() : umatrix_cx_tlate<double,gsl_complex>(N,M) { 00726 } 00727 }; 00728 00729 00730 #ifndef DOXYGENP 00731 } 00732 #endif 00733 00734 #endif 00735 00736 00737
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page