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

◆ TEST() [10/10]

TEST ( ResMonoidSparse ,
mult  )

Definition at line 176 of file ResTest.cpp.

177{
178 ResMonoidSparse M(4,
179 std::vector<int>{1, 1, 1, 1},
180 std::vector<int>{},
182
183 int exp1[]{0, 0, 0, 0};
184 int exp2[]{0, 1, 0, 3};
185 int exp3[]{0, 0, 0, 0};
186 int mon1[]{0, 0, 0, 0, 0, 0};
187 int mon2[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
188 int mon3[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
189 int mon[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
190 int comp;
191 M.from_expvector(exp1, 0, mon1);
192 M.from_expvector(exp2, 0, mon2);
193 M.mult(mon1, mon2, mon);
194 M.to_expvector(mon, exp3, comp);
195 EXPECT_EQ(3, M.monomial_size(mon1));
196 EXPECT_EQ(7, M.monomial_size(mon2));
197 EXPECT_EQ(7, M.monomial_size(mon));
198
199 for (int i = 0; i < M.n_vars(); i++)
200 for (int j = i; j < M.n_vars(); j++)
201 for (int k = 0; k < M.n_vars(); k++)
202 {
203 int exp1[]{0, 0, 0, 0};
204 exp1[i]++;
205 exp1[j]++;
206 int exp2[]{0, 0, 0, 0};
207 exp2[k]++;
208 M.from_expvector(exp1, 0, mon1);
209 M.from_expvector(exp2, 0, mon2);
210 M.mult(mon1, mon2, mon);
211 M.mult(mon1, mon2, mon3);
212 EXPECT_TRUE(M.is_equal(mon, mon3));
213 M.to_expvector(mon, exp3, comp);
214 int exp3a[]{0, 0, 0, 0};
215 exp3a[i]++;
216 exp3a[j]++;
217 exp3a[k]++;
218 for (int ell = 0; ell < M.n_vars(); ell++)
219 EXPECT_EQ(exp3[ell], exp3a[ell]);
220 EXPECT_EQ(M.monomial_size(mon),
221 M.monomial_size(mon1) + M.monomial_size(mon2) - 3);
222 }
223}
Sparse / varpower-format ResMonoid implementation: monomials laid out as length-prefixed lists of (va...
const mpreal exp2(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2299

References GRevLex.