Fast Library for Number Theory
Total Page:16
File Type:pdf, Size:1020Kb
FLINT Fast Library for Number Theory Version 2.2.0 4 June 2011 William Hart∗, Fredrik Johanssony, Sebastian Pancratzz ∗ Supported by EPSRC Grant EP/G004870/1 y Supported by Austrian Science Foundation (FWF) Grant Y464-N18 z Supported by European Research Council Grant 204083 Contents 1 Introduction1 2 Building and using FLINT3 3 Test code5 4 Reporting bugs7 5 Contributors9 6 Example programs 11 7 FLINT macros 13 8 fmpz 15 8.1 Introduction.................................. 15 8.2 Simple example................................ 16 8.3 Memory management ............................ 16 8.4 Random generation.............................. 16 8.5 Conversion .................................. 17 8.6 Input and output............................... 18 8.7 Basic properties and manipulation ..................... 19 8.8 Comparison.................................. 19 8.9 Basic arithmetic ............................... 20 8.10 Greatest common divisor .......................... 23 8.11 Modular arithmetic.............................. 23 8.12 Bit packing and unpacking ......................... 23 8.13 Chinese remaindering ............................ 24 9 fmpz vec 27 9.1 Memory management ............................ 27 9.2 Randomisation ................................ 27 9.3 Bit sizes.................................... 27 9.4 Input and output............................... 27 9.5 Conversions.................................. 28 9.6 Assignment and basic manipulation .................... 28 9.7 Comparison.................................. 29 9.8 Sorting..................................... 29 9.9 Addition and subtraction .......................... 29 9.10 Scalar multiplication and division...................... 29 9.11 Gaussian content............................... 31 10 fmpz mat 33 10.1 Introduction.................................. 33 10.2 Simple example................................ 33 Contents iii 10.3 Memory management ............................ 34 10.4 Random matrix generation ......................... 34 10.5 Basic assignment and manipulation..................... 36 10.6 Input and output............................... 36 10.7 Comparison.................................. 37 10.8 Transpose................................... 37 10.9 Modular reduction and reconstruction ................... 37 10.10 Addition and subtraction .......................... 38 10.11 Matrix-scalar arithmetic........................... 38 10.12 Matrix multiplication ............................ 39 10.13 Inverse..................................... 40 10.14 Determinant ................................. 40 10.15 Rank...................................... 40 10.16 Nonsingular solving ............................. 41 10.17 Kernel..................................... 42 10.18 Echelon form ................................. 42 10.19 Internal functions for row reduction .................... 42 11 fmpz poly 45 11.1 Introduction.................................. 45 11.2 Simple example................................ 45 11.3 Definition of the fmpz poly t type ..................... 46 11.4 Memory management ............................ 46 11.5 Polynomial parameters............................ 47 11.6 Assignment and basic manipulation .................... 47 11.7 Randomisation ................................ 49 11.8 Getting and setting coefficients....................... 49 11.9 Comparison.................................. 50 11.10 Addition and subtraction .......................... 50 11.11 Scalar multiplication and division...................... 51 11.12 Bit packing.................................. 52 11.13 Multiplication................................. 53 11.14 Powering ................................... 55 11.15 Shifting .................................... 57 11.16 Norms..................................... 57 11.17 Greatest common divisor .......................... 58 11.18 Gaussian content............................... 60 11.19 Euclidean division .............................. 60 11.20 Divisibility testing .............................. 64 11.21 Power series division............................. 64 11.22 Pseudo division................................ 65 11.23 Derivative................................... 67 11.24 Evaluation................................... 67 11.25 Interpolation ................................. 68 11.26 Composition ................................. 68 11.27 Signature ................................... 69 11.28 Input and output............................... 70 11.29 Modular reduction and reconstruction ................... 72 11.30 Products.................................... 73 12 fmpq 75 12.1 Introduction.................................. 75 12.2 Memory management ............................ 75 12.3 Canonicalisation ............................... 75 iv Contents 12.4 Basic assignment............................... 76 12.5 Comparison.................................. 76 12.6 Conversion .................................. 77 12.7 Input and output............................... 77 12.8 Random number generation......................... 77 12.9 Arithmetic .................................. 78 12.10 Modular reduction and rational reconstruction .............. 79 12.11 Rational enumeration ............................ 79 13 fmpq mat 81 13.1 Introduction.................................. 81 13.2 Memory management ............................ 81 13.3 Entry access.................................. 81 13.4 Basic assignment............................... 82 13.5 Addition, scalar multiplication ....................... 82 13.6 Input and output............................... 82 13.7 Random matrix generation ......................... 83 13.8 Special matrices ............................... 83 13.9 Basic comparison and properties ...................... 83 13.10 Integer matrix conversion .......................... 83 13.11 Modular reduction and rational reconstruction .............. 84 13.12 Matrix multiplication ............................ 84 13.13 Determinant ................................. 85 13.14 Nonsingular solving ............................. 85 13.15 Inverse..................................... 85 13.16 Echelon form ................................. 86 14 fmpq poly 87 14.1 Introduction.................................. 87 14.2 Memory management ............................ 87 14.3 Polynomial parameters............................ 89 14.4 Accessing the numerator and denominator................. 89 14.5 Random testing................................ 89 14.6 Assignment, swap, negation......................... 90 14.7 Setting and getting coefficients ....................... 91 14.8 Comparison.................................. 92 14.9 Addition and subtraction .......................... 92 14.10 Scalar multiplication and division...................... 93 14.11 Multiplication................................. 95 14.12 Powering ................................... 96 14.13 Shifting .................................... 96 14.14 Euclidean division .............................. 96 14.15 Power series division............................. 97 14.16 Derivative and integral............................ 98 14.17 Square roots ................................. 98 14.18 Transcendental functions........................... 98 14.19 Evaluation...................................101 14.20 Interpolation .................................101 14.21 Composition .................................102 14.22 Gaussian content...............................102 14.23 Square-free ..................................103 14.24 Input and output...............................103 15 fmpz poly q 105 Contents v 15.1 Introduction..................................105 15.2 Simple example................................105 15.3 Memory management ............................106 15.4 Randomisation ................................106 15.5 Assignment..................................107 15.6 Comparison..................................107 15.7 Addition and subtraction ..........................107 15.8 Scalar multiplication and division......................108 15.9 Multiplication and division .........................108 15.10 Powering ...................................109 15.11 Derivative...................................109 15.12 Evaluation...................................109 15.13 Input and output...............................109 16 fmpz poly mat 111 16.1 Simple example................................111 16.2 Memory management ............................112 16.3 Basic assignment and manipulation.....................112 16.4 Input and output...............................112 16.5 Random matrix generation .........................112 16.6 Special matrices ...............................112 16.7 Basic comparison and properties ......................113 16.8 Norms.....................................113 16.9 Evaluation...................................113 16.10 Arithmetic ..................................113 16.11 Row reduction ................................114 16.12 Determinants.................................114 17 nmod vec 115 17.1 Memory management ............................115 17.2 Modular reduction and arithmetic .....................115 17.3 Random functions ..............................116 17.4 Basic manipulation and comparison ....................116 17.5 Arithmetic operations ............................117 18 nmod poly 119 18.1 Introduction..................................119 18.2 Simple example................................119 18.3 Definition of the nmod poly t type.....................120