Frobby
0.9.5
src
lattice.cpp
Go to the documentation of this file.
1
/* Frobby: Software for monomial ideal computations.
2
Copyright (C) 2007 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 "
lattice.h
"
19
20
#include "
BigIdeal.h
"
21
22
void
addMultiple
(
BigIdeal
&
basis
,
23
unsigned
int
add,
24
unsigned
int
addTo
,
25
const
mpz_class
&
mult
) {
26
if
(
mult
== 0)
27
return
;
28
29
for
(
unsigned
int
i
= 0;
i
<
basis
[0].size(); ++
i
)
30
basis
[
addTo
][
i
] +=
basis
[add][
i
] *
mult
;
31
}
32
33
void
makeZeroesInLatticeBasis
(
BigIdeal
&
basis
) {
34
ASSERT
(!
basis
.empty());
35
unsigned
int
rowCount
=
basis
.getGeneratorCount();
36
unsigned
int
columnCount
=
basis
[0].size();
37
38
for
(
unsigned
int
col
=
columnCount
- 1;
col
>= 1; --
col
) {
39
for
(
unsigned
int
i
= 0;
i
<
rowCount
; ++
i
) {
40
mpz_class
sign;
41
if
(
basis
[
i
][
col
] == 1)
42
sign = 1;
43
else
if
(
basis
[
i
][
col
] == -1)
44
sign = -1;
45
else
46
continue
;
47
48
for
(
unsigned
int
j
= 0;
j
<
rowCount
; ++
j
) {
49
if
(
j
==
i
)
50
continue
;
51
addMultiple
(
basis
,
i
,
j
, -1 * sign *
basis
[
j
][
col
]);
52
}
53
54
break
;
55
}
56
}
57
}
BigIdeal.h
nameFactoryRegister
void nameFactoryRegister(NameFactory< AbstractProduct > &factory)
Registers the string returned by ConcreteProduct::getStaticName() to a function that default-construc...
Definition
NameFactory.h:142
BigIdeal
Definition
BigIdeal.h:27
makeZeroesInLatticeBasis
void makeZeroesInLatticeBasis(BigIdeal &basis)
Definition
lattice.cpp:33
addMultiple
void addMultiple(BigIdeal &basis, unsigned int add, unsigned int addTo, const mpz_class &mult)
Definition
lattice.cpp:22
lattice.h
ASSERT
#define ASSERT(X)
Definition
stdinc.h:86
stdinc.h
Generated by
1.9.8