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

Public Types

typedef vec_integer_class::const_iterator iterator
 
typedef vec_integer_class::const_reverse_iterator reverse_iterator
 
- Public Types inherited from SymEngine::UNonExprPoly< Container, Poly, Cf >
typedef Cf coef_type
 
- Public Types inherited from SymEngine::UPolyBase< Container, Poly >
typedef Container container_type
 

Public Member Functions

void accept (Visitor &v) const override
 
void accept (EvalRealDoubleVisitorFinal &v) const override
 
 GaloisField (const RCP< const Basic > &var, GaloisFieldDict &&dict)
 Constructor of GaloisField class.
 
bool is_canonical (const GaloisFieldDict &dict) const
 
hash_t __hash__ () const override
 
int compare (const Basic &o) const override
 
integer_class eval (const integer_class &x) const override
 
vec_integer_class multieval (const vec_integer_class &v) const
 
iterator begin () const
 
iterator end () const
 
reverse_iterator obegin () const
 
reverse_iterator oend () const
 
integer_class get_coeff (unsigned int x) const override
 
vec_basic get_args () const override
 Returns the list of arguments.
 
const std::vector< integer_class > & get_dict () const
 
int size () const override
 
- Public Member Functions inherited from SymEngine::UIntPolyBase< GaloisFieldDict, GaloisField >
 UIntPolyBase (const RCP< const Basic > &var, GaloisFieldDict &&container)
 
RCP< const Basicas_symbolic () const
 
- Public Member Functions inherited from SymEngine::UNonExprPoly< Container, Poly, Cf >
 UNonExprPoly (const RCP< const Basic > &var, Container &&container)
 
virtual Cf get_coeff (unsigned int i) const =0
 
virtual Cf eval (const Cf &x) const =0
 
std::vector< Cf > multieval (const std::vector< Cf > &v) const
 
int get_degree () const
 
Cf get_lc () const
 
- Public Member Functions inherited from SymEngine::UPolyBase< Container, Poly >
 UPolyBase (const RCP< const Basic > &var, Container &&container)
 
int compare (const Basic &o) const override=0
 
hash_t __hash__ () const override=0
 
virtual int size () const =0
 
bool __eq__ (const Basic &o) const override
 
const RCP< const Basic > & get_var () const
 
const Container & get_poly () const
 
vec_basic get_args () const override
 Returns the list of arguments.
 
- Public Member Functions inherited from SymEngine::Basic
TypeID get_type_code () const
 
 Basic ()
 Constructor.
 
 Basic (const Basic &)=delete
 Delete the copy constructor and assignment.
 
Basicoperator= (const Basic &)=delete
 Assignment operator in continuation with above.
 
 Basic (Basic &&)=delete
 Delete the move constructor and assignment.
 
Basicoperator= (Basic &&)=delete
 Assignment operator in continuation with above.
 
virtual hash_t __hash__ () const =0
 
hash_t hash () const
 
virtual bool __eq__ (const Basic &o) const =0
 Test equality.
 
bool __neq__ (const Basic &o) const
 true if this is not equal to o.
 
int __cmp__ (const Basic &o) const
 Comparison operator.
 
virtual int compare (const Basic &o) const =0
 
std::string __str__ () const
 
std::string dumps () const
 Returns a string of the instance serialized.
 
RCP< const Basicsubs (const map_basic_basic &subs_dict) const
 Substitutes 'subs_dict' into 'self'.
 
RCP< const Basicxreplace (const map_basic_basic &subs_dict) const
 
virtual RCP< const Basicexpand_as_exp () const
 expands the special function in terms of exp function
 
virtual vec_basic get_args () const =0
 Returns the list of arguments.
 
virtual void accept (Visitor &v) const =0
 
virtual void accept (EvalRealDoubleVisitorFinal &v) const =0
 
RCP< const Basicdiff (const RCP< const Symbol > &x, bool cache=true) const
 
- Public Member Functions inherited from SymEngine::EnableRCPFromThis< Basic >
RCP< Basicrcp_from_this ()
 Get RCP<T> pointer to self (it will cast the pointer to T)
 
RCP< const Basicrcp_from_this () const
 Get RCP<const T> pointer to self (it will cast the pointer to const T)
 
RCP< const T2 > rcp_from_this_cast () const
 Get RCP<T2> pointer to self (it will cast the pointer to T2)
 
unsigned int use_count () const
 

Static Public Member Functions

static RCP< const GaloisFieldfrom_dict (const RCP< const Basic > &var, GaloisFieldDict &&d)
 
