1 /* 2 3 cm_class-impl.h - header file for internal use of the cm_class library 4 5 Copyright (C) 2009, 2010, 2015, 2016, 2018 Andreas Enge 6 7 This file is part of CM. 8 9 CM is free software; you can redistribute it and/or modify it under 10 the terms of the GNU General Public License as published by the 11 Free Software Foundation; either version 3 of the license, or (at your 12 option) any later version. 13 14 CM is distributed in the hope that it will be useful, but WITHOUT ANY 15 WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 for more details. 18 19 You should have received a copy of the GNU General Public License along 20 with CM; see the file COPYING. If not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 */ 23 24 #ifndef __CM_CLASS_IMPL_H 25 #define __CM_CLASS_IMPL_H 26 27 #include "mpfpx.h" 28 #include "cm_class.h" 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <string.h> 32 #include <math.h> 33 #include <assert.h> 34 35 #define CM_CLASS_DATADIR "." 36 #define CM_CLASS_TMPDIR "." 37 38 #define CM_FIELD_REAL 1 39 #define CM_FIELD_COMPLEX 2 40 41 42 typedef struct { 43 int_cl_t a, b; 44 } cm_form_t; 45 46 typedef struct { 47 int_cl_t d; 48 cm_form_t *form; 49 /* contains a set of representatives of quadratic forms of */ 50 /* discriminant d. */ 51 int *conj; 52 /* references how the forms in form are related by "conjugation", 53 that is, negation; conj [i] == j if and only if form [j] is the 54 inverse of form [i] */ 55 int h; 56 /* the class number */ 57 } cm_classgroup_t; 58 59 typedef struct { 60 cm_modular_t m; 61 cm_classgroup_t cl; 62 ftype root; 63 /* sqrt (-cl.d); */ 64 ftype sqrt2_over2, sqrt2_over4; 65 ctype *eta; 66 /* contains the values of eta with respect to the entries of 67 cl.form with the same row index. */ 68 cm_classgroup_t cl2; 69 ctype *eta2; 70 ftype root2; 71 /* Space for a second class group and associated eta values; intended */ 72 /* to be filled with an order of smaller conductor. Currently, is is */ 73 /* used for the Weber function with odd discriminant D; then cl.d==4*D */ 74 /* and cl2.d==D. */ 75 } cm_modclass_t; 76 77 78 #if defined (__cplusplus) 79 extern "C" { 80 #endif 81 82 /* functions depending on PARI */ 83 extern void cm_pari_onefactor (mpz_t *res, mpz_t *f, int deg, int deg_factor, 84 mpz_t p, bool verbose); 85 extern void cm_pari_oneroot (mpz_t root, mpz_t *f, int deg, mpz_t p, 86 bool verbose); 87 extern mpz_t* cm_pari_find_roots (mpz_t *f, int deg, mpz_t p, int *no); 88 extern int cm_pari_classgroup (int_cl_t d, int_cl_t *ord, cm_form_t *gen); 89 90 91 /* functions for classgroups of imaginary-quadratic number fields */ 92 93 extern void cm_classgroup_init (cm_classgroup_t *cl, int_cl_t disc, 94 bool verbose); 95 extern void cm_classgroup_clear (cm_classgroup_t *cl); 96 97 extern void cm_classgroup_mpz_set_icl (mpz_t rop, int_cl_t op); 98 extern int_cl_t cm_classgroup_mpz_get_icl (mpz_t op); 99 extern uint_cl_t cm_classgroup_mod (int_cl_t a, uint_cl_t p); 100 extern int_cl_t cm_classgroup_gcd (int_cl_t a, int_cl_t b); 101 extern int cm_classgroup_kronecker (int_cl_t a, int_cl_t b); 102 103 extern void cm_classgroup_factor (int_cl_t d, 104 uint_cl_t *factors, unsigned int *exponents); 105 extern int_cl_t cm_classgroup_fundamental_discriminant (int_cl_t d); 106 extern int cm_classgroup_h (int_cl_t d); 107 108 extern int_cl_t cm_classgroup_compute_c (int_cl_t a, int_cl_t b, int_cl_t d); 109 extern void cm_classgroup_reduce (cm_form_t *Q, int_cl_t d); 110 extern void cm_classgroup_compose (cm_form_t *Q, cm_form_t Q1, 111 cm_form_t Q2, int_cl_t d); 112 extern cm_form_t cm_classgroup_prime_form (int_cl_t p, int_cl_t d); 113 114 115 /* functions for evaluating modular functions at quadratic integers via 116 precomputations */ 117 118 extern void cm_modclass_init (cm_modclass_t *mc, cm_classgroup_t cl, 119 cm_classgroup_t cl2, fprec_t prec, bool checkpoints, bool verbose); 120 extern void cm_modclass_clear (cm_modclass_t *mc); 121 122 extern void cm_modclass_eta_eval_quad (ctype rop, cm_modular_t m, 123 cm_classgroup_t cl, ctype *eta, int_cl_t a, int_cl_t b, ftype root); 124 extern void cm_modclass_f_eval_quad (cm_modclass_t mc, ctype rop, 125 int_cl_t a, int_cl_t b, int e); 126 extern void cm_modclass_f1_eval_quad (cm_modclass_t mc, ctype rop, 127 int_cl_t a, int_cl_t b, int e); 128 extern void cm_modclass_gamma2_eval_quad (cm_modclass_t mc, ctype rop, 129 int_cl_t a, int_cl_t b); 130 extern void cm_modclass_gamma3_eval_quad (cm_modclass_t mc, ctype rop, 131 int_cl_t a, int_cl_t b); 132 extern void cm_modclass_j_eval_quad (cm_modclass_t mc, ctype rop, 133 int_cl_t a, int_cl_t b); 134 extern void cm_modclass_multieta_eval_quad (cm_modclass_t mc, ctype rop, 135 int_cl_t a, int_cl_t b, int *p, int e); 136 extern void cm_modclass_atkinhecke_level_eval_quad (cm_modclass_t mc, ctype rop, 137 int_cl_t a, int_cl_t b, unsigned long int l); 138 139 140 /* functions for class polynomials */ 141 extern void cm_class_write (cm_class_t c); 142 extern bool cm_class_read (cm_class_t c); 143 144 extern mpz_t* cm_class_get_j_mod_P (int_cl_t d, char inv, mpz_t P, int *no, 145 const char* modpoldir, bool readwrite, bool verbose); 146 147 148 #if defined (__cplusplus) 149 } 150 #endif 151 #endif /* ifndef __CM_CLASS_IMPL_H */ 152