-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdr.h
221 lines (180 loc) · 7.5 KB
/
dr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// Copyright 2013-2017 Edgar Costa
// See LICENSE file for license details.
//
// dr.h: header file for de_Rham_local class, which implements the de Rham structure to perform controlled_reductions
#ifndef DR_H
#define DR_H
#include "conv.h"
#include "solve_system.h"
#include "tools.h"
#include "matrix.h"
#include "vec_int64.h"
#include <NTL/ZZX.h>
#include <stdio.h>
#include <map>
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
using namespace NTL;
class de_Rham_local{
/*
* Some notation:
* V_u = { (m-1)! x^u G Omega / x0 ... xn f^m}
* with G a dense polynomial of degree d * n - n and x0 ... xn | x^u G
*/
public:
int64_t p;
int64_t precision;
bool save_memory;
bool verbose;
map< Vec<int64_t>, zz_p, vi64less> fbar;
map< Vec<int64_t>, ZZ_p, vi64less> f;
int64_t d;
int64_t n;
/*
* tuple_list[l] = the list (n+1)-tuples that are a partition of l
*/
Vec< Vec< Vec<int64_t> > > tuple_list;
/*
* tuple_dict[l] is the dictionary for reverse lookup of (n+1)-tuples that are a partition of l
*/
Vec< map< Vec<int64_t>, int64_t, vi64less> > tuple_dict;
/*
* the Hilbert polynomial as a vector
*/
Vec<int64_t> Hilbert_J;
/*
* the basis for the midle cohomology
*/
Vec< Vec<int64_t> > coKernels_J_basis;
/*
* the dictionary for reverse lookup
*/
map< Vec<int64_t>, int64_t, vi64less> coKernels_J_basis_dict;
/*
* the equivalent of solve_Ji as a dictionary i->solve_Ji
* solve_Ji is the matrix that will tell us how to write a monomial of degree i in terms of
* dfi and coKernel elements
*/
map< int64_t, pair< Vec<int64_t>, Mat<ZZ_p> > > solve_J;
/*
* the dictionary where we will store the inclusion matrices
* u -> inclusion_matrix_J(u) (sum(u) = n)
* where inclusion_matrix_J(u) is the matrix that maps
* V_u - > {(n-1)! H Omega/f^n : deg H = d*n - n - 1}
*/
map< Vec<int64_t>, Mat<ZZ_p>, vi64less> inclusion_matrix_J_dict;
/*
* the dictionary where we will store the final reduction matrices
* pole -> matrix that reduces (pole -1)! G \Omega / f^pole to the cohomology basis elements
*/
Vec< Mat<ZZ_p> > final_reduction_matrix_J_dict;
/*
* the dictionary where we will store the reduction matrices as polynomials
* v -> reduction_matrix(v)(u) \in ZZ_p[u0, ..., un] represented as a vector M
* consntant term = M[0]
* ui term = M[i+1]
* where reduction_matrix(v)(u) is the map from V_{u+v} to V_{u}
*/
map< Vec<int64_t> , Vec< Mat<ZZ_p> > , vi64less> reduction_matrix_J_dict;
/*
* same map as above but stores matrices already over ZZ to avoid unecessary conversions
*/
map< Vec<int64_t> , Vec< Mat<ZZ> > , vi64less> reduction_matrix_J_ZZ_dict;
/*
* FUNCTIONS
*/
/*
* constructors
*/
de_Rham_local(){};
de_Rham_local(int64_t p, int64_t precision, int64_t n, int64_t d, bool verbose, bool save_memory = true);
de_Rham_local(int64_t p, int64_t precision, int64_t n, int64_t d, Vec< ZZ_p> f_vector, bool verbose, bool save_memory = true);
de_Rham_local(int64_t p, int64_t precision, map< Vec<int64_t>, ZZ_p, vi64less> f, bool verbose , bool save_memory = true);
// if given fbar, we lift to f naively
de_Rham_local(int64_t p, int64_t precision, int64_t n, int64_t d, Vec< zz_p> fbar_vector, bool verbose, bool save_memory = true);
de_Rham_local(int64_t p, int64_t precision, map< Vec<int64_t>, zz_p, vi64less> fbar, bool verbose , bool save_memory = true);
de_Rham_local(const char * filename);
virtual bool save(const char * filename);
virtual ~de_Rham_local(){};
void init(int64_t p, int64_t precision, map< Vec<int64_t>, ZZ_p, vi64less> f, bool verbose, bool save_memory);
/*
* computes all the reduction and inclusion matrices
*/
void compute_everything_J();
/*
* computes the pair solve_Jl and adds it to the dictionary (if not compute already)
* returns the pointer for the pair
*/
pair< Vec<int64_t>, Mat<ZZ_p> >* get_solve_J(const int64_t level);
/*
* returns the reduction matrix from V_{u+v} to V_u
*/
Mat<ZZ_p> get_reduction_matrix_J(const Vec<int64_t> u, const Vec<int64_t> v);
/*
* returns the reduction matrix (over ZZ) from V_{u+v} to V_u
* that will be correct in ZZ_p
*/
Mat<ZZ> get_reduction_matrix_J_ZZ(const Vec<int64_t> u, const Vec<int64_t> v);
Vec<ZZ_p> reduce_vector_J(const Vec<int64_t> u, const Vec<int64_t>, const Vec<ZZ_p> G);
void reduce_vector_J_ZZ(Vec<ZZ> &result, const Vec<int64_t> u, const Vec<int64_t> v, const Vec<ZZ> G);
/*
* reduces a vector from V_{u+kv) to V_u
*/
void reduce_vector_J_poly(Vec<ZZ_p> &result, const Vec<int64_t> u, const Vec<int64_t> v, const int64_t k, const Vec<ZZ_p> G);
void reduce_vector_J_poly_ZZ(Vec<ZZ> &result, const Vec<int64_t> u, const Vec<int64_t> v, const int64_t k, const Vec<ZZ> G);
/*
* returns the iterator for the reduction matrix from V_{u+v} to V_u as a polynomial in u0,...,un
* if not computed adds it to the map
*/
map< Vec<int64_t>, Vec<Mat<ZZ_p> >, vi64less>::const_iterator compute_reduction_matrix_J(const Vec<int64_t> v);
map< Vec<int64_t>, Vec<Mat<ZZ> >, vi64less>::const_iterator compute_reduction_matrix_J_ZZ(const Vec<int64_t> v);
/*
* returns a pointer to the inclusion_matrix_J(u)
*/
Mat<ZZ_p>* get_inclusion_matrix_J(Vec<int64_t> u);
/*
* computes the inclusion_matrix_J(u) and adds it to the dictionary
*/
void compute_inclusion_matrix_J(Vec<int64_t> u);
/*
* computes all the final reduction matrices for 0 <= pole <= k
* that reduce (pole -1)! G \Omega / f^pole to the cohomology basis elements
* and adds them to the list.
*/
void compute_final_reduction_matrix_J(int64_t k);
/*
* returns the final reduction matrix for
* (k -1)! G \Omega / f^k to the cohomology basis elements
*/
Mat<ZZ_p>* get_final_reduction_matrix_J(int64_t k);
/*
* computes the matrix map
* (H0,...,Hn) -> H0 * df0 + ... + Hn * dfn
* Where Hi have degree = l - (d-1).
*/
void matrix_J(Mat<ZZ_p> &result, int64_t l);
/*
* Computes the coordinates of (m-1)! x^u \Omega / x0 ... xn f^m
* in the cohomology basis
*/
Vec<ZZ_p> monomial_to_basis_J(Vec<int64_t> u);
/*
* Test Functions
*/
/*
* checks that a basis element x^w \Omega / f^k ~ x^w f^l \Omega / f^(l+k)
* for l <= N
*/
bool test_monomial_to_basis_J(int64_t N);
/*
* tests the path independence while performing reductions
*/
bool test_paths_J(int64_t trials, int64_t paths);
};
// checks if F defines a smooth hypersurface
// does this by constructing a minmal dr object
// and checks if Jacobian ideal is irrelevant
bool isSmooth( const map< Vec<int64_t>, zz_p, vi64less> &F );
#endif