My Project
Loading...
Searching...
No Matches
cf_hnf.cc
Go to the documentation of this file.
1/* emacs edit mode for this file is -*- C++ -*- */
2
3/**
4 *
5 * @file cf_hnf.cc
6 *
7 * HNF/LLL of NTL
8 *
9 * Header file: cf_hnf.h
10 *
11**/
12
13
14#include "config.h"
15
16#include "canonicalform.h"
17#include "cf_defs.h"
18#include "cf_hnf.h"
19#include "cf_util.h"
20
21#ifdef HAVE_NTL
22#include "NTLconvert.h"
23#include <NTL/mat_ZZ.h>
24#include <NTL/HNF.h>
25#include <NTL/LLL.h>
26#endif
27
28#ifdef HAVE_FLINT
29#include "FLINTconvert.h"
30#endif
31
32/**
33 * The input matrix A is an n x m matrix of rank m (so n >= m), and D
34 * is a multiple of the determinant of the lattice L spanned by the
35 * rows of A. W is computed as the Hermite Normal Form of A; that is,
36 * W is the unique m x m matrix whose rows span L, such that
37 *
38 * - W is lower triangular,
39 * - the diagonal entries are positive,
40 * - any entry below the diagonal is a non-negative number
41 * strictly less than the diagonal entry in its column.
42 *
43**/
45{
46#ifdef HAVE_FLINT
47 fmpz_mat_t FLINTM;
49 fmpz_mat_hnf(FLINTM,FLINTM);
51 fmpz_mat_clear(FLINTM);
52 return r;
53#elif defined(HAVE_NTL)
55 ZZ DD=convertFacCF2NTLZZ(determinant(A,A.rows()));
56 mat_ZZ WW;
57 HNF(WW,*AA,DD);
58 delete AA;
60#else
61 factoryError("NTL/FLINT missing: cf_HNF");
62 return NULL; // avoid warning
63#endif
64}
65
67{
68#ifdef HAVE_FLINT
69 fmpz_mat_t FLINTM;
71 fmpq_t delta,eta;
72 fmpq_init(delta); fmpq_set_si(delta,1,1);
73 fmpq_init(eta); fmpq_set_si(eta,3,4);
74 fmpz_mat_lll_storjohann(FLINTM,delta,eta);
76 fmpz_mat_clear(FLINTM);
77 return r;
78#elif defined(HAVE_NTL)
80 ZZ det2;
81 LLL(det2,*AA,0L);
83 delete AA;
84 return r;
85#else
86 factoryError("NTL/FLINT missing: cf_LLL");
87 return NULL; // avoid warning
88#endif
89}
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
mat_ZZ * convertFacCFMatrix2NTLmat_ZZ(const CFMatrix &m)
Definition: NTLconvert.cc:1138
CFMatrix * convertNTLmat_ZZ2FacCFMatrix(const mat_ZZ &m)
Definition: NTLconvert.cc:1153
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
Definition: NTLconvert.cc:670
Conversion to and from NTL.
Header for factory's main class CanonicalForm.
CanonicalForm FACTORY_PUBLIC determinant(const CFMatrix &M, int n)
Definition: cf_linsys.cc:222
factory switches.
CFMatrix * cf_LLL(CFMatrix &A)
performs LLL reduction.
Definition: cf_hnf.cc:66
CFMatrix * cf_HNF(CFMatrix &A)
The input matrix A is an n x m matrix of rank m (so n >= m), and D is a multiple of the determinant o...
Definition: cf_hnf.cc:44
VAR void(* factoryError)(const char *s)
Definition: cf_util.cc:80
#define NULL
Definition: omList.c:12
#define A
Definition: sirandom.c:24