mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
cout IO for all types
This commit is contained in:
@ -234,5 +234,60 @@ namespace Grid {
|
||||
typedef vRealF vReal;
|
||||
typedef vComplexF vComplex;
|
||||
#endif
|
||||
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& stream, const vComplexF &o){
|
||||
int nn=vComplexF::Nsimd();
|
||||
std::vector<ComplexF,alignedAllocator<ComplexF> > buf(nn);
|
||||
vstore(o,&buf[0]);
|
||||
stream<<"<";
|
||||
for(int i=0;i<nn;i++){
|
||||
stream<<buf[i];
|
||||
if(i<nn-1) stream<<",";
|
||||
}
|
||||
stream<<">";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& stream, const vComplexD &o){
|
||||
int nn=vComplexD::Nsimd();
|
||||
std::vector<ComplexD,alignedAllocator<ComplexD> > buf(nn);
|
||||
vstore(o,&buf[0]);
|
||||
stream<<"<";
|
||||
for(int i=0;i<nn;i++){
|
||||
stream<<buf[i];
|
||||
if(i<nn-1) stream<<",";
|
||||
}
|
||||
stream<<">";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& stream, const vRealF &o){
|
||||
int nn=vRealF::Nsimd();
|
||||
std::vector<RealF,alignedAllocator<RealF> > buf(nn);
|
||||
vstore(o,&buf[0]);
|
||||
stream<<"<";
|
||||
for(int i=0;i<nn;i++){
|
||||
stream<<buf[i];
|
||||
if(i<nn-1) stream<<",";
|
||||
}
|
||||
stream<<">";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& stream, const vRealD &o){
|
||||
int nn=vRealD::Nsimd();
|
||||
std::vector<RealD,alignedAllocator<RealD> > buf(nn);
|
||||
vstore(o,&buf[0]);
|
||||
stream<<"<";
|
||||
for(int i=0;i<nn;i++){
|
||||
stream<<buf[i];
|
||||
if(i<nn-1) stream<<",";
|
||||
}
|
||||
stream<<">";
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -176,7 +176,27 @@ PARALLEL_FOR_LOOP
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
}; // class Lattice
|
||||
|
||||
template<class vobj> inline std::ostream& operator<< (std::ostream& stream, const Lattice<vobj> &o){
|
||||
std::vector<int> gcoor;
|
||||
typedef typename vobj::scalar_object sobj;
|
||||
sobj ss;
|
||||
for(int g=0;g<o._grid->_gsites;g++){
|
||||
o._grid->GlobalIndexToGlobalCoor(g,gcoor);
|
||||
peekSite(ss,o,gcoor);
|
||||
stream<<"[";
|
||||
for(int d=0;d<gcoor.size();d++){
|
||||
stream<<gcoor[d];
|
||||
if(d!=gcoor.size()-1) stream<<",";
|
||||
}
|
||||
stream<<"]\t";
|
||||
stream<<ss<<std::endl;
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ PARALLEL_FOR_LOOP
|
||||
// Peek a scalar object from the SIMD array
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class vobj,class sobj>
|
||||
void peekSite(sobj &s,Lattice<vobj> &l,std::vector<int> &site){
|
||||
void peekSite(sobj &s,const Lattice<vobj> &l,std::vector<int> &site){
|
||||
|
||||
GridBase *grid=l._grid;
|
||||
|
||||
|
@ -95,6 +95,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& stream, const iScalar<vtype> &o){
|
||||
stream<< "S {"<<o._internal<<"}";
|
||||
return stream;
|
||||
};
|
||||
};
|
||||
///////////////////////////////////////////////////////////
|
||||
// Allows to turn scalar<scalar<scalar<double>>>> back to double.
|
||||
@ -170,6 +174,15 @@ public:
|
||||
inline const vtype & operator ()(int i) const {
|
||||
return _internal[i];
|
||||
}
|
||||
friend std::ostream& operator<< (std::ostream& stream, const iVector<vtype,N> &o){
|
||||
stream<< "V<"<<N<<">{";
|
||||
for(int i=0;i<N;i++) {
|
||||
stream<<o._internal[i];
|
||||
if (i<N-1) stream<<",";
|
||||
}
|
||||
stream<<"}";
|
||||
return stream;
|
||||
};
|
||||
// inline vtype && operator ()(int i) {
|
||||
// return _internal[i];
|
||||
// }
|
||||
@ -262,6 +275,19 @@ public:
|
||||
inline const vtype & operator ()(int i,int j) const {
|
||||
return _internal[i][j];
|
||||
}
|
||||
friend std::ostream& operator<< (std::ostream& stream, const iMatrix<vtype,N> &o){
|
||||
stream<< "M<"<<N<<">{";
|
||||
for(int i=0;i<N;i++) {
|
||||
stream<< "{";
|
||||
for(int j=0;j<N;j++) {
|
||||
stream<<o._internal[i][j];
|
||||
if (i<N-1) stream<<",";
|
||||
}
|
||||
stream<<"}\n\t\t";
|
||||
}
|
||||
stream<<"}";
|
||||
return stream;
|
||||
};
|
||||
|
||||
// inline vtype && operator ()(int i,int j) {
|
||||
// return _internal[i][j];
|
||||
|
Reference in New Issue
Block a user