MCPcopy Create free account
hub / github.com/Singular/Singular / REDI_IL

Function REDI_IL

IntegerProgramming/LLL.cc:55–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54
55void REDI_IL(const short& k, const short& l, BigInt** b,
56 const short& vector_dimension, BigInt* d, BigInt** lambda)
57// the REDI procedure for the integer LLL algorithm (algorithm 2.6.7 in
58// Cohen's book)
59{
60#ifdef GMP
61 if(abs(BigInt(2)*lambda[k][l])<=d[l+1])
62#else // GMP
63 if(labs(2*lambda[k][l])<=d[l+1])
64 // labs is the abs-function for long ints
65#endif // GMP
66 return;
67
68#ifdef GMP
69 BigInt q=(BigInt(2)*lambda[k][l]+d[l+1])/(BigInt(2)*d[l+1]);
70#else // GMP
71 long q=(long int) floor(((float)(2*lambda[k][l]+d[l+1]))/(2*d[l+1]));
72#endif // GMP
73
74 // q is the integer quotient of the division
75 // (2*lambda[k][l]+d[l+1])/(2*d[l+1]).
76 // Because of the rounding mode (always towards zero) of GNU C++,
77 // we cannot use the built-in integer division
78 // here; it causes errors when dealing with negative numbers. Therefore
79 // the complicated casts: The divident is first casted to a float which
80 // causes the division result to be a float. This result is explicitly
81 // rounded downwards. As the floor-function returns a double (for range
82 // reasons), this has to be casted to an integer again.
83
84 for(short m=0;m<vector_dimension;m++)
85 b[k][m]-=q*b[l][m];
86 // b[k]=b[k]-q*b[l]
87
88 lambda[k][l]-=q*d[l+1];
89
90 for(short i=0;i<=l-1;i++)
91 lambda[k][i]-=q*lambda[l][i];
92}
93
94
95

Callers 1

integral_LLLFunction · 0.85

Calls 3

BigIntClass · 0.85
absFunction · 0.70
floorFunction · 0.50

Tested by

no test coverage detected