source: git/factory/cf_hnf.cc @ 86faff

spielwiese
Last change on this file since 86faff was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3//{{{ docu
4//
5// cf_hnf.cc - HNF of NTL
6//
7// Header file: cf_hnf.h
8//
9//}}}
10
11#include "config.h"
12
13#ifdef HAVE_NTL
14#include "NTLconvert.h"
15#include "canonicalform.h"
16#include "cf_defs.h"
17#include "cf_hnf.h"
18#include <NTL/mat_ZZ.h>
19#include <NTL/HNF.h>
20#include <NTL/LLL.h>
21
22// The input matrix A is an n x m matrix of rank m (so n >= m), and D
23// is a multiple of the determinant of the lattice L spanned by the
24// rows of A.  W is computed as the Hermite Normal Form of A; that is,
25// W is the unique m x m matrix whose rows span L, such that
26//
27// - W is lower triangular,
28// - the diagonal entries are positive,
29// - any entry below the diagonal is a non-negative number
30//   strictly less than the diagonal entry in its column.
31//
32// via ntl
33CFMatrix* cf_HNF(CFMatrix& A)
34{
35  mat_ZZ *AA=convertFacCFMatrix2NTLmat_ZZ(A);
36  ZZ DD=convertFacCF2NTLZZ(determinant(A,A.rows()));
37  mat_ZZ WW;
38  HNF(WW,*AA,DD);
39  delete AA;
40  return convertNTLmat_ZZ2FacCFMatrix(WW);
41}
42CFMatrix* cf_LLL(CFMatrix& A)
43{
44  mat_ZZ *AA=convertFacCFMatrix2NTLmat_ZZ(A);
45  #if 0
46  LLL_RR(*AA);
47  #else
48  ZZ det2;
49  LLL(det2,*AA,0L);
50  #endif
51  CFMatrix *r= convertNTLmat_ZZ2FacCFMatrix(*AA);
52  delete AA;
53  return r;
54}
55#endif
Note: See TracBrowser for help on using the repository browser.