ExaTN
exatn_numerics.hpp
1 
24 #ifndef EXATN_NUMERICS_HPP_
25 #define EXATN_NUMERICS_HPP_
26 
27 #include "num_server.hpp"
28 
29 #include <utility>
30 #include <memory>
31 #include <string>
32 
33 namespace exatn{
34 
36 inline ScopeId openScope(const std::string & scope_name) //new scope name
37  {return numericalServer->openScope(scope_name);}
38 
39 
41 inline ScopeId closeScope()
42  {return numericalServer->closeScope();}
43 
44 
47 inline SpaceId createVectorSpace(const std::string & space_name, //in: vector space name
48  DimExtent space_dim, //in: vector space dimension
49  const VectorSpace ** space_ptr = nullptr) //out: non-owning pointer to the created vector space
50  {return numericalServer->createVectorSpace(space_name,space_dim,space_ptr);}
51 
52 
54 inline void destroyVectorSpace(const std::string & space_name) //in: name of the vector space to destroy
55  {return numericalServer->destroyVectorSpace(space_name);}
56 
57 inline void destroyVectorSpace(SpaceId space_id) //in: id of the vector space to destroy
58  {return numericalServer->destroyVectorSpace(space_id);}
59 
60 
63 inline SubspaceId createSubspace(const std::string & subspace_name, //in: subspace name
64  const std::string & space_name, //in: containing vector space name
65  const std::pair<DimOffset,DimOffset> bounds, //in: range of basis vectors defining the created subspace: [lower:upper]
66  const Subspace ** subspace_ptr = nullptr) //out: non-owning pointer to the created subspace
67  {return numericalServer->createSubspace(subspace_name,space_name,bounds,subspace_ptr);}
68 
69 
71 inline void destroySubspace(const std::string & subspace_name) //in: name of the subspace to destroy
72  {return numericalServer->destroySubspace(subspace_name);}
73 
74 inline void destroySubspace(SubspaceId subspace_id) //in: id of the subspace to destroy
75  {return numericalServer->destroySubspace(subspace_id);}
76 
77 
80 inline const Subspace * getSubspace(const std::string & subspace_name) //in: name of the subspace to get
81  {return numericalServer->getSubspace(subspace_name);}
82 
83 
85 inline void registerTensorMethod(const std::string & tag,
86  std::shared_ptr<TensorMethod> method)
87  {return numericalServer->registerTensorMethod(tag,method);}
88 
89 
91 inline std::shared_ptr<TensorMethod> getTensorMethod(const std::string & tag)
92  {return numericalServer->getTensorMethod(tag);}
93 
94 
96 inline void registerExternalData(const std::string & tag,
97  std::shared_ptr<BytePacket> packet)
98  {return numericalServer->registerExternalData(tag,packet);}
99 
100 
102 inline std::shared_ptr<BytePacket> getExternalData(const std::string & tag)
103  {return numericalServer->getExternalData(tag);}
104 
105 
108 template <typename... Args>
109 inline bool createTensor(const std::string & name, //in: tensor name
110  TensorElementType element_type, //in: tensor element type
111  Args&&... args) //in: other arguments for Tensor ctor
112  {return numericalServer->createTensor(name,element_type,args...);}
113 
114 template <typename... Args>
115 inline bool createTensorSync(const std::string & name, //in: tensor name
116  TensorElementType element_type, //in: tensor element type
117  Args&&... args) //in: other arguments for Tensor ctor
118  {return numericalServer->createTensorSync(name,element_type,args...);}
119 
120 
122 inline Tensor & getTensorRef(const std::string & name) //in: tensor name
123  {return numericalServer->getTensorRef(name);}
124 
125 
127 inline TensorElementType getTensorElementType(const std::string & name) //in: tensor name
128  {return numericalServer->getTensorElementType(name);}
129 
130 
132 inline bool destroyTensor(const std::string & name) //in: tensor name
133  {return numericalServer->destroyTensor(name);}
134 
135 inline bool destroyTensorSync(const std::string & name) //in: tensor name
136  {return numericalServer->destroyTensorSync(name);}
137 
138 
140 template<typename NumericType>
141 inline bool initTensor(const std::string & name, //in: tensor name
142  NumericType value) //in: scalar value
143  {return numericalServer->initTensor(name,value);}
144 
145 template<typename NumericType>
146 inline bool initTensorSync(const std::string & name, //in: tensor name
147  NumericType value) //in: scalar value
148  {return numericalServer->initTensorSync(name,value);}
149 
150 
152 inline bool transformTensor(const std::string & name, //in: tensor name
153  std::shared_ptr<TensorMethod> functor) //in: functor defining tensor transformation
154  {return numericalServer->transformTensor(name,functor);}
155 
156 inline bool transformTensorSync(const std::string & name, //in: tensor name
157  std::shared_ptr<TensorMethod> functor) //in: functor defining tensor transformation
158  {return numericalServer->transformTensorSync(name,functor);}
159 
160 
162 template<typename NumericType>
163 inline bool addTensors(const std::string & addition, //in: symbolic tensor addition specification
164  NumericType alpha) //in: alpha prefactor
165  {return numericalServer->addTensors(addition,alpha);}
166 
167 template<typename NumericType>
168 inline bool addTensorsSync(const std::string & addition, //in: symbolic tensor addition specification
169  NumericType alpha) //in: alpha prefactor
170  {return numericalServer->addTensorsSync(addition,alpha);}
171 
172 
174 template<typename NumericType>
175 inline bool contractTensors(const std::string & contraction, //in: symbolic tensor contraction specification
176  NumericType alpha) //in: alpha prefactor
177  {return numericalServer->contractTensors(contraction,alpha);}
178 
179 template<typename NumericType>
180 inline bool contractTensorsSync(const std::string & contraction, //in: symbolic tensor contraction specification
181  NumericType alpha) //in: alpha prefactor
182  {return numericalServer->contractTensorsSync(contraction,alpha);}
183 
184 
186 inline bool evaluateTensorNetwork(const std::string & name, //in: tensor network name
187  const std::string & network) //in: symbolic tensor network specification
188  {return numericalServer->evaluateTensorNetwork(name,network);}
189 
190 inline bool evaluateTensorNetworkSync(const std::string & name, //in: tensor network name
191  const std::string & network) //in: symbolic tensor network specification
192  {return numericalServer->evaluateTensorNetworkSync(name,network);}
193 
194 
196 inline bool sync(const std::string & name, //in: tensor name
197  bool wait = true) //in: wait versus test for completion
198  {return numericalServer->sync(name,wait);}
199 
200 
204 inline std::shared_ptr<talsh::Tensor> getLocalTensor(std::shared_ptr<Tensor> tensor, //in: exatn::numerics::Tensor to get slice of (by copy)
205  const std::vector<std::pair<DimOffset,DimExtent>> & slice_spec) //in: tensor slice specification
206  {return numericalServer->getLocalTensor(tensor,slice_spec);}
207 
208 inline std::shared_ptr<talsh::Tensor> getLocalTensor(const std::string & name, //in: name of the registered exatn::numerics::Tensor
209  const std::vector<std::pair<DimOffset,DimExtent>> & slice_spec) //in: tensor slice specification
210  {return numericalServer->getLocalTensor(name,slice_spec);}
211 
212 inline std::shared_ptr<talsh::Tensor> getLocalTensor(const std::string & name) //in: name of the registered exatn::numerics::Tensor
213  {return numericalServer->getLocalTensor(name);}
214 
215 
217 inline void resetRuntimeLoggingLevel(int level = 0)
218  {return numericalServer->resetRuntimeLoggingLevel(level);}
219 
220 } //namespace exatn
221 
222 #endif //EXATN_NUMERICS_HPP_
exatn::numerics::Tensor
Definition: tensor.hpp:63
exatn::closeScope
ScopeId closeScope()
Definition: exatn_numerics.hpp:41
exatn::numerics::Subspace
Definition: spaces.hpp:84
exatn::registerExternalData
void registerExternalData(const std::string &tag, std::shared_ptr< BytePacket > packet)
Definition: exatn_numerics.hpp:96
exatn::registerTensorMethod
void registerTensorMethod(const std::string &tag, std::shared_ptr< TensorMethod > method)
Definition: exatn_numerics.hpp:85
exatn::getLocalTensor
std::shared_ptr< talsh::Tensor > getLocalTensor(std::shared_ptr< Tensor > tensor, const std::vector< std::pair< DimOffset, DimExtent >> &slice_spec)
Definition: exatn_numerics.hpp:204
exatn::addTensors
bool addTensors(const std::string &addition, NumericType alpha)
Definition: exatn_numerics.hpp:163
exatn::createTensor
bool createTensor(const std::string &name, TensorElementType element_type, Args &&... args)
Definition: exatn_numerics.hpp:109
exatn::resetRuntimeLoggingLevel
void resetRuntimeLoggingLevel(int level=0)
Definition: exatn_numerics.hpp:217
exatn
Definition: DriverClient.hpp:10
exatn::createSubspace
SubspaceId createSubspace(const std::string &subspace_name, const std::string &space_name, const std::pair< DimOffset, DimOffset > bounds, const Subspace **subspace_ptr=nullptr)
Definition: exatn_numerics.hpp:63
exatn::openScope
ScopeId openScope(const std::string &scope_name)
Definition: exatn_numerics.hpp:36
exatn::numericalServer
std::shared_ptr< NumServer > numericalServer
Definition: num_server.cpp:17
exatn::destroyVectorSpace
void destroyVectorSpace(const std::string &space_name)
Definition: exatn_numerics.hpp:54
exatn::initTensor
bool initTensor(const std::string &name, NumericType value)
Definition: exatn_numerics.hpp:141
exatn::destroySubspace
void destroySubspace(const std::string &subspace_name)
Definition: exatn_numerics.hpp:71
exatn::getTensorRef
Tensor & getTensorRef(const std::string &name)
Definition: exatn_numerics.hpp:122
exatn::sync
bool sync(const std::string &name, bool wait=true)
Definition: exatn_numerics.hpp:196
exatn::getExternalData
std::shared_ptr< BytePacket > getExternalData(const std::string &tag)
Definition: exatn_numerics.hpp:102
exatn::transformTensor
bool transformTensor(const std::string &name, std::shared_ptr< TensorMethod > functor)
Definition: exatn_numerics.hpp:152
exatn::evaluateTensorNetwork
bool evaluateTensorNetwork(const std::string &name, const std::string &network)
Definition: exatn_numerics.hpp:186
exatn::getSubspace
const Subspace * getSubspace(const std::string &subspace_name)
Definition: exatn_numerics.hpp:80
exatn::getTensorMethod
std::shared_ptr< TensorMethod > getTensorMethod(const std::string &tag)
Definition: exatn_numerics.hpp:91
exatn::contractTensors
bool contractTensors(const std::string &contraction, NumericType alpha)
Definition: exatn_numerics.hpp:175
exatn::numerics::VectorSpace
Definition: spaces.hpp:32
exatn::createVectorSpace
SpaceId createVectorSpace(const std::string &space_name, DimExtent space_dim, const VectorSpace **space_ptr=nullptr)
Definition: exatn_numerics.hpp:47
exatn::getTensorElementType
TensorElementType getTensorElementType(const std::string &name)
Definition: exatn_numerics.hpp:127
exatn::destroyTensor
bool destroyTensor(const std::string &name)
Definition: exatn_numerics.hpp:132