Go to the documentation of this file.00001
00002
00003 inline comple _zhsmatrix::operator()(const long& i, const long& j) const
00004 {VERBOSE_REPORT;
00005 #ifdef CPPL_DEBUG
00006 if( i<0 || j<0 || n<=i || n<=j ){
00007 ERROR_REPORT;
00008 std::cerr << "The required component is out of the matrix size." << std::endl
00009 << "Your input was (" << i << "," << j << ")." << std::endl;
00010 exit(1);
00011 }
00012 #endif//CPPL_DEBUG
00013
00014
00015 const uint32_t ii(std::max(i,j)), jj(std::min(i,j));
00016 for(std::vector<uint32_t>::const_iterator p=line[ii].begin(); p!=line[ii].end(); p++){
00017 if(data[*p].j==jj){
00018 if( i>j ){ return data[*p].v; }
00019 else{ return std::conj(data[*p].v); }
00020 }
00021 }
00022
00023
00024 return comple(0.0,0.0);
00025 }
00026
00027
00028
00029
00030
00031
00032 inline std::ostream& operator<<(std::ostream& s, const _zhsmatrix& mat)
00033 {VERBOSE_REPORT;
00034 for(long i=0; i<mat.n; i++){
00035 for(long j=0; j<mat.n; j++){
00036 if( i >= j ){
00037 std::vector<uint32_t>::iterator q;
00038 for(q=mat.line[i].begin(); q!=mat.line[i].end(); q++){
00039 if( long(mat.data[*q].j)==j ){ break; }
00040 }
00041 if(q!=mat.line[i].end()){ s << " " << mat.data[*q].v << " "; }
00042 else{ s << " x "; }
00043 }
00044 else{
00045 std::vector<uint32_t>::iterator q;
00046 for(q=mat.line[i].begin(); q!=mat.line[i].end(); q++){
00047 if( long(mat.data[*q].j)==j ){ break; }
00048 }
00049 if(q!=mat.line[i].end()){ s << "{" << mat.data[*q].v << "}"; }
00050 else{ s << "{x}"; }
00051 }
00052 }
00053 s << std::endl;
00054 }
00055
00056 mat.destroy();
00057 return s;
00058 }
00059
00060
00061
00062
00063
00064
00065 inline void _zhsmatrix::write(const char* filename) const
00066 {VERBOSE_REPORT;
00067 std::ofstream ofs(filename, std::ios::trunc);
00068 ofs.setf(std::cout.flags());
00069 ofs.precision(std::cout.precision());
00070 ofs.width(std::cout.width());
00071 ofs.fill(std::cout.fill());
00072
00073 ofs << "#zhsmatrix" << " " << n << std::endl;
00074 for(std::vector<zcomponent>::const_iterator it=data.begin(); it!=data.end(); it++){
00075 ofs << it->i << " " << it->j << " " << it->v << std::endl;
00076 }
00077 ofs.close();
00078 destroy();
00079 }