source: git/factory/cf_hnf.cc @ 6bc4cd

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