LibStdProgramTest.cpp
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#include "stdinc.h"
#include "frobby.h"
#include "tests.h"
#include "BigIdeal.h"
#include "IdealFactory.h"
#include "LibTest.h"
TEST_SUITE2(LibraryInterface, StandardProgram)
TEST(StandardProgram, TypicalNonNegative) {
vector<mpz_class> grading(4);
grading[0] = 0;
grading[1] = 100;
grading[2] = 10000;
grading[3] = "1000000000000000000000000000000000000";
Frobby::Ideal ideal = toLibIdeal(IdealFactory::xx_yy_zz_t_xz_yz());
LibIdealConsumer consumer(IdealFactory::ring_xyzt());
bool returnValue =
Frobby::solveStandardMonomialProgram
(ideal, castLibArray(grading), consumer);
ASSERT_TRUE(returnValue);
ASSERT_EQ(consumer.getIdeal(), IdealFactory::z());
}
TEST(StandardProgram, TypicalNegative) {
vector<mpz_class> grading(4);
grading[0] = 0;
grading[1] = 100;
grading[2] = -10000;
grading[3] = "1000000000000000000000000000000000000";
Frobby::Ideal ideal = toLibIdeal(IdealFactory::xx_yy_zz_t_xz_yz());
LibIdealConsumer consumer(IdealFactory::ring_xyzt());
bool returnValue =
Frobby::solveStandardMonomialProgram(ideal, castLibArray(grading), consumer);
ASSERT_TRUE(returnValue);
ASSERT_EQ(consumer.getIdeal(), IdealFactory::xy());
}
TEST(StandardProgram, ZeroIdeal) {
vector<mpz_class> grading(3);
grading[0] = 0;
grading[1] = 100;
grading[2] = -10000;
for (size_t varCount = 0; varCount <= 3; ++varCount) {
Frobby::Ideal ideal(varCount);
LibIdealConsumer consumer((VarNames(varCount)));
bool returnValue =
Frobby::solveStandardMonomialProgram
(ideal, castLibArray(grading), consumer);
if (varCount == 0) {
ASSERT_TRUE(returnValue);
ASSERT_EQ(consumer.getIdeal(), IdealFactory::wholeRing(varCount));
} else {
ASSERT_FALSE(returnValue);
ASSERT_EQ(consumer.getIdeal(), IdealFactory::zeroIdeal(varCount));
}
}
}
TEST(StandardProgram, WholeRing) {
vector<mpz_class> grading(3);
grading[0] = 0;
grading[1] = 100;
grading[2] = -10000;
for (size_t varCount = 0; varCount <= 3; ++varCount) {
Frobby::Ideal ideal = toLibIdeal(IdealFactory::wholeRing(varCount));
LibIdealConsumer consumer((VarNames(varCount)));
bool returnValue =
Frobby::solveStandardMonomialProgram
(ideal, castLibArray(grading), consumer);
ASSERT_FALSE(returnValue);
ASSERT_EQ(consumer.getIdeal(), IdealFactory::zeroIdeal(varCount));
}
}
BigIdeal.h
IdealFactory.h
castLibArray
const mpz_t * castLibArray(const vector< mpz_class > &vect)
Returns a pointer to an array of mpt_t that represents the entries in the mpz_class.
Definition LibTest.cpp:41
toLibIdeal
Frobby::Ideal toLibIdeal(const BigIdeal &ideal)
Returns a library interface ideal that corresponds to the parameter ideal.
Definition LibTest.cpp:26
LibTest.h
ASSERT_TRUE
#define ASSERT_TRUE(VALUE)
Definition asserts.h:77
ASSERT_EQ
#define ASSERT_EQ(A, B)
Definition asserts.h:152
ASSERT_FALSE
#define ASSERT_FALSE(VALUE)
Definition asserts.h:124
Frobby::Ideal
Definition frobby.h:35
IdealFactory::z
static BigIdeal z()
Returns .
Definition IdealFactory.cpp:126
IdealFactory::ring_xyzt
static VarNames ring_xyzt()
Returns the ring in the four variables , , and .
Definition IdealFactory.cpp:22
IdealFactory::xy
static BigIdeal xy()
Returns .
Definition IdealFactory.cpp:119
IdealFactory::xx_yy_zz_t_xz_yz
static BigIdeal xx_yy_zz_t_xz_yz()
Returns .
Definition IdealFactory.cpp:91
IdealFactory::zeroIdeal
static BigIdeal zeroIdeal(size_t varCount)
Returns the ideal in the ring VarNames(varCount).
Definition IdealFactory.cpp:155
IdealFactory::wholeRing
static BigIdeal wholeRing(size_t varCount)
Returns in the ring VarNames(varCount).
Definition IdealFactory.cpp:149
LibIdealConsumer
Records library interface output into a BigIdeal.
Definition LibTest.h:39
LibIdealConsumer::getIdeal
const BigIdeal & getIdeal() const
Returns the recorded ideal in a canonical form.
Definition LibTest.cpp:66
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40
frobby.h
TEST_SUITE2
#define TEST_SUITE2(PARENT, SUITE)
Definition macroes.h:28
TEST
#define TEST(SUITE, TEST_NAME)
Definition macroes.h:41
Frobby::solveStandardMonomialProgram
bool solveStandardMonomialProgram(const Ideal &ideal, const mpz_t *l, IdealConsumer &consumer)
Solve the optimization program.
Definition frobby.cpp:424
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...
tests.h