mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	function to get tensor dimensions
This commit is contained in:
		@@ -30,6 +30,48 @@ namespace Grid {
 | 
				
			|||||||
    typedef typename std::vector<std::vector<typename TensorToVec<T>::type>> type;
 | 
					    typedef typename std::vector<std::vector<typename TensorToVec<T>::type>> type;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename T>
 | 
				
			||||||
 | 
					  void tensorDim(std::vector<size_t> &dim, const T &t, const bool wipe = true)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (wipe)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      dim.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename T>
 | 
				
			||||||
 | 
					  void tensorDim(std::vector<size_t> &dim, const iScalar<T> &t, const bool wipe = true)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (wipe)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      dim.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    tensorDim(dim, t._internal, false);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename T, int N>
 | 
				
			||||||
 | 
					  void tensorDim(std::vector<size_t> &dim, const iVector<T, N> &t, const bool wipe = true)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (wipe)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      dim.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    dim.push_back(N);
 | 
				
			||||||
 | 
					    tensorDim(dim, t._internal[0], false);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename T, int N>
 | 
				
			||||||
 | 
					  void tensorDim(std::vector<size_t> &dim, const iMatrix<T, N> &t, const bool wipe = true)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (wipe)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      dim.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    dim.push_back(N);
 | 
				
			||||||
 | 
					    dim.push_back(N);
 | 
				
			||||||
 | 
					    tensorDim(dim, t._internal[0][0], false);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  template <typename T>
 | 
					  template <typename T>
 | 
				
			||||||
  typename TensorToVec<T>::type tensorToVec(const T &t)
 | 
					  typename TensorToVec<T>::type tensorToVec(const T &t)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user