6 std::cerr <<
"# [MARK] zhematrix::operator()(const long&, const long&)"
11 if( i<0 || j<0 || N<=i || N<=j ){
12 std::cerr <<
"[ERROR] zhematrix::operator()(long, long)" << std::endl
13 <<
"The required component is out of the matrix size."
15 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
31 std::cerr <<
"# [MARK] zhematrix::operator()(const long&, const long&) const"
36 if( i<0 || j<0 || N<=i || N<=j ){
37 std::cerr <<
"[ERROR] zhematrix::operator()(long, long) const" << std::endl
38 <<
"The required component is out of the matrix size."
40 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
47 if(i>=j){
return Darray[j][
i]; }
48 else{
return std::conj(Darray[i][j]); }
58 const std::complex<double>& v)
const
61 std::cerr <<
"# [MARK] zhematrix::set(const long&, const long&, const std::complex<double>&) const"
66 if( i<0 || j<0 || N<=i || N<=j ){
67 std::cerr <<
"[ERROR] zhematrix::set"
68 <<
"(long&, long&, std::complex<double>&) const" << std::endl
69 <<
"The required component is out of the matrix size."
71 <<
"Your input was (" << i <<
"," << j <<
")." << std::endl;
78 if(i>=j){ Darray[j][
i] = v; }
79 else{ Darray[
i][j] = std::conj(v); }
87 inline std::ostream& operator<<(std::ostream& s,
const zhematrix& mat)
90 std::cerr <<
"# [MARK] operator<<(std::ostream&, const zhematrix&)"
94 for(
long i=0; i<mat.N; i++){
95 for(
long j=0; j<mat.N; j++){
96 if(i>j){ s <<
" " << mat(i,j) <<
" "; }
97 else if(i==j){ s <<
" " << std::real(mat(i,i)) <<
" "; }
98 else{ s <<
"{" << std::conj(mat(j,i)) <<
"} "; }
103 if(std::fabs(std::imag(mat(i,i))) > CPPL_EPS){
104 std::cerr <<
"[WARNING] operator<<(std::ostream&, const zhematrix&)"
106 <<
"The " << i <<
"th diagonal component of the zhematrix"
107 <<
"is not a real number." << std::endl;
120 inline void zhematrix::write(
const char* filename)
const
123 std::cerr <<
"# [MARK] zhematrix::write(const char*) const"
127 std::ofstream s(filename, std::ios::trunc);
129 s <<
"zhematrix" <<
" " << N << std::endl;
130 for(
long i=0;
i<N;
i++){
131 for(
long j=0; j<=
i; j++ ){
137 if(std::fabs(std::imag(
operator()(
i,
i))) > CPPL_EPS){
138 std::cerr <<
"[WARNING] zhematrix::write(const char*)" << std::endl
139 <<
"The " <<
i <<
"th diagonal component of the zhematrix"
140 <<
"is not a real number." << std::endl;
149 inline void zhematrix::read(
const char* filename)
152 std::cerr <<
"# [MARK] zhematrix::read(const char*)"
156 std::ifstream s(filename);
158 std::cerr <<
"[ERROR] zhematrix::read(const char*) " << std::endl
159 <<
"The file \"" << filename <<
"\" can not be opened."
166 if(
id !=
"zhematrix" ){
167 std::cerr <<
"[ERROR] zhematrix::read(const char*) " << std::endl
168 <<
"The type name of the file \"" << filename
169 <<
"\" is not zhematrix." << std::endl
170 <<
"Its type name was " <<
id <<
" ." << std::endl;
176 for(
long i=0;
i<N;
i++){
177 for(
long j=0; j<=
i; j++ ){
183 std::cerr <<
"[ERROR] zhematrix::read(const char*) " << std::endl
184 <<
"There is something is wrong with the file \""
185 << filename <<
" ." << std::endl
186 <<
"Most likely, there is not enough data components, "
187 <<
"or a linefeed code or space code is missing "
188 <<
"at the end of the last line." << std::endl;
__zhecomplex operator()(const long &, const long &)
Definition: zhematrix-io.hpp:3
friend _zgematrix i(const zhematrix &)
Definition: zhematrix-calc.hpp:20
Complex Double-precision Hermitian Matrix Class [L-type (UPLO=L) Strage].
Definition: zhematrix.hpp:4
void set(const long &, const long &, const std::complex< double > &) const
Definition: zhematrix-io.hpp:57
void resize(const long &)
Definition: zhematrix-misc.hpp:147
(DO NOT USE) Shaddow Complex-double Class for zhematrix
Definition: __zhecomplex.hpp:3