mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	Conjugate residual algorithm; some more unary functions
This commit is contained in:
		@@ -123,6 +123,13 @@ public:
 | 
			
		||||
  typedef iScalar<tensor_reduced_v> tensor_reduced;
 | 
			
		||||
  typedef iVector<recurse_scalar_object,N> scalar_object;
 | 
			
		||||
 | 
			
		||||
  template<class T,typename std::enable_if<!isGridTensor<T>::value, T>::type* = nullptr > strong_inline auto operator = (T arg) -> iVector<vtype,N>
 | 
			
		||||
    { 
 | 
			
		||||
      zeroit(*this);
 | 
			
		||||
      for(int i=0;i<N;i++)
 | 
			
		||||
	_internal[i] = arg;
 | 
			
		||||
      return *this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  enum { TensorLevel = GridTypeMapper<vtype>::TensorLevel + 1};
 | 
			
		||||
  iVector(const Zero &z){ *this = zero; };
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										37
									
								
								lib/tensors/Tensor_unary.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lib/tensors/Tensor_unary.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
#ifndef GRID_TENSOR_UNARY_H
 | 
			
		||||
#define GRID_TENSOR_UNARY_H
 | 
			
		||||
namespace Grid {
 | 
			
		||||
 | 
			
		||||
#define UNARY_REAL(func)\
 | 
			
		||||
template<class obj> inline auto func(const iScalar<obj> &z) -> iScalar<obj>\
 | 
			
		||||
{\
 | 
			
		||||
    iScalar<obj> ret;\
 | 
			
		||||
    ret._internal = func( (z._internal));\
 | 
			
		||||
    return ret;\
 | 
			
		||||
}\
 | 
			
		||||
template<class obj,int N> inline auto func(const iVector<obj,N> &z) -> iVector<obj,N>\
 | 
			
		||||
{\
 | 
			
		||||
    iVector<obj,N> ret;\
 | 
			
		||||
    for(int c1=0;c1<N;c1++){\
 | 
			
		||||
      ret._internal[c1] = func( (z._internal[c1]));\
 | 
			
		||||
    }\
 | 
			
		||||
    return ret;\
 | 
			
		||||
}\
 | 
			
		||||
template<class obj,int N> inline auto func(const iMatrix<obj,N> &z) -> iMatrix<obj,N>\
 | 
			
		||||
{\
 | 
			
		||||
    iMatrix<obj,N> ret;\
 | 
			
		||||
    for(int c1=0;c1<N;c1++){\
 | 
			
		||||
    for(int c2=0;c2<N;c2++){\
 | 
			
		||||
      ret._internal[c1][c2] = func( (z._internal[c1][c2]));\
 | 
			
		||||
    }}\
 | 
			
		||||
    return ret;\
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
UNARY_REAL(sqrt);
 | 
			
		||||
UNARY_REAL(rsqrt);
 | 
			
		||||
UNARY_REAL(sin);
 | 
			
		||||
UNARY_REAL(cos);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user