20 #ifndef _libint2_src_bin_libint_rr_h_ 21 #define _libint2_src_bin_libint_rr_h_ 28 #include <exception.h> 30 #include <smart_ptr.h> 31 #include <polyconstr.h> 32 #include <singl_stack.h> 34 #include <default_params.h> 35 #include <util_types.h> 36 #include <global_macros.h> 44 class ImplicitDimensions;
46 template <
typename V>
class AlgebraicOperator;
51 template <
typename RR>
56 static SafePtr<RRStackBase<RR> > rrstack_;
63 typedef typename parent_type::data_type data_type;
64 typedef typename parent_type::value_type value_type;
82 for(citer_type it=rrs->begin(); it != rrs->end(); it++) {
83 find((*it).second.second);
88 void remove(
const data_type& rr) {
89 parent_type::remove(rr);
93 template <
typename RR>
112 virtual unsigned int num_children()
const =0;
114 virtual SafePtr<DGVertex> rr_child(
unsigned int i)
const =0;
116 virtual SafePtr<DGVertex> rr_target()
const =0;
122 const SafePtr<ExprType>&
rr_expr()
const {
return expr_; }
130 virtual bool is_simple()
const =0;
134 virtual bool invariant_type()
const;
143 size_t size_of_children()
const;
150 const std::string& label()
const;
155 virtual std::string description()
const;
158 virtual void generate_code(
const SafePtr<CodeContext>& context,
159 const SafePtr<ImplicitDimensions>& dims,
160 const std::string& funcname,
161 std::ostream& decl, std::ostream& def);
165 virtual void generate_generic_code(
const SafePtr<CodeContext>& context,
166 const SafePtr<ImplicitDimensions>& dims,
167 const std::string& funcname,
168 std::ostream& decl, std::ostream& def);
171 virtual std::string spfunction_call(
const SafePtr<CodeContext>& context,
172 const SafePtr<ImplicitDimensions>& dims)
const;
175 unsigned int nflops()
const {
return nflops_; }
181 unsigned int nflops_;
182 mutable std::string label_;
183 SafePtr<ExprType> expr_;
185 void add_expr(
const SafePtr<ExprType>& a,
int minus=1);
187 virtual std::string generate_label()
const =0;
194 SafePtr<RR> this_ptr =
195 const_pointer_cast<RR,
const RR>(
197 EnableSafePtrFromThis<RecurrenceRelation>::SafePtr_from_this()
200 rrstack->find(this_ptr);
201 #if DEBUG || DEBUG_CONSTRUCTION 202 std::cout <<
"register_with_rrstack: registered " << this_ptr->label() << std::endl;
210 SafePtr<DirectedGraph> generate_graph_(
const SafePtr<DirectedGraph>& dg);
213 void assign_symbols_(SafePtr<CodeSymbols>& S);
216 virtual SafePtr<ImplicitDimensions> adapt_dims_(
const SafePtr<ImplicitDimensions>& dims)
const;
219 virtual bool has_generic(
const SafePtr<CompilationParameters>& cparams)
const;
221 virtual std::string generic_header()
const;
223 virtual std::string generic_instance(
const SafePtr<CodeContext>& context,
const SafePtr<CodeSymbols>& args)
const;
229 SafePtr<RecurrenceRelation::ExprType> operator+(
const SafePtr<DGVertex>& A,
230 const SafePtr<DGVertex>& B);
231 SafePtr<RecurrenceRelation::ExprType> operator-(
const SafePtr<DGVertex>& A,
232 const SafePtr<DGVertex>& B);
233 SafePtr<RecurrenceRelation::ExprType>
operator*(
const SafePtr<DGVertex>& A,
234 const SafePtr<DGVertex>& B);
235 SafePtr<RecurrenceRelation::ExprType> operator/(
const SafePtr<DGVertex>& A,
236 const SafePtr<DGVertex>& B);
237 const SafePtr<RecurrenceRelation::ExprType>& operator+=(SafePtr<RecurrenceRelation::ExprType>& A,
238 const SafePtr<DGVertex>& B);
239 const SafePtr<RecurrenceRelation::ExprType>& operator-=(SafePtr<RecurrenceRelation::ExprType>& A,
240 const SafePtr<DGVertex>& B);
241 const SafePtr<RecurrenceRelation::ExprType>& operator*=(SafePtr<RecurrenceRelation::ExprType>& A,
242 const SafePtr<DGVertex>& B);
243 const SafePtr<RecurrenceRelation::ExprType>& operator/=(SafePtr<RecurrenceRelation::ExprType>& A,
244 const SafePtr<DGVertex>& B);
252 template<
typename T> SafePtr<RecurrenceRelation::ExprType> operator*(
const SafePtr<
RTimeEntity<T> >& A,
253 const SafePtr<DGVertex>& B);
254 template<
typename T> SafePtr<RecurrenceRelation::ExprType> operator*(
const SafePtr<
CTimeEntity<T> >& A,
255 const SafePtr<DGVertex>& B);
SingletonStack<T,KeyType> helps to implement Singleton-like objects of type T.
Definition: singl_stack.h:42
void add(const SafePtr< RRStackBase< RR > > &rrs)
adds content of rrs to this stack
Definition: rr.h:81
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition: bfset.h:879
const SafePtr< ExprType > & rr_expr() const
Returns the expression.
Definition: rr.h:122
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
Definition: stdarray.h:18
SafePtr< CTimeEntity< typename ProductType< T, U >::result > > operator*(const SafePtr< CTimeEntity< T > > &A, const SafePtr< CTimeEntity< U > > &B)
Creates product A*B.
Definition: entity.h:277
KeyTypes::InstanceID InstanceID
Specifies type for the instance index variables.
Definition: singl_stack.h:48
map_type::iterator iter_type
use iter_type objects to iterate over the stack
Definition: singl_stack.h:52
void inst_id(const SingletonStack< RecurrenceRelation, string >::InstanceID &i)
RecurrenceRelation is managed by SingletonStack but doesn't need to keep track of instance ID...
Definition: rr.h:178
Entity is a base class for all objects that exist at compile or runtime of the generated code...
Definition: entity.h:78
AlgebraicOperator is an algebraic operator that acts on objects of type T.
Definition: algebra.h:47
unsigned int nflops() const
Return the number of FLOPs per this recurrence relation.
Definition: rr.h:175
map_type::const_iterator citer_type
const version of iter_type
Definition: singl_stack.h:54
bool register_with_rrstack()
Registers with the stack.
Definition: rr.h:189
RecurrenceRelation describes all recurrence relations.
Definition: rr.h:100
AlgebraicOperator< DGVertex > ExprType
Numerical expression of a recurrence relation is always expressed as an AlgebraicOperator<DGVertex> ...
Definition: rr.h:120
RRStack implements a stack of RecurrenceRelation's which can only hold one instance of a given RR...
Definition: rr.h:52
virtual int partindex_direction() const
Definition: rr.h:139
static SafePtr< RRStackBase< RR > > & Instance()
Obtain the unique Instance of RRStack.
Definition: rr.h:70