21#ifndef _libint2_src_bin_libint_entity_h_
22#define _libint2_src_bin_libint_entity_h_
24#include <class_registry.h>
37namespace EntityTypes {
38typedef enum { fp, integer } EntityTypeEnum;
40template <
unsigned int TypeIndex>
42 static unsigned int type2int() {
return TypeIndex; }
48static const unsigned int ntypes = 2;
52template <
typename T,
typename U>
60 typedef double result;
64 typedef double result;
68 typedef double result;
122 std::ostringstream oss;
123 oss << std::scientific
124 << std::setprecision(std::numeric_limits<T>::digits10 + 1) << x;
136 const std::string&
id()
const {
return id_; }
139 Entity(
const std::string&
id) : id_(
id) {}
160 key_ = KeyTypes::cast(SH.
hash(
id));
162 std::cout <<
"Allocated RTimeEntity id = " << this->
id() << std::endl;
168 std::cout <<
"Deallocated RTimeEntity id = " << this->
id() << std::endl;
173 unsigned int size()
const override {
return 1; }
176 bool equiv(
const std::shared_ptr<DGVertex>& a)
const override {
178#if USE_INT_KEY_TO_COMPARE
179 return key() == a->key() &&
label() == a->label();
181 std::shared_ptr<RTimeEntity> a_cast =
182 std::static_pointer_cast<RTimeEntity, DGVertex>(a);
183 return id() == a_cast->id();
192 const std::string&
id()
const override {
return label(); }
195 std::ostringstream os;
196 os <<
"RTimeEntity: " <<
id();
197 const std::string descr = os.str();
201 typename DGVertex::KeyReturnType
key()
const override {
return key_; }
205 bool this_precomputed()
const override {
return precomputed_; }
227 std::cout <<
"Allocated CTimeEntity id = " << this->
id()
228 <<
" value = " <<
value() << std::endl;
234 std::cout <<
"Deallocated CTimeEntity id = " << this->
id()
235 <<
" value = " <<
value() << std::endl;
240 unsigned int size()
const override {
return 1; }
243 bool equiv(
const std::shared_ptr<DGVertex>& a)
const override {
245#if USE_INT_KEY_TO_COMPARE
246 return key() == a->key();
248 std::shared_ptr<CTimeEntity> a_cast =
249 std::static_pointer_cast<CTimeEntity, DGVertex>(a);
250 return id() == a_cast->id();
259 const std::string&
id()
const override {
return label(); }
262 std::ostringstream os;
263 os <<
"CTimeEntity: " <<
id();
264 const std::string descr = os.str();
269 typename KeyTraits<T>::ReturnType
value()
const {
return value_; }
272 typename DGVertex::KeyReturnType
key()
const override {
273 if (std::is_floating_point<T>::value) {
274 if (not std::is_same<T, double>::value)
275 throw std::runtime_error(
276 "CTimeEntity<Real> only supported when Real==double");
277 return static_cast<typename DGVertex::KeyReturnType
>(
278 *
reinterpret_cast<const unsigned long*
>(&value_));
280 return static_cast<typename DGVertex::KeyReturnType
>(
value());
287 bool this_precomputed()
const override {
return true; }
301template <
typename T,
typename U>
302std::shared_ptr<CTimeEntity<typename ProductType<T, U>::result> >
operator*(
306 return std::shared_ptr<prodtype>(
new prodtype(A->value() * B->value()));
311template <
typename T,
typename U>
312std::shared_ptr<RTimeEntity<typename ProductType<T, U>::result> >
operator*(
316 std::ostringstream oss;
317 oss << A->
id() <<
"*" << B->id();
320 const bool not_precomputed =
true;
321 return std::shared_ptr<prodtype>(
new prodtype(oss.str(), not_precomputed));
328 template <
typename T,
typename U>
329 std::shared_ptr< RTimeEntity< typename ProductType<T,U>::result > >
CTimeEntity is an Entity of type T that exists at compile-time of the generated code (hence has a val...
Definition entity.h:220
bool equiv(const std::shared_ptr< DGVertex > &a) const override
Implementation of DGVertex::equiv()
Definition entity.h:243
DGVertex::KeyReturnType key() const override
Implements Hashable::key()
Definition entity.h:272
std::string description() const override
Implementation of DGVertex::description()
Definition entity.h:261
const std::string & id() const override
Implementation of DGVertex::id()
Definition entity.h:259
const std::string & label() const override
Implementation of DGVertex::label()
Definition entity.h:257
unsigned int size() const override
Implementation of DGVertex::size()
Definition entity.h:240
KeyTraits< T >::ReturnType value() const
returns the value
Definition entity.h:269
Objects of this type provide limited information about the class at runtime.
Definition class_registry.h:46
This is a vertex of a Directed Graph (DG)
Definition dgvertex.h:44
ClassID typeid_
typeid stores the ClassID of the concrete type.
Definition dgvertex.h:71
KeyTypes::InstanceID KeyType
DGVertex provides function key() which computes key of type KeyType and returns it using KeyReturnTyp...
Definition dgvertex.h:63
DGVertex(ClassID tid)
Sets typeid to tid.
Definition dgvertex.cc:32
Entity is a base class for all objects that exist at compile or runtime of the generated code.
Definition entity.h:132
const std::string & id() const
Return id string.
Definition entity.h:136
FNVStringHash uses Fowler/Noll/Vo algorithm to hash a char string to a 64-bit integer.
Definition hashable.h:94
LIBINT2_UINT_LEAST64 hash(const std::string &S)
Returns 64-bit integer hash of S.
Definition hashable.h:116
RTimeEntity is an Entity of type T that exists at runtime of the generated code (hence has no value k...
Definition entity.h:151
const std::string & id() const override
Implementation of DGVertex::id()
Definition entity.h:192
bool equiv(const std::shared_ptr< DGVertex > &a) const override
Implementation of DGVertex::equiv()
Definition entity.h:176
DGVertex::KeyReturnType key() const override
Implements Hashable::key()
Definition entity.h:201
unsigned int size() const override
Implementation of DGVertex::size()
Definition entity.h:173
const std::string & label() const override
Implementation of DGVertex::label()
Definition entity.h:190
std::string description() const override
Implementation of DGVertex::description()
Definition entity.h:194
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
std::string to_string(const T &x)
Converts x to its string representation.
Definition entity.h:121
std::shared_ptr< CTimeEntity< typename ProductType< T, U >::result > > operator*(const std::shared_ptr< CTimeEntity< T > > &A, const std::shared_ptr< CTimeEntity< U > > &B)
Creates product A*B.
Definition entity.h:302
Product of 2 types.
Definition entity.h:53