static RCP< const GaloisFieldfrom_vec (const RCP< const Basic > &var, const std::vector< integer_class > &v, const integer_class &modulo)
 
static RCP< const GaloisFieldfrom_uintpoly (const UIntPoly &a, const integer_class &modulo)
 
- Static Public Member Functions inherited from SymEngine::UNonExprPoly< Container, Poly, Cf >
static RCP< const Poly > from_dict (const RCP< const Basic > &var, std::map< unsigned, Cf > &&d)
 
- Static Public Member Functions inherited from SymEngine::UPolyBase< Container, Poly >
static RCP< const Poly > from_container (const RCP< const Basic > &var, Container &&d)
 
- Static Public Member Functions inherited from SymEngine::Basic
static RCP< const Basicloads (const std::string &)
 Creates an instance of a serialized string.
 

Static Public Attributes

static const TypeID type_code_id = SYMENGINE_GALOISFIELD
 

Additional Inherited Members

- Data Fields inherited from SymEngine::Basic
TypeID type_code_
 

Detailed Description

Definition at line 547 of file fields.h.

Member Typedef Documentation

◆ iterator

typedef vec_integer_class::const_iterator SymEngine::GaloisField::iterator

Definition at line 581 of file fields.h.

◆ reverse_iterator

typedef vec_integer_class::const_reverse_iterator SymEngine::GaloisField::reverse_iterator

Definition at line 582 of file fields.h.

Constructor & Destructor Documentation

◆ GaloisField()

SymEngine::GaloisField::GaloisField ( const RCP< const Basic > &  var,
GaloisFieldDict &&  dict 
)

Constructor of GaloisField class.

Definition at line 10 of file fields.cpp.

11 : UIntPolyBase(var, std::move(dict))
12{
13 SYMENGINE_ASSIGN_TYPEID()
14 SYMENGINE_ASSERT(is_canonical(get_poly()))
15}
bool is_canonical(const GaloisFieldDict &dict) const
Definition: fields.cpp:17
T move(T... args)

Member Function Documentation

◆ __hash__()

hash_t SymEngine::GaloisField::__hash__ ( ) const
overridevirtual
Returns
size of the hash

Implements SymEngine::UPolyBase< Container, Poly >.

Definition at line 28 of file fields.cpp.

29{
30 hash_t seed = SYMENGINE_GALOISFIELD;
31
32 seed += get_var()->hash();
33 for (const auto &it : get_poly().dict_) {
34 hash_t temp = SYMENGINE_GALOISFIELD;
35 hash_combine<hash_t>(temp, mp_get_si(it));
36 seed += temp;
37 }
38 return seed;
39}

◆ accept() [1/2]

void SymEngine::GaloisField::accept ( EvalRealDoubleVisitorFinal v) const
overridevirtual

Implements SymEngine::Basic.

◆ accept() [2/2]

void SymEngine::GaloisField::accept ( Visitor v) const
overridevirtual

Implements SymEngine::Basic.

◆ begin()

iterator SymEngine::GaloisField::begin ( ) const
inline

Definition at line 583 of file fields.h.

584 {
585 return get_poly().dict_.begin();
586 }

◆ compare()

int SymEngine::GaloisField::compare ( const Basic o) const
overridevirtual
Returns
-1,0 or 1 after comparing

Implements SymEngine::UPolyBase< Container, Poly >.

Definition at line 41 of file fields.cpp.

42{
43 const GaloisField &s = down_cast<const GaloisField &>(o);
44
45 if (get_poly().size() != s.get_poly().size())
46 return (get_poly().size() < s.get_poly().size()) ? -1 : 1;
47
48 int cmp = unified_compare(get_var(), s.get_var());
49 if (cmp != 0)
50 return cmp;
51
52 cmp = unified_compare(get_poly().modulo_, s.get_poly().modulo_);
53 if (cmp != 0)
54 return cmp;
55
56 return unified_compare(get_poly().dict_, s.get_poly().dict_);
57}
GaloisField(const RCP< const Basic > &var, GaloisFieldDict &&dict)
Constructor of GaloisField class.
Definition: fields.cpp:10
int unified_compare(const T &a, const T &b)
Definition: dict.h:205

◆ end()

iterator SymEngine::GaloisField::end ( ) const
inline

Definition at line 587 of file fields.h.

588 {
589 return get_poly().dict_.end();
590 }

◆ eval()

integer_class SymEngine::GaloisField::eval ( const integer_class &  x) const
inlineoverride

Definition at line 571 of file fields.h.

572 {
573 return get_poly().gf_eval(x);
574 }

◆ from_dict()

