| 53 | |
| 54 | |
| 55 | void 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 |
no test coverage detected