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 dgematrix_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 <<
"#dgematrix" <<
" " << 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 !=
"dgematrix" &&
id !=
"#dgematrix" ){
113 std::cerr <<
"The type name of the file \"" << filename <<
"\" is not dgematrix." << 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;
176 const CPPL_INT imax =std::min(m,n);
177 for(CPPL_INT
i=0;
i<imax;
i++){
186 template<CPPL_INT m, CPPL_INT n>
188 {CPPL_VERBOSE_REPORT;
190 for(CPPL_INT
i=0;
i<m;
i++){
191 for(CPPL_INT j=0; j<n; j++){
192 if( max<fabs(A(
i,j)) ){
204 template<CPPL_INT m, CPPL_INT n>
206 {CPPL_VERBOSE_REPORT;
218 template<CPPL_INT m, CPPL_INT n>
220 {CPPL_VERBOSE_REPORT;
221 for(CPPL_INT k=0; k<m*n; k++){ array[k]=0.; }
227 template<CPPL_INT m, CPPL_INT n>
229 {CPPL_VERBOSE_REPORT;
232 const CPPL_INT kmax =std::min(m,n);
233 for(CPPL_INT k=0; k<kmax; k++){
242 template<CPPL_INT m, CPPL_INT n>
244 {CPPL_VERBOSE_REPORT;
246 for(CPPL_INT
i=0;
i<m;
i++){ vec(
i)=(*this)(
i,j); }
252 template<CPPL_INT m, CPPL_INT n>
254 {CPPL_VERBOSE_REPORT;
256 for(CPPL_INT j=0; j<n; j++){ vec(j)=(*this)(
i,j); }
266 template<CPPL_INT m, CPPL_INT n>
268 {CPPL_VERBOSE_REPORT;
269 for(CPPL_INT k=0; k<m*n; k++){
277 template<CPPL_INT m, CPPL_INT n>
279 {CPPL_VERBOSE_REPORT;
280 for(CPPL_INT k=0; k<m*n; k++){
288 template<CPPL_INT m, CPPL_INT l, CPPL_INT n>
290 {CPPL_VERBOSE_REPORT;
293 for(CPPL_INT
i=0;
i<m;
i++){
294 for(CPPL_INT j=0; j<n; j++){
295 for(CPPL_INT k=0; k<l; k++){
296 X(
i,j) += A(
i,k)*B(k,j);
306 template<CPPL_INT m, CPPL_INT n>
308 {CPPL_VERBOSE_REPORT;
309 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++){ X(
i,j)=A(
i,j)-B(
i,j); }
409 for(CPPL_INT j=
i+1; j<n; j++){ X(
i,j)=A(
i,j)-B(j,
i); }
416 template<CPPL_INT m, CPPL_INT n>
418 {CPPL_VERBOSE_REPORT;
421 for(CPPL_INT
i=0;
i<m;
i++){
422 for(CPPL_INT j=0; j<n; j++){
431 template<CPPL_INT m, CPPL_INT l, CPPL_INT n>
433 {CPPL_VERBOSE_REPORT;
436 for(
int i=0;
i<m;
i++){
437 for(
int j=0; j<n; j++){
438 for(
int k=0; k<l; k++){
439 C(
i,j) +=A(
i,k)*B(k,j);
448 template<CPPL_INT m, CPPL_INT n>
450 {CPPL_VERBOSE_REPORT;
453 for(CPPL_INT
i=0;
i<m;
i++){
454 for(CPPL_INT j=0; j<n; j++){
455 for(CPPL_INT k=0; k<j; k++){ X(
i,j)+=A(
i,k)*B(j,k); }
456 for(CPPL_INT k=j; k<n; k++){ X(
i,j)+=A(
i,k)*B(k,j); }
464 template<CPPL_INT m, CPPL_INT n>
466 {CPPL_VERBOSE_REPORT;
468 for(CPPL_INT
i=0;
i<m;
i++){
469 for(CPPL_INT j=0; j<n; j++){
478 template<CPPL_INT m, CPPL_INT n>
480 {CPPL_VERBOSE_REPORT;
482 for(CPPL_INT
i=0;
i<m;
i++){
483 for(CPPL_INT j=0; j<n; j++){
496 template<CPPL_INT m, CPPL_INT n>
498 {CPPL_VERBOSE_REPORT;
500 for(CPPL_INT
i=0;
i<m;
i++){
501 for(CPPL_INT j=0; j<n; j++){
502 C(
i,j) =A(
i,j)*B(
i,j);
512 {CPPL_VERBOSE_REPORT;
514 for(CPPL_INT
i=0;
i<n;
i++){
515 for(CPPL_INT j=0; j<=
i; j++){
516 C(
i,j) =A(
i,j)*B(
i,j);
518 for(CPPL_INT j=
i+1; j<n; j++){
519 C(
i,j) =A(
i,j)*B(j,
i);
dcovector_small< m > operator*(const dgematrix_small< m, n > &A, const dcovector_small< n > &B)
void write(const char *filename) const
dgematrix_small< m, n > & identity()
dgematrix_small< m, n > & set(const CPPL_INT &i, const CPPL_INT &j, const double &v)
double & operator()(const CPPL_INT &i, const CPPL_INT &j)
dcovector_small< l > & zero()
Samll Real Double-precision Symmetric Matrix Class.
void read(const char *filename)
Samll Real Double-precision General Dence Matrix Class.
_dgematrix i(const _dgbmatrix &mat)
dgematrix_small< m, n > & zero()
dgematrix_small< m, n > & operator*=(dgematrix_small< m, l > &A, const dgematrix_small< l, n > &B)
Real Double-precision General Dence Matrix Class.
dgematrix_small< m, n > operator-(const dgematrix_small< m, n > &A)
Samll Real Double-precision Row Vector Class.
dgematrix_small< m, n > & operator-=(dgematrix_small< m, n > &A, const dgematrix_small< m, n > &B)
const dgematrix_small< m, n > & operator+(const dgematrix_small< m, n > &A)
dcovector_small< m > col(const CPPL_INT &j) const
dgematrix_small< m, n > & operator+=(dgematrix_small< m, n > &A, const dgematrix_small< m, n > &B)
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
dgematrix_small< m, n > & operator/=(dgematrix_small< m, n > &A, const double &d)
double damax(const dgematrix_small< m, n > &A)
dgematrix_small< m, n > operator/(const dgematrix_small< m, n > &A, const double &v)
double trace(const dgematrix_small< m, n > &A)
void idamax(CPPL_INT &I, CPPL_INT &J, const dgematrix_small< m, n > &A)
Samll Real Double-precision Column Vector Class.
dgematrix_small< n, m > t(const dgematrix_small< m, n > &A)
double array[m *n]
1D array to store vector data
drovector_small< n > row(const CPPL_INT &i) const
_dcovector _(dcovector &vec)
_dgematrix to_dgematrix() const
dgematrix_small< m, n > hadamard(const dgematrix_small< m, n > &A, const dgematrix_small< m, n > &B)