3 template<CPPL_INT m, CPPL_INT n>
7 for(CPPL_INT
i=0;
i<m;
i++){
8 for(CPPL_INT j=0; j<n; j++){
9 mat(
i,j) =(*this)(
i,j);
21 template<CPPL_INT m, CPPL_INT n>
25 if( i<0 || j<0 || m<=i || n<=j ){
27 std::cerr <<
"The required component is out of the matrix size." << std::endl
28 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " << m <<
"x" << n <<
"." << std::endl;
38 template<CPPL_INT m, CPPL_INT n>
42 if( i<0 || j<0 || m<=i || n<=j ){
44 std::cerr <<
"The required component is out of the matrix size." << std::endl
45 <<
"Your input is (" << i <<
"," << j <<
"), whereas the matrix size is " << m <<
"x" << n <<
"." << std::endl;
55 template<CPPL_INT m, CPPL_INT n>
64 template<CPPL_INT m, CPPL_INT n>
65 inline std::ostream& operator<<(std::ostream& s, const zgematrix_small<m,n>& A)
67 s << std::setiosflags(std::ios::showpos);
68 for(CPPL_INT
i=0;
i<m;
i++){
69 for(CPPL_INT j=0; j<n; j++){
79 template<CPPL_INT m, CPPL_INT n>
82 std::ofstream ofs(filename, std::ios::trunc);
83 ofs.setf(std::cout.flags());
84 ofs.precision(std::cout.precision());
85 ofs.width(std::cout.width());
86 ofs.fill(std::cout.fill());
87 ofs <<
"#zgematrix" <<
" " << m <<
" " << n << std::endl;
88 for(CPPL_INT
i=0;
i<m;
i++){
89 for(CPPL_INT j=0; j<n; j++){
90 ofs << (*this)(
i,j) <<
" ";
99 template<CPPL_INT m, CPPL_INT n>
101 {CPPL_VERBOSE_REPORT;
102 std::ifstream s( filename );
105 std::cerr <<
"The file \"" << filename <<
"\" can not be opened." << std::endl;
111 if(
id !=
"zgematrix" &&
id !=
"#zgematrix" ){
113 std::cerr <<
"The type name of the file \"" << filename <<
"\" is not zgematrix." << std::endl
114 <<
"Its type name was " <<
id <<
" ." << std::endl;
122 std::cerr <<
"Matrix size is invalid." << std::endl;
125 for(CPPL_INT
i=0;
i<m;
i++){
126 for(CPPL_INT j=0; j<n; j++ ){
127 s >> operator()(
i,j);
132 std::cerr <<
"There is something is wrong with the file \"" << filename <<
"\"." << std::endl
133 <<
"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;
140 std::cerr <<
"There is something is wrong with the file \"" << filename <<
"\"." << std::endl
141 <<
"Most likely, there are extra data components." << std::endl;
157 template<CPPL_INT m, CPPL_INT n>
159 {CPPL_VERBOSE_REPORT;
161 for(CPPL_INT
i=0;
i<m;
i++){
162 for(CPPL_INT j=0; j<n; j++){
171 template<CPPL_INT m, CPPL_INT n>
173 {CPPL_VERBOSE_REPORT;
174 comple
trace =comple(0.,0);
176 const CPPL_INT imax =std::min(m,n);
177 for(CPPL_INT
i=0;
i<imax;
i++){
190 template<CPPL_INT m, CPPL_INT n>
192 {CPPL_VERBOSE_REPORT;
193 for(CPPL_INT k=0; k<m*n; k++){
194 array[k] =comple(0.,0.);
202 template<CPPL_INT m, CPPL_INT n>
204 {CPPL_VERBOSE_REPORT;
207 const CPPL_INT kmax =std::min(m,n);
208 for(CPPL_INT k=0; k<kmax; k++){
217 template<CPPL_INT m, CPPL_INT n>
219 {CPPL_VERBOSE_REPORT;
221 for(CPPL_INT
i=0;
i<m;
i++){
222 vec(
i) =(*this)(
i,j);
229 template<CPPL_INT m, CPPL_INT n>
231 {CPPL_VERBOSE_REPORT;
233 for(CPPL_INT j=0; j<n; j++){
245 template<CPPL_INT m, CPPL_INT n>
247 {CPPL_VERBOSE_REPORT;
248 for(CPPL_INT k=0; k<m*n; k++){
256 template<CPPL_INT m, CPPL_INT n>
258 {CPPL_VERBOSE_REPORT;
259 for(CPPL_INT k=0; k<m*n; k++){
267 template<CPPL_INT m, CPPL_INT l, CPPL_INT n>
269 {CPPL_VERBOSE_REPORT;
272 for(CPPL_INT
i=0;
i<m;
i++){
273 for(CPPL_INT j=0; j<n; j++){
274 for(CPPL_INT k=0; k<l; k++){
275 X(
i,j) += A(
i,k)*B(k,j);
285 template<CPPL_INT m, CPPL_INT n>
287 {CPPL_VERBOSE_REPORT;
288 for(CPPL_INT k=0; k<m*n; k++){
296 template<CPPL_INT m, CPPL_INT n>
298 {CPPL_VERBOSE_REPORT;
299 for(CPPL_INT k=0; k<m*n; k++){
307 template<CPPL_INT m, CPPL_INT n>
309 {CPPL_VERBOSE_REPORT;
310 for(CPPL_INT k=0; k<m*n; k++){
317 template<CPPL_INT m, CPPL_INT n>
319 {CPPL_VERBOSE_REPORT;
320 for(CPPL_INT k=0; k<m*n; k++){
332 template<CPPL_INT m, CPPL_INT n>
334 {CPPL_VERBOSE_REPORT;
340 template<CPPL_INT m, CPPL_INT n>
342 {CPPL_VERBOSE_REPORT;
344 for(CPPL_INT
i=0;
i<m;
i++){
345 for(CPPL_INT j=0; j<n; j++){
358 template<CPPL_INT m, CPPL_INT n>
360 {CPPL_VERBOSE_REPORT;
362 for(
int i=0;
i<m;
i++){
363 for(
int j=0; j<n; j++){
364 C(
i,j) =A(
i,j)+B(
i,j);
374 {CPPL_VERBOSE_REPORT;
376 for(CPPL_INT
i=0;
i<n;
i++){
377 for(CPPL_INT j=0; j<
i; j++){
378 X(i,j) =A(i,j)+B(i,j);
380 for(CPPL_INT j=i; j<n; j++){
381 X(i,j) =A(i,j)+B(j,i);
389 template<CPPL_INT m, CPPL_INT n>
391 {CPPL_VERBOSE_REPORT;
393 for(
int i=0;
i<m;
i++){
394 for(
int j=0; j<n; j++){
395 C(
i,j)=A(
i,j)-B(
i,j);
405 {CPPL_VERBOSE_REPORT;
407 for(CPPL_INT
i=0;
i<n;
i++){
408 for(CPPL_INT j=0; j<=
i; j++){
409 X(
i,j)=A(
i,j)-B(
i,j);
411 for(CPPL_INT j=
i+1; j<n; j++){
412 X(
i,j)=A(
i,j)-B(j,
i);
424 template<CPPL_INT m, CPPL_INT n>
426 {CPPL_VERBOSE_REPORT;
429 for(CPPL_INT
i=0;
i<m;
i++){
430 for(CPPL_INT j=0; j<n; j++){
439 template<CPPL_INT m, CPPL_INT l, CPPL_INT n>
441 {CPPL_VERBOSE_REPORT;
444 for(
int i=0;
i<m;
i++){
445 for(
int j=0; j<n; j++){
446 for(
int k=0; k<l; k++){
447 C(
i,j) +=A(
i,k)*B(k,j);
456 template<CPPL_INT m, CPPL_INT n>
458 {CPPL_VERBOSE_REPORT;
461 for(CPPL_INT
i=0;
i<m;
i++){
462 for(CPPL_INT j=0; j<n; j++){
463 for(CPPL_INT k=0; k<j; k++){
464 X(
i,j) +=A(
i,k)*B(j,k);
466 for(CPPL_INT k=j; k<n; k++){
467 X(
i,j) +=A(
i,k)*B(k,j);
476 template<CPPL_INT m, CPPL_INT n>
478 {CPPL_VERBOSE_REPORT;
480 for(CPPL_INT
i=0;
i<m;
i++){
481 for(CPPL_INT j=0; j<n; j++){
490 template<CPPL_INT m, CPPL_INT n>
492 {CPPL_VERBOSE_REPORT;
494 for(CPPL_INT
i=0;
i<m;
i++){
495 for(CPPL_INT j=0; j<n; j++){
508 template<CPPL_INT m, CPPL_INT n>
510 {CPPL_VERBOSE_REPORT;
512 for(CPPL_INT
i=0;
i<m;
i++){
513 for(CPPL_INT j=0; j<n; j++){
522 template<CPPL_INT m, CPPL_INT n>
524 {CPPL_VERBOSE_REPORT;
526 for(CPPL_INT
i=0;
i<m;
i++){
527 for(CPPL_INT j=0; j<n; j++){
540 template<CPPL_INT m, CPPL_INT n>
542 {CPPL_VERBOSE_REPORT;
544 for(CPPL_INT
i=0;
i<m;
i++){
545 for(CPPL_INT j=0; j<n; j++){
546 C(
i,j) =A(
i,j)*B(
i,j);
556 {CPPL_VERBOSE_REPORT;
558 for(CPPL_INT
i=0;
i<n;
i++){
559 for(CPPL_INT j=0; j<=
i; j++){
560 C(
i,j) =A(
i,j)*B(
i,j);
562 for(CPPL_INT j=
i+1; j<n; j++){
const zgematrix_small< m, n > & operator+(const zgematrix_small< m, n > &A)
void write(const char *filename) const
zgematrix_small< m, n > & operator*=(zgematrix_small< m, l > &A, const zgematrix_small< l, n > &B)
_dgematrix i(const _dgbmatrix &mat)
Samll Complex Double-precision Column Vector Class.
zgematrix_small< m, n > & operator-=(zgematrix_small< m, n > &A, const zgematrix_small< m, n > &B)
zgematrix_small< m, n > & operator+=(zgematrix_small< m, n > &A, const zgematrix_small< m, n > &B)
_zcovector conj(const _zcovector &vec)
Samll Complex Double-precision Row Vector Class.
zcovector_small< l > & zero()
_zgematrix to_zgematrix() const
Complex Double-precision General Dence Matrix Class.
(DO NOT USE) Smart-temporary Complex Double-precision General Dence Matrix Class
zgematrix_small< m, n > & zero()
zgematrix_small< m, n > & identity()
zgematrix_small< m, n > & operator/=(zgematrix_small< m, n > &A, const double &v)
zgematrix_small< m, n > hadamerd(const zgematrix_small< m, n > &A, const zgematrix_small< m, n > &B)
zrovector_small< n > row(const CPPL_INT &i) const
zcovector_small< m > col(const CPPL_INT &j) const
zgematrix_small< n, m > t(const zgematrix_small< m, n > &A)
void read(const char *filename)
zgematrix_small< m, n > & set(const CPPL_INT &i, const CPPL_INT &j, const comple &v)
comple trace(const zgematrix_small< m, n > &A)
zgematrix_small< m, n > operator/(const zgematrix_small< m, n > &A, const double &v)
zgematrix_small< m, n > operator-(const zgematrix_small< m, n > &A)
comple & operator()(const CPPL_INT &i, const CPPL_INT &j)
_dcovector _(dcovector &vec)
zcovector_small< m > operator*(const zgematrix_small< m, n > &A, const zcovector_small< n > &B)
Samll Complex Double-precision General Dence Matrix Class.
Samll Complex Double-precision Symmetric Matrix Class.