Frobby  0.9.5
LibIrreducibleDecomTest.cpp
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2009 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #include "stdinc.h"
18 
19 #include "frobby.h"
20 #include "tests.h"
21 #include "IdealFactory.h"
22 #include "LibTest.h"
23 #include "BigIdeal.h"
24 
25 #include <vector>
26 
27 TEST_SUITE2(LibraryInterface, IrreducibleDecom)
28 
29 TEST(IrreducibleDecom, TypicalEncoded) {
32 
33  bool returnValue =
35 
36  ASSERT_TRUE(returnValue);
38  ASSERT_TRUE(consumer.hasAnyOutput());
39 }
40 
41 TEST(IrreducibleDecom, Typical) {
44 
46 
48 }
49 
50 TEST(IrreducibleDecom, ZeroIdealEncoded) {
51  for (size_t varCount = 0; varCount <= 3; ++varCount) {
52  Frobby::Ideal frobbyInputIdeal(varCount);
53  LibIdealConsumer consumer((VarNames(varCount)));
54 
55  bool returnValue =
56  Frobby::irreducibleDecompositionAsMonomials(frobbyInputIdeal, consumer);
57 
58  ASSERT_FALSE(returnValue);
59  ASSERT_FALSE(consumer.hasAnyOutput());
60  }
61 }
62 
63 TEST(IrreducibleDecom, ZeroIdeal) {
64  for (size_t varCount = 0; varCount <= 3; ++varCount) {
65  Frobby::Ideal frobbyInputIdeal(varCount);
66  LibIdealsConsumer consumer((VarNames(varCount)));
67 
68  Frobby::irreducibleDecompositionAsIdeals(frobbyInputIdeal, consumer);
69 
70  vector<BigIdeal> ideals;
71  ideals.push_back(IdealFactory::zeroIdeal(varCount));
72  ASSERT_EQ(consumer.getIdeals(), ideals);
73  }
74 }
75 
76 TEST(IrreducibleDecom, WholeRingEncoded) {
77  for (size_t varCount = 0; varCount <= 3; ++varCount) {
79  LibIdealConsumer consumer((VarNames(varCount)));
80 
81  bool returnValue =
83 
84  ASSERT_TRUE(returnValue);
85  ASSERT_TRUE(consumer.hasAnyOutput());
86  ASSERT_EQ(consumer.getIdeal(), IdealFactory::zeroIdeal(varCount));
87  }
88 }
89 
90 TEST(IrreducibleDecom, WholeRing) {
91  for (size_t varCount = 0; varCount <= 3; ++varCount) {
93  LibIdealsConsumer consumer((VarNames(varCount)));
94 
96 
97  ASSERT_EQ(consumer.getIdeals(), vector<BigIdeal>());
98  }
99 }
TEST(IrreducibleDecom, TypicalEncoded)
Frobby::Ideal toLibIdeal(const BigIdeal &ideal)
Returns a library interface ideal that corresponds to the parameter ideal.
Definition: LibTest.cpp:26
#define ASSERT_TRUE(VALUE)
Definition: asserts.h:72
#define ASSERT_EQ(A, B)
Definition: asserts.h:147
#define ASSERT_FALSE(VALUE)
Definition: asserts.h:119
static BigIdeal xy_xxyyz()
Returns .
static BigIdeal xx_yy_xz_yz()
Returns .
static VarNames ring_xyzt()
Returns the ring in the four variables , , and .
static vector< BigIdeal > irrdecom_xx_yy_xz_yz()
Returns the irreducible decomposition of .
static BigIdeal zeroIdeal(size_t varCount)
Returns the ideal in the ring VarNames(varCount).
static BigIdeal wholeRing(size_t varCount)
Returns in the ring VarNames(varCount).
Records library interface output into a BigIdeal.
Definition: LibTest.h:39
const BigIdeal & getIdeal() const
Returns the recorded ideal in a canonical form.
Definition: LibTest.cpp:66
bool hasAnyOutput() const
Returns whether any ideal has been recorded.
Definition: LibTest.cpp:71
Records library interface output into a vector of BigIdeals.
Definition: LibTest.h:58
const vector< BigIdeal > & getIdeals() const
Returns the recorded ideals in a canonical form.
Definition: LibTest.cpp:91
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
#define TEST_SUITE2(PARENT, SUITE)
Definition: macroes.h:28
void irreducibleDecompositionAsIdeals(const Ideal &ideal, IdealConsumer &consumer)
Compute the irreducible decomposition of ideal.
Definition: frobby.cpp:371
bool irreducibleDecompositionAsMonomials(const Ideal &ideal, IdealConsumer &consumer)
Compute the irreducible decomposition of ideal, and encode each irreducible component as a monomial.
Definition: frobby.cpp:381