Go to the documentation of this file.00001
00002
00003 inline comple& zrovector::operator()(const long& i)
00004 {VERBOSE_REPORT;
00005 #ifdef CPPL_DEBUG
00006 if( i<0 || l<=i ){
00007 ERROR_REPORT;
00008 std::cerr << "The required component is out of the vector size." << std::endl
00009 << "Your input was (" << i << ")." << std::endl;
00010 exit(1);
00011 }
00012 #endif//CPPL_DEBUG
00013
00014 return array[i];
00015 }
00016
00017
00018
00019 inline comple zrovector::operator()(const long& i) const
00020 {VERBOSE_REPORT;
00021 #ifdef CPPL_DEBUG
00022 if( i<0 || l<=i ){
00023 ERROR_REPORT;
00024 std::cerr << "The required component is out of the vector size." << std::endl
00025 << "Your input was (" << i << ")." << std::endl;
00026 exit(1);
00027 }
00028 #endif//CPPL_DEBUG
00029
00030 return array[i];
00031 }
00032
00033
00034
00035
00036
00037
00038
00039 inline zrovector& zrovector::set(const long& i, const comple& v)
00040 {VERBOSE_REPORT;
00041 #ifdef CPPL_DEBUG
00042 if( i<0 || l<=i ){
00043 ERROR_REPORT;
00044 std::cerr << "The required component is out of the vector size." << std::endl
00045 << "Your input was (" << i << ")." << std::endl;
00046 exit(1);
00047 }
00048 #endif//CPPL_DEBUG
00049
00050 array[i] =v;
00051 return *this;
00052 }
00053
00054
00055
00056
00057
00058
00059 inline std::ostream& operator<<(std::ostream& s, const zrovector& vec)
00060 {VERBOSE_REPORT;
00061 for(long i=0; i<vec.l; i++){ s << " " << vec.array[i]; }
00062 s << std::endl;
00063
00064 return s;
00065 }
00066
00067
00068
00069
00070
00071
00072 inline void zrovector::write(const char* filename) const
00073 {VERBOSE_REPORT;
00074 std::ofstream ofs(filename, std::ios::trunc);
00075 ofs.setf(std::cout.flags());
00076 ofs.precision(std::cout.precision());
00077 ofs.width(std::cout.width());
00078 ofs.fill(std::cout.fill());
00079
00080 ofs << "#zrovector" << " " << l << std::endl;
00081 for(long i=0; i<l; i++){
00082 ofs << operator()(i) << " ";
00083 }
00084 ofs << std::endl;
00085
00086 ofs.close();
00087 }
00088
00089
00090 inline void zrovector::read(const char* filename)
00091 {VERBOSE_REPORT;
00092 std::ifstream s( filename );
00093 if(!s){
00094 ERROR_REPORT;
00095 std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
00096 exit(1);
00097 }
00098
00099 std::string id;
00100 s >> id;
00101 if( id != "zrovector" && id != "#zrovector" ){
00102 ERROR_REPORT;
00103 std::cerr << "The type name of the file \"" << filename << "\" is not zrovector." << std::endl
00104 << "Its type name was " << id << " ." << std::endl;
00105 exit(1);
00106 }
00107
00108 s >> l;
00109 resize(l);
00110 for(long i=0; i<l; i++){
00111 s >> operator()(i);
00112 }
00113 if(s.eof()){
00114 ERROR_REPORT;
00115 std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
00116 << "Most likely, there is not enough data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
00117 exit(1);
00118 }
00119
00120 s >> id;
00121 if(!s.eof()){
00122 ERROR_REPORT;
00123 std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
00124 << "Most likely, there are extra data components." << std::endl;
00125 exit(1);
00126 }
00127
00128
00129 s.close();
00130 }