| 205 | |
| 206 | |
| 207 | short relations(BigInt **b, const short& number_of_vectors, |
| 208 | const short& vector_dimension, BigInt**& H) |
| 209 | { |
| 210 | |
| 211 | // first check arguments |
| 212 | |
| 213 | if(number_of_vectors<0) |
| 214 | { |
| 215 | cerr<<"\nWARNING: short relations(BigInt**, const short&, const short&, " |
| 216 | "BigInt**):\nargument number_of_vectors out of range"<<endl; |
| 217 | return -1; |
| 218 | } |
| 219 | |
| 220 | if(vector_dimension<=0) |
| 221 | { |
| 222 | cerr<<"\nWARNING: short relations(BigInt**, const short&, const short&, " |
| 223 | "BigInt**):\nargument vector_dimension out of range"<<endl; |
| 224 | return -1; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | // consider special case |
| 229 | |
| 230 | if(number_of_vectors==1) |
| 231 | // Only one vector which has no relations if it is not zero, |
| 232 | // else relation 1. |
| 233 | { |
| 234 | short r=1; // Suppose the only column of the matrix is zero. |
| 235 | |
| 236 | for(short m=0;m<vector_dimension;m++) |
| 237 | if(b[0][m]!=BigInt(0)) |
| 238 | // nonzero entry detected |
| 239 | r=0; |
| 240 | |
| 241 | if(r==1) |
| 242 | { |
| 243 | H=new BigIntP[1]; |
| 244 | H[0]=new BigInt[1]; |
| 245 | H[0][0]=1; |
| 246 | // This is the lattice basis of the relations... |
| 247 | } |
| 248 | |
| 249 | return r; |
| 250 | } |
| 251 | |
| 252 | |
| 253 | // memory allocation |
| 254 | |
| 255 | // The names are chosen (as far as possible) according to Cohen's book. |
| 256 | // However, for technical reasons, the indices do not run from 1 to |
| 257 | // (e.g.) number_of_vectors, but from 0 to number_of_vectors-1. |
| 258 | // Therefore all indices are shifted by -1 in comparison with this book, |
| 259 | // except from the indices of the array d which has size |
| 260 | // number_of_vectors+1. |
| 261 | |
| 262 | H=new BigIntP[number_of_vectors]; |
| 263 | for(short n=0;n<number_of_vectors;n++) |
| 264 | H[n]=new BigInt[number_of_vectors]; |
no test coverage detected