Frobby 0.9.5
LibDimensionTest.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#include "frobby.h"
19
20#include "tests.h"
21#include "BigIdeal.h"
22#include "IdealFactory.h"
23#include "LibTest.h"
24
25TEST_SUITE2(LibraryInterface, DimensionAndCodimension)
26
27namespace {
29 mpz_class dimension(const BigIdeal& ideal) {
30 mpz_class dim;
31 Frobby::dimension(toLibIdeal(ideal), dim.get_mpz_t());
32 return dim;
33 }
34
36 mpz_class codimension(const BigIdeal& ideal) {
37 mpz_class codim;
38 Frobby::codimension(toLibIdeal(ideal), codim.get_mpz_t());
39 return codim;
40 }
41}
42
43TEST(DimensionAndCodimension, WholeRing) {
44 ASSERT_EQ(dimension(IdealFactory::wholeRing(0)), -1);
45 ASSERT_EQ(codimension(IdealFactory::wholeRing(0)), 1);
46
47 ASSERT_EQ(dimension(IdealFactory::wholeRing(5)), -1);
48 ASSERT_EQ(codimension(IdealFactory::wholeRing(5)), 6);
49}
50
51TEST(DimensionAndCodimension, ZeroIdeal) {
52 ASSERT_EQ(dimension(IdealFactory::zeroIdeal(0)), 0);
53 ASSERT_EQ(codimension(IdealFactory::zeroIdeal(0)), 0);
54
55 ASSERT_EQ(dimension(IdealFactory::zeroIdeal(5)), 5);
56 ASSERT_EQ(codimension(IdealFactory::zeroIdeal(5)), 0);
57}
58
59TEST(DimensionAndCodimension, Typical) {
60 ASSERT_EQ(dimension(IdealFactory::xy_xz()), 3);
61 ASSERT_EQ(codimension(IdealFactory::xy_xz()), 1);
62
63 ASSERT_EQ(dimension(IdealFactory::xx_yy_xz_yz()), 2);
64 ASSERT_EQ(codimension(IdealFactory::xx_yy_xz_yz()), 2);
65}
Frobby::Ideal toLibIdeal(const BigIdeal &ideal)
Returns a library interface ideal that corresponds to the parameter ideal.
Definition LibTest.cpp:26
#define ASSERT_EQ(A, B)
Definition asserts.h:147
static BigIdeal xy_xz()
Returns .
static BigIdeal xx_yy_xz_yz()
Returns .
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).
#define TEST_SUITE2(PARENT, SUITE)
Definition macroes.h:28
#define TEST(SUITE, TEST_NAME)
Definition macroes.h:41
void dimension(const Ideal &ideal, mpz_t dim)
Compute the Krull dimension of a monomial ideal.
Definition frobby.cpp:447
void codimension(const Ideal &ideal, mpz_t codim)
Compute the codimension of a monomial ideal.
Definition frobby.cpp:441
This header file includes common definitions and is included as the first line of code in every imple...