inlib
1.2.0
|
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved. 00002 // See the file inlib.license for terms. 00003 00004 #ifndef inlib_sqmz 00005 #define inlib_sqmz 00006 00007 #include "sqm" 00008 00009 #include <complex> 00010 00011 namespace inlib { 00012 00013 template <class T> 00014 inline void conj(array<T>& a_array) { 00015 std::vector<T>& vec = a_array.vector(); 00016 typedef typename std::vector<T>::iterator vec_it_t; 00017 for(vec_it_t it = vec.begin();it!=vec.end();++it) { 00018 (*it) = conj(*it); 00019 } 00020 } 00021 00022 template <class T> 00023 inline void dagger(sqm<T>& a_array) { 00024 conj(a_array); 00025 a_array.transpose(); 00026 } 00027 00028 template <class T> 00029 inline sqm< std::complex<double> > to_complex(const sqm<T>& a_from) { 00030 unsigned int order = a_from.order(); 00031 typedef std::complex<double> z; 00032 sqm<z> to(order); 00033 const std::vector<T>& fvec = a_from.vector(); 00034 std::vector<z>& tvec = to.vector(); 00035 typedef typename std::vector<T>::const_iterator const_vec_it_t; 00036 const_vec_it_t fit = fvec.begin(); 00037 typedef typename std::vector<z>::iterator vec_it_t; 00038 vec_it_t tit = tvec.begin(); 00039 for(;fit!=fvec.end();++fit,++tit) *tit = *fit; 00040 return to; 00041 } 00042 00043 } 00044 00045 #endif