-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rank1Lattice.cc
144 lines (112 loc) · 3.45 KB
/
Rank1Lattice.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Copyright (c) 2012 Richard Simard, Pierre L'Ecuyer, Université de Montréal.
//
// This file is part of Lattice Builder.
//
// Lattice Builder 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 3 of the License, or
// (at your option) any later version.
//
// Lattice Builder 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 Lattice Builder. If not, see <http://www.gnu.org/licenses/>.
#include "latcommon/UtilLC.h"
#include "latcommon/Rank1Lattice.h"
#include <cassert>
// #include <boost/numeric/ublas/matrix.hpp>
// #include <boost/numeric/ublas/matrix_proxy.hpp>
#ifdef WITH_NTL
#else
using namespace boost::numeric::ublas;
#endif
using namespace std;
namespace LatCommon
{
Rank1Lattice::Rank1Lattice (const MScal & n, const MVect & a, int maxDim,
NormType norm):
IntLattice::IntLattice (n, maxDim, maxDim, norm)
{
m_a.resize (1 + maxDim);
m_a = a;
init ();
}
//=========================================================================
Rank1Lattice::~Rank1Lattice ()
{
m_a.clear ();
}
//=========================================================================
void Rank1Lattice::init ()
{
IntLattice::init ();
for (int r = 2; r <= getMaxDim (); r++)
m_lgVolDual2[r] = m_lgVolDual2[r - 1];
}
//=========================================================================
Rank1Lattice & Rank1Lattice::operator= (const Rank1Lattice & lat)
{
if (this == &lat)
return * this;
copy (lat);
init ();
int maxDim = lat.getMaxDim ();
m_a.resize (1 + maxDim);
m_a = lat.m_a;
return *this;
}
//=========================================================================
Rank1Lattice::Rank1Lattice (const Rank1Lattice & lat):
IntLattice::IntLattice (lat.m_m, lat.getOrder (),
lat.getMaxDim (), lat.getNorm ())
{
// MyExit (1, "Rank1Lattice:: constructeur n'est pas terminé " );
init ();
int maxDim = lat.getMaxDim ();
m_a.resize (1 + maxDim);
m_a = lat.m_a;
}
//===========================================================================
std::string Rank1Lattice::toStringCoef ()const
{
return toString (m_a, 1, getMaxDim ());
}
//=========================================================================
void Rank1Lattice::incDim ()
{
// kill();
buildBasis (1 + getDim ());
m_v.setNegativeNorm (true);
m_w.setNegativeNorm (true);
}
//===========================================================================
void Rank1Lattice::buildBasis (int d)
{
// assert(d <= getMaxDim());
setDim (d);
// conv(m_v[1][1], 1);
for (int j = 1; j <= d; j++) {
m_v (1, j) = m_a[j];
}
for (int i = 2; i <= d; i++) {
for (int j = 1; j <= d; j++) {
if (i == j) {
m_v (i, j) = m_m;
} else {
m_v (i, j) = 0;
}
}
}
// if a[1] != 1, the basis must be triangularized
if (m_v (1, 1) != 1) {
Triangularization < Base > (m_v, m_w, d, d, m_m);
dualize ();
}
CalcDual < Base > (m_v, m_w, d, m_m);
m_v.setNegativeNorm (true);
m_w.setNegativeNorm (true);
}
}