OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opencog::ArithmeticLink Class Referenceabstract

#include <ArithmeticLink.h>

+ Inheritance diagram for opencog::ArithmeticLink:
+ Collaboration diagram for opencog::ArithmeticLink:

Public Member Functions

 ArithmeticLink (const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 ArithmeticLink (Link &l)
 
virtual Handle reorder (void)
 
virtual Handle reduce (void)
 
virtual Handle execute (AtomSpace *as) const
 
- Public Member Functions inherited from opencog::Atom
virtual ~Atom ()
 
Type getType () const
 
bool isType (Type t, bool subclass) const
 
Handle getHandle ()
 
AttentionValuePtr getAttentionValue ()
 
void setAttentionValue (AttentionValuePtr)
 Sets the AttentionValue object of the atom. More...
 
AttentionValue::sti_t getSTI ()
 Handy-dandy convenience getters for attention values. More...
 
AttentionValue::lti_t getLTI ()
 
AttentionValue::vlti_t getVLTI ()
 
void setSTI (AttentionValue::sti_t stiValue)
 
void setLTI (AttentionValue::lti_t ltiValue)
 
void incVLTI ()
 
void decVLTI ()
 
TruthValuePtr getTruthValue ()
 
void setTruthValue (TruthValuePtr)
 Sets the TruthValue object of the atom. More...
 
void merge (TruthValuePtr)
 
Handle tvmerge (TruthValuePtr tv)
 
size_t getIncomingSetSize ()
 Get the size of the incoming set. More...
 
IncomingSet getIncomingSet ()
 
template<typename OutputIterator >
OutputIterator getIncomingSet (OutputIterator result)
 
template<class T >
bool foreach_incoming (bool(T::*cb)(const Handle &), T *data)
 
template<typename OutputIterator >
OutputIterator getIncomingSetByType (OutputIterator result, Type type, bool subclass=false)
 
IncomingSet getIncomingSetByType (Type type, bool subclass=false)
 

Protected Member Functions

virtual double konsd (double, double) const =0
 
void init (void)
 
 ArithmeticLink (Type, const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 ArithmeticLink (Type, const Handle &a, const Handle &b, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
- Protected Member Functions inherited from opencog::Atom
 Atom (Type t, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
void keep_incoming_set ()
 
void drop_incoming_set ()
 
void insert_atom (LinkPtr)
 Add an atom to the incoming set. More...
 
void remove_atom (LinkPtr)
 Remove an atom from the incoming set. More...
 

Protected Attributes

double knild
 
- Protected Attributes inherited from opencog::Atom
UUID _uuid
 
AtomTable_atomTable
 
Type _type
 
char _flags
 
TruthValuePtr _truthValue
 
AttentionValuePtr _attentionValue
 
std::mutex _mtx
 
InSetPtr _incoming_set
 

Additional Inherited Members

- Protected Types inherited from opencog::Atom
typedef std::shared_ptr< InSetInSetPtr
 

Detailed Description

The ArithmeticLink implements the arithmetic operations of plus and times. It uses FoldLink to perform reduction.

Definition at line 39 of file ArithmeticLink.h.

Constructor & Destructor Documentation

ArithmeticLink::ArithmeticLink ( Type  t,
const HandleSeq oset,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)
protected

Definition at line 41 of file ArithmeticLink.cc.

References opencog::classserver(), and init().

ArithmeticLink::ArithmeticLink ( Type  t,
const Handle a,
const Handle b,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)
protected

Definition at line 51 of file ArithmeticLink.cc.

References opencog::classserver(), and init().

ArithmeticLink::ArithmeticLink ( const HandleSeq oset,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)

Definition at line 33 of file ArithmeticLink.cc.

References init().

ArithmeticLink::ArithmeticLink ( Link l)

Definition at line 61 of file ArithmeticLink.cc.

References opencog::classserver(), opencog::Atom::getType(), and init().

Member Function Documentation

void ArithmeticLink::init ( void  )
protected

Definition at line 70 of file ArithmeticLink.cc.

References knild.

+ Here is the caller graph for this function:

virtual double opencog::ArithmeticLink::konsd ( double  ,
double   
) const
protectedpure virtual

Implemented in opencog::PlusLink, and opencog::TimesLink.

+ Here is the caller graph for this function:

Handle ArithmeticLink::reduce ( void  )
virtual

reduce() – reduce the expression by summing constants, etc.

No actual black-box evaluation or execution is performed. Only clearbox reductions are performed.

Examples: the reduct of (PlusLink (NumberNode 2) (NumberNode 2)) is (NumberNode 4) – its just a constant.

The reduct of (PlusLink (VariableNode "$x") (NumberNode 0)) is (VariableNode "$x"), because adding zero to anything yeilds the thing itself.

Reimplemented from opencog::FoldLink.

Definition at line 87 of file ArithmeticLink.cc.

References opencog::ArithmeticLinkCast(), python.stop_go::red, and reorder().

Handle ArithmeticLink::reorder ( void  )
virtual

re-order the contents of an ArithmeticLink into "lexicographic" order.

The goal of the re-ordering is to simplify the reduction code, by placing atoms where they are easily found. For now, this means: first, all of the variables, next, all compound expressions, last, all number nodes We do not currently sort the variables, but maybe we should...? Sorting by variable names would hold consilidate them... The FoldLink::reduce() method already returns expressions that are almost in the correct order.

Definition at line 113 of file ArithmeticLink.cc.

References opencog::Atom::_atomTable, opencog::Link::_outgoing, opencog::AtomSpace::add_atom(), opencog::FunctionLink::factory(), opencog::AtomTable::getAtomSpace(), opencog::Atom::getType(), and python.bindlink::result.

+ Here is the caller graph for this function:

Member Data Documentation

double opencog::ArithmeticLink::knild
protected

Definition at line 42 of file ArithmeticLink.h.


The documentation for this class was generated from the following files: