Loading...
Searching...
No Matches
SymEngine::KroneckerDelta Class Reference
+ Inheritance diagram for SymEngine::KroneckerDelta:
+ Collaboration diagram for SymEngine::KroneckerDelta:

Public Member Functions

virtual void accept (Visitor &v) const
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const
 
 KroneckerDelta (const RCP< const Basic > &i, const RCP< const Basic > &j)
 KroneckerDelta Constructor. More...
 
bool is_canonical (const RCP< const Basic > &i, const RCP< const Basic > &j) const
 
virtual RCP< const Basiccreate (const RCP< const Basic > &a, const RCP< const Basic > &b) const
 
virtual RCP< const Basiccreate (const RCP< const Basic > &a, const RCP< const Basic > &b) const=0
 
RCP< const Basiccreate (const vec_basic &b) const
 
- Public Member Functions inherited from SymEngine::TwoArgBasic< BaseClass >
 TwoArgBasic (const RCP< const Basic > &a, const RCP< const Basic > &b)
 b in TwoArgBasic(a, b) More...
 
hash_t __hash__ () const
 
RCP< const Basicget_arg1 () const
 
RCP< const Basicget_arg2 () const
 
virtual vec_basic get_args () const
 
virtual RCP< const Basiccreate (const RCP< const Basic > &a, const RCP< const Basic > &b) const =0
 Method to construct classes with canonicalization. More...
 
RCP< const Basiccreate (const vec_basic &b) const
 
virtual bool __eq__ (const Basic &o) const
 
virtual int compare (const Basic &o) const
 Structural equality comparator. More...
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_KRONECKERDELTA
 

Detailed Description

Definition at line 986 of file functions.h.

Constructor & Destructor Documentation

◆ KroneckerDelta()

SymEngine::KroneckerDelta::KroneckerDelta ( const RCP< const Basic > &  i,
const RCP< const Basic > &  j 
)

KroneckerDelta Constructor.

Definition at line 2647 of file functions.cpp.

2649 : TwoArgFunction(i, j)
2650{
2651 SYMENGINE_ASSIGN_TYPEID()
2652 SYMENGINE_ASSERT(is_canonical(i, j))
2653}
bool is_canonical(const RCP< const Basic > &i, const RCP< const Basic > &j) const
Definition: functions.cpp:2655

Member Function Documentation

◆ create() [1/3]

RCP< const Basic > SymEngine::KroneckerDelta::create ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
) const
virtual
Returns
canonicalized KroneckerDelta

Implements SymEngine::TwoArgBasic< BaseClass >.

Definition at line 2669 of file functions.cpp.

2671{
2672 return kronecker_delta(a, b);
2673}
RCP< const Basic > kronecker_delta(const RCP< const Basic > &i, const RCP< const Basic > &j)
Canonicalize KroneckerDelta:
Definition: functions.cpp:2675

◆ create() [2/3]

virtual RCP< const Basic > SymEngine::TwoArgBasic< BaseClass >::create ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
) const
virtual

The discrete, or Kronecker, delta function. A function that takes in two integers i and j. It returns 0 if i and j are not equal or it returns 1 if i and j are equal. http://en.wikipedia.org/wiki/Kronecker_delta

Implements SymEngine::TwoArgBasic< BaseClass >.

◆ create() [3/3]

RCP< const Basic > SymEngine::TwoArgBasic< BaseClass >::create ( const vec_basic b) const
inline

The discrete, or Kronecker, delta function. A function that takes in two integers i and j. It returns 0 if i and j are not equal or it returns 1 if i and j are equal. http://en.wikipedia.org/wiki/Kronecker_delta

Definition at line 108 of file functions.h.

109 {
110 SYMENGINE_ASSERT(b.size() == 2);
111 return create(b[0], b[1]);
112 }
virtual RCP< const Basic > create(const RCP< const Basic > &a, const RCP< const Basic > &b) const
Definition: functions.cpp:2669

◆ is_canonical()

bool SymEngine::KroneckerDelta::is_canonical ( const RCP< const Basic > &  i,
const RCP< const Basic > &  j 
) const
Returns
true if canonical

Definition at line 2655 of file functions.cpp.

2657{
2658 RCP<const Basic> diff = expand(sub(i, j));
2659 if (eq(*diff, *zero)) {
2660 return false;
2661 } else if (is_a_Number(*diff)) {
2662 return false;
2663 } else {
2664 // TODO: SymPy uses default key sorting to return in order
2665 return true;
2666 }
2667}
bool is_a_Number(const Basic &b)
Definition: number.h:130
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:495
RCP< const Basic > expand(const RCP< const Basic > &self, bool deep=true)
Expands self
Definition: expand.cpp:369

Field Documentation

◆ type_code_id

const TypeID SymEngine::KroneckerDelta::type_code_id = SYMENGINE_KRONECKERDELTA
static

Type_code_id shared by all instances

Definition at line 996 of file functions.h.


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