Macaulay2 Engine
Loading...
Searching...
No Matches
aring-wrap.hpp
Go to the documentation of this file.
1// Copyright 2011 Michael E. Stillman
2
3#ifndef _aring_wrap_hpp_
4#define _aring_wrap_hpp_
5
33
34#include "aring.hpp"
35
36namespace M2 {
37
41template <class RingType>
42class RElementWrap : public RElement
43{
44 friend bool ARing::converter(const ARing *sourceR,
45 const ARing *targetR,
46 const RElement &a,
47 RElement &b);
48
49 public:
50 typedef typename RingType::ElementType element_type;
53 RElementWrap(const element_type &a) : val_(a) {}
55 : val_(static_cast<const RElementWrap &>(a).val_)
56 {
57 }
58
59 private:
60 friend class AConcreteRing<RingType>;
62};
63
67template <class RingType> // RingType should inherit from RingInterface
68class AConcreteRing : public ARing
69{
70 friend bool ARing::converter(const ARing *sourceR,
71 const ARing *targetR,
72 const RElement &a,
73 RElement &b);
74
75 public:
76 typedef typename RingType::ElementType element_type;
78
80 AConcreteRing(RingType R) : R_(R) {}
81 virtual RingID getRingID() const { return RingType::ringID; }
82 RingType &getInternalRing() { return R_; }
83 const RingType &getInternalRing() const { return R_; }
84 virtual void init_set(RElement &a, long val) const
85 {
86 R_.init_set(RELEM(RingType, a), val);
87 }
88
89 virtual void add_to(RElement &a, const RElement &b) const
90 {
91 R_.add_to(RELEM(RingType, a), constRELEM(RingType, b));
92 }
93
94 private:
95 RingType R_;
96};
97};
98
99#endif
100
101// Local Variables:
102// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
103// indent-tabs-mode: nil
104// End:
Shared base of the aring framework (namespace M2) that unifies the engine's coefficient rings.
RingType::ElementType element_type
RElementWrap< RingType > ringelem_type
RingType & getInternalRing()
virtual void add_to(RElement &a, const RElement &b) const
friend bool ARing::converter(const ARing *sourceR, const ARing *targetR, const RElement &a, RElement &b)
AConcreteRing(RingType R)
virtual RingID getRingID() const
virtual void init_set(RElement &a, long val) const
const RingType & getInternalRing() const
element_type val_
friend bool ARing::converter(const ARing *sourceR, const ARing *targetR, const RElement &a, RElement &b)
RElementWrap(const element_type &a)
RingType::ElementType element_type
RingID
Definition aring.hpp:75
Definition aring-CC.cpp:3