ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
output.h
Go to the documentation of this file.
1//==========================================================
2// AUTHOR : Lixin He, Mohan Chen
3// DATA : 2006-11 ~ 2008-11
4//==========================================================
5#ifndef OUTPUT_H
6#define OUTPUT_H
7
8#include "../source_base/realarray.h"
9#include "../source_base/matrix3.h"
10#include "../source_base/complexmatrix.h"
11#include "../source_base/matrix.h"
12class output
13{
14public:
15 //============================
16 // Print realArray (3D or 4D)
17 //============================
18 static void printr3_d(std::ofstream &ofs,const std::string &s,const ModuleBase::realArray &u);
19 static void printr4_d(std::ofstream &ofs,const std::string &s,const ModuleBase::realArray &u);
20
21 //===========================
22 // print matrix3
23 //===========================
24 static void printM3(std::ofstream &ofs,const std::string& description, const ModuleBase::Matrix3 &m);
25 static void printM3(const std::string &description, const ModuleBase::Matrix3 &m);
26
27 //===============================
28 // print matrix
29 //===============================
30 static void printrm(std::ofstream &ofs,const std::string &s, const ModuleBase::matrix &m, const double &limit = 1.0e-15);
31 static void printrm(const std::string &s, const ModuleBase::matrix &m, const double &limit = 1.0e-15);
32
33
34 //===============================
35 // print ModuleBase::ComplexMatrix
36 //===============================
37 static void printcm(std::ofstream &ofs,const std::string &s, const ModuleBase::ComplexMatrix &m);
38
39 static void printcm(const std::string &s, const ModuleBase::ComplexMatrix &m);
40
41 static void printcm_real(const std::string &s, const ModuleBase::ComplexMatrix &m,const double &limit = 1.0e-15);
42
43 static void printcm_real_limit_hermit(const std::string &s, const ModuleBase::ComplexMatrix &m,const double &limit);
44
45 static void printcm_imag(const std::string &s, const ModuleBase::ComplexMatrix &m,const double &limit = 1.0e-15);
46 static void printcm_norm(const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit);
47 static void printcm_norm(std::ofstream &ofs, const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit);
48
49
50 //***************
51 // Template
52 //***************
53public:
54
55 template <class T>
56 static void printr1_d(std::ofstream &ofs, const std::string &s,T *u, int n1)
57 {
58 ofs<<"\n\n "<<s<< " n1 = "<< n1;
59 if (n1<=0)return;
60 if (u==0) return;
61 // ofs.setf(ios::scientific,ios::floatfield);
62 for (int i=0;i<n1;i++)
63 {
64 if (i%8==0)ofs<<"\n";
65 ofs<< std::setw(12)<<u[i];
66 }
67 // ofs.unsetf(ios::scientific);
68 }
69
70 //===================================================
71 // print one dimension array (double,int,std::string ...)
72 //===================================================
73 template <class T>
74 static void printr1_d(const std::string &s, T *u,const int n1)
75 {
76 std::cout << "\n " << s << " Dimension = " << n1;
77 if (n1 <= 0)return;
78 if (u == 0) return;
79 //std::cout.setf(ios::scientific, ios::floatfield);
80 for (int i = 0;i < n1;i++)
81 {
82 if (i % 8 == 0) std::cout << "\n";
83 std::cout << std::setw(12) << u[i];
84 }
85 std::cout<<std::endl;
86 //std::cout.unsetf(ios::scientific);
87 }
88
89 //================================
90 // output ModuleBase::Vector3 : printV3
91 // output ModuleBase::Vector3[] : printv31_d
92 //================================
93 template <class T>
94 static void printV3(std::ofstream &ofs, const ModuleBase::Vector3 <T> v)
95 {
96 ofs << " ";
97 ofs << std::setw(18) << v.x << std::setw(18) << v.y << std::setw(18) << v.z << std::endl;
98 }
99
100 template <class T>
101 static void printV3(const ModuleBase::Vector3 <T> v)
102 {
103 std::cout << " ";
104 std::cout << std::setw(18) << v.x << std::setw(18) << v.y << std::setw(18) << v.z << std::endl;
105 }
106
107 template <class T>
108 static void printv31_d(std::ofstream &ofs, const std::string &s, ModuleBase::Vector3<T> *u, int n1)
109 {
110 ofs << " " << s << " Dimension = " << n1 << std::endl;
111 if (n1 <= 0)return;
112 if (u == 0) return;
113 for (int i = 0;i < n1;i++)
114 {
115 printV3(ofs, u[i]);
116 }
117 }
118
119 template <class T>
120 static void printv31_d(const std::string &s, ModuleBase::Vector3<T> *u, int n1)
121 {
122 std::cout << "\n " << s << " dimension = " << n1;
123 if (n1 <= 0)return;
124 if (u == 0) return;
125 for (int i = 0;i < n1;i++)
126 {
127 printV3(u[i]);
128 }
129 }
130
131};
132
133#endif // OUTPUT_H
Definition complexmatrix.h:14
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
3 elements vector
Definition vector3.h:22
T x
Definition vector3.h:24
T y
Definition vector3.h:25
T z
Definition vector3.h:26
Definition matrix.h:19
double float array
Definition realarray.h:21
Definition output.h:13
static void printcm(const std::string &s, const ModuleBase::ComplexMatrix &m)
static void printcm_imag(const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit=1.0e-15)
static void printM3(std::ofstream &ofs, const std::string &description, const ModuleBase::Matrix3 &m)
Definition symmetry_test_analysis.cpp:22
static void printrm(std::ofstream &ofs, const std::string &s, const ModuleBase::matrix &m, const double &limit=1.0e-15)
Definition output.cpp:5
static void printr1_d(const std::string &s, T *u, const int n1)
Definition output.h:74
static void printV3(const ModuleBase::Vector3< T > v)
Definition output.h:101
static void printcm_real_limit_hermit(const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit)
static void printcm(std::ofstream &ofs, const std::string &s, const ModuleBase::ComplexMatrix &m)
static void printr3_d(std::ofstream &ofs, const std::string &s, const ModuleBase::realArray &u)
Definition output.cpp:221
static void printr1_d(std::ofstream &ofs, const std::string &s, T *u, int n1)
Definition output.h:56
static void printcm_norm(std::ofstream &ofs, const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit)
static void printV3(std::ofstream &ofs, const ModuleBase::Vector3< T > v)
Definition output.h:94
static void printv31_d(const std::string &s, ModuleBase::Vector3< T > *u, int n1)
Definition output.h:120
static void printcm_norm(const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit)
static void printcm_real(const std::string &s, const ModuleBase::ComplexMatrix &m, const double &limit=1.0e-15)
static void printr4_d(std::ofstream &ofs, const std::string &s, const ModuleBase::realArray &u)
static void printv31_d(std::ofstream &ofs, const std::string &s, ModuleBase::Vector3< T > *u, int n1)
Definition output.h:108
#define T
Definition exp.cpp:237