30 for(
int i=0;i<3;i++) for(int j=i+1;j<3;j++) if(modulo2(v[i])>
modulo2(v[j])){
31 Vector x=v[i]; v[i]=v[j]; v[j]=x;
33 for(
int i=0;i<2;i++) plumed_assert(
modulo2(v[i])<=
modulo2(v[i+1]));
42 double mt(ma); ma=mb; mb=mt;
46 if(mb<=ma+epsilon)
break;
54 v[0]=
a; v[1]=b; v[2]=c;
73 a=v[0]; b=v[1]; c=v[2];
78 for(
int i=-cut;i<=cut;i++){
111 double z=b11*b22-b12*b12;
112 double y2=-(b11*b23-b12*b13)/z;
113 double y1=-(b22*b13-b12*b23)/z;
121 for(
int x1=x1min;x1<=x1max;x1++)
122 for(
int x2=x2min;x2<=x2max;x2++){
123 trial=v[2]+x2*v[1]+x1*v[0];
125 if(first || mtrial<mbest){
151 int eps01=0;
if(e01>0.0) eps01=1;
else if(e01<0.0) eps01=-1;
152 int eps02=0;
if(e02>0.0) eps02=1;
else if(e02<0.0) eps02=-1;
153 Vector n=v[0]-eps01*v[1]-eps02*v[2];
154 int i=0;
double mx=
modulo2(v[i]);
155 for(
int j=1;j<3;j++){
180 for(
int i=0;i<3;i++) m[i]=
modulo2(v[i]);
181 if(!((m[0]<=m[1]) && m[1]<=m[2]))
return false;
183 for(
int i=-cut;i<=cut;i++){
184 double mm=
modulo2(v[1]+i*v[0]);
185 if(mm<m[1])
return false;
186 for(
int j=-cut;j<=cut;j++){
187 double mx=
modulo2(v[2]+i*v[1]+j*v[0]);
188 if(mx<m[2])
return false;
static void sort(Vector v[3])
Sort three vectors by modulo.
Class implementing fixed size matrices of doubles.
Class implementing fixed size vectors of doubles.
static bool isReduced(const Vector &a, const Vector &b)
Check if two vectors are reduced.
static void reduceFast(Tensor &t)
Reduce a basis in place using the fast algorithm (Algorithm 3 in the paper)
static bool isReduced2(const Vector &a, const Vector &b, const Vector &c)
Check if three vectors are reduced-2.
T dotProduct(const std::vector< T > &A, const std::vector< T > &B)
Calculate the dot product between two vectors.
double modulo2(const VectorGeneric< n > &v)
static void reduce2(Vector &a, Vector &b, Vector &c)
Obtain three reduce-2 vectors (Algorithm 1 in the paper), equivalent to reduce2(Tensor&t) ...
static void reduce(Vector &a, Vector &b)
Gaussian reduction.
TensorGeneric & setRow(unsigned i, const VectorGeneric< m > &r)
set i-th row
static void reduceSlow(Tensor &t)
Reduce a basis in place using the slow algorithm (Algorithm 2 in the paper)
VectorGeneric< m > getRow(unsigned i) const
get i-th row