Macaulay2 Engine
Loading...
Searching...
No Matches

◆ TEST() [2/2]

TEST ( RingTower ,
elems  )

Definition at line 76 of file RingTowerTest.cpp.

77{
78 std::vector<std::string> vars = {"a", "b"};
79 M2_ArrayString varnames = stdvector_to_M2_ArrayString(vars);
80 const Tower* R = Tower::create(101, varnames);
81
82 ring_elem a = R->var(0);
83 ring_elem b = R->var(1);
84
85 buffer o;
86 o << "a=";
87 R->elem_text_out(o, a);
88 o << " b=";
89 R->elem_text_out(o, b);
90 ring_elem c = R->add(a, R->from_long(2));
91 c = R->add(c, b);
92 o << " c=";
93 R->elem_text_out(o, c);
94 ring_elem d = R->power(c, 2);
95 o << " d=";
96 R->elem_text_out(o, d);
97 o << newline;
98
99 std::cout << o.str();
100}
virtual ring_elem power(const ring_elem f, mpz_srcptr n) const
Exponentiation. This is the default function, if a class doesn't define this.
Definition ring.cpp:109
virtual ring_elem from_long(long n) const
Definition tower.cpp:106
static Tower * create(int charac, M2_ArrayString names)
Definition tower.cpp:46
virtual ring_elem var(int v) const
Definition tower.cpp:128
virtual ring_elem add(const ring_elem f, const ring_elem g) const
Definition tower.cpp:187
virtual void elem_text_out(buffer &o, const ring_elem f, bool p_one=true, bool p_plus=false, bool p_parens=false) const
Definition tower.cpp:254
Ring subclass for tower polynomial rings (Z/p)[x_0][x_1]...[x_{n-1}] modulo a chain of algebraic exte...
Definition tower.hpp:59
char * str()
Definition buffer.hpp:72
char newline[]
Definition m2-types.cpp:49
M2_ArrayString stdvector_to_M2_ArrayString(const std::vector< std::string > &strs)
Definition util.hpp:67

References Tower::add(), Tower::create(), Tower::elem_text_out(), Tower::from_long(), newline, Ring::power(), stdvector_to_M2_ArrayString(), buffer::str(), and Tower::var().