RCP< const GaloisField > SymEngine::GaloisField::from_dict ( const RCP< const Basic > &  var,
GaloisFieldDict &&  d 
)
static

Definition at line 59 of file fields.cpp.

61{
62 return make_rcp<const GaloisField>(var, std::move(d));
63}

◆ from_uintpoly()

RCP< const GaloisField > SymEngine::GaloisField::from_uintpoly ( const UIntPoly a,
const integer_class &  modulo 
)
static

Definition at line 74 of file fields.cpp.

76{
77 GaloisFieldDict wrapper(a.get_poly().get_dict(), modulo);
78 return GaloisField::from_dict(a.get_var(), std::move(wrapper));
79}

◆ from_vec()

RCP< const GaloisField > SymEngine::GaloisField::from_vec ( const RCP< const Basic > &  var,
const std::vector< integer_class > &  v,
const integer_class &  modulo 
)
static

Definition at line 66 of file fields.cpp.

69{
70 return make_rcp<const GaloisField>(var,
71 GaloisFieldDict::from_vec(v, modulo));
72}

◆ get_args()

vec_basic SymEngine::GaloisField::get_args ( ) const
overridevirtual

Returns the list of arguments.

Implements SymEngine::Basic.

Definition at line 81 of file fields.cpp.

82{
83 vec_basic args;
84 if (get_poly().dict_.empty())
85 args.push_back(zero);
86 else {
87 for (unsigned i = 0; i < get_poly().dict_.size(); i++) {
88 if (get_poly().dict_[i] == integer_class(0))
89 continue;
90 if (i == 0) {
91 args.push_back(integer(get_poly().dict_[i]));
92 } else if (i == 1) {
93 if (get_poly().dict_[i] == 1) {
94 args.push_back(get_var());
95 } else {
96 args.push_back(Mul::from_dict(integer(get_poly().dict_[i]),
97 {{get_var(), one}}));
98 }
99 } else {
100 if (get_poly().dict_[i] == 1) {
101 args.push_back(pow(get_var(), integer(i)));
102 } else {
103 args.push_back(Mul::from_dict(integer(get_poly().dict_[i]),
104 {{get_var(), integer(i)}}));
105 }
106 }
107 }
108 }
109 return args;
110}
static RCP< const Basic > from_dict(const RCP< const Number > &coef, map_basic_basic &&d)
Create a Mul from a dict.
Definition: mul.cpp:115
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:197
T pow(T... args)
T push_back(T... args)

◆ get_coeff()

integer_class SymEngine::GaloisField::get_coeff ( unsigned int  x) const
inlineoverridevirtual

Implements SymEngine::UNonExprPoly< Container, Poly, Cf >.

Definition at line 600 of file fields.h.

601 {
602 return get_poly().get_coeff(x);
603 }

◆ get_dict()

const std::vector< integer_class > & SymEngine::GaloisField::get_dict ( ) const
inline

Definition at line 606 of file fields.h.

607 {
608 return get_poly().dict_;
609 }

◆ is_canonical()

bool SymEngine::GaloisField::is_canonical ( const GaloisFieldDict dict) const
Returns
true if canonical

Definition at line 17 of file fields.cpp.

18{
19 // Check if dictionary contains terms with coeffienct 0
20 if (dict.modulo_ <= integer_class(0))
21 return false;
22 if (not dict.empty())
23 if (dict.dict_[dict.dict_.size() - 1] == integer_class(0))
24 return false;
25 return true;
26}

◆ multieval()

vec_integer_class SymEngine::GaloisField::multieval ( const vec_integer_class v) const
inline

Definition at line 576 of file fields.h.

577 {
578 return get_poly().gf_multi_eval(v);
579 }

◆ obegin()

reverse_iterator SymEngine::GaloisField::obegin ( ) const
inline

Definition at line 591 of file fields.h.

592 {
593 return get_poly().dict_.rbegin();
594 }

◆ oend()

reverse_iterator SymEngine::GaloisField::oend ( ) const
inline

Definition at line 595 of file fields.h.

596 {
597 return get_poly().dict_.rend();
598 }

◆ size()

int SymEngine::GaloisField::size ( ) const
inlineoverridevirtual

Implements SymEngine::UPolyBase< Container, Poly >.

Definition at line 611 of file fields.h.

612 {
613 if (get_poly().empty())
614 return 0;
615 return get_degree() + 1;
616 }

Field Documentation

◆ type_code_id

const TypeID SymEngine::GaloisField::type_code_id = SYMENGINE_GALOISFIELD
static

Type_code_id shared by all instances

Definition at line 550 of file fields.h.


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