Original Authors: Torbjorn Granlund and the GMP Development Team

Total Page:16

File Type:pdf, Size:1020Kb

Original Authors: Torbjorn Granlund and the GMP Development Team MPIR The Multiple Precision Integers and Rationals Library Edition 3.0.0 18 February 2017 Original Authors: Torbjorn Granlund and the GMP Development Team Subsequent modifications: William Hart and the MPIR Team This manual describes how to install and use MPIR, the Multiple Precision Integers and Ratio- nals library, version 3.0.0. Copyright 1991, 1993-2016 Free Software Foundation, Inc. Copyright 2008, 2009, 2010 William Hart Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being \A GNU Manual", and with the Back-Cover Texts being \You have freedom to copy and modify this GNU Manual, like GNU software". A copy of the license is included in Appendix C [GNU Free Documentation License], page 148. i Table of Contents MPIR Copying Conditions ::::::::::::::::::::::::::::::::::::::: 1 1 Introduction to MPIR :::::::::::::::::::::::::::::::::::::::: 2 1.1 How to use this Manual ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 2 2 Installing MPIR ::::::::::::::::::::::::::::::::::::::::::::::: 3 2.1 Build Options ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2.2 ABI and ISA :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 8 2.3 Notes for Package Builds ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 10 2.4 Building with Microsoft Visual Studio :::::::::::::::::::::::::::::::::::::::::::: 11 2.5 Notes for Particular Systems ::::::::::::::::::::::::::::::::::::::::::::::::::::: 13 2.6 Known Build Problems ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 14 2.7 Performance optimization :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 15 3 MPIR Basics ::::::::::::::::::::::::::::::::::::::::::::::::: 16 3.1 Headers and Libraries :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 16 3.2 Nomenclature and Types ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 16 3.3 MPIR on Windows x64::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 17 3.4 Function Classes ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 18 3.5 Variable Conventions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 18 3.6 Parameter Conventions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 19 3.7 Memory Management :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 20 3.8 Reentrancy::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 20 3.9 Useful Macros and Constants ::::::::::::::::::::::::::::::::::::::::::::::::::::: 20 3.10 Compatibility with older versions :::::::::::::::::::::::::::::::::::::::::::::::: 21 3.11 Efficiency ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 21 3.12 Debugging :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 23 3.13 Profiling :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 25 3.14 Autoconf:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 27 3.15 Emacs :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 27 4 Reporting Bugs::::::::::::::::::::::::::::::::::::::::::::::: 28 5 Integer Functions::::::::::::::::::::::::::::::::::::::::::::: 29 5.1 Initialization Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 29 5.2 Assignment Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 30 5.3 Combined Initialization and Assignment Functions :::::::::::::::::::::::::::::::: 30 5.4 Conversion Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 31 5.5 Arithmetic Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 32 5.6 Division Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 33 5.7 Exponentiation Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 35 5.8 Root Extraction Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 35 5.9 Number Theoretic Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::: 36 5.10 Comparison Functions::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 39 5.11 Logical and Bit Manipulation Functions ::::::::::::::::::::::::::::::::::::::::: 39 5.12 Input and Output Functions::::::::::::::::::::::::::::::::::::::::::::::::::::: 40 ii MPIR 3.0.0 5.13 Random Number Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::: 41 5.14 Integer Import and Export :::::::::::::::::::::::::::::::::::::::::::::::::::::: 41 5.15 Miscellaneous Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 43 5.16 Special Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 43 6 Rational Number Functions ::::::::::::::::::::::::::::::::: 46 6.1 Initialization and Assignment Functions :::::::::::::::::::::::::::::::::::::::::: 46 6.2 Conversion Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 47 6.3 Arithmetic Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 47 6.4 Comparison Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 48 6.5 Applying Integer Functions to Rationals :::::::::::::::::::::::::::::::::::::::::: 48 6.6 Input and Output Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::: 49 7 Floating-point Functions::::::::::::::::::::::::::::::::::::: 50 7.1 Initialization Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 50 7.2 Assignment Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 52 7.3 Combined Initialization and Assignment Functions :::::::::::::::::::::::::::::::: 53 7.4 Conversion Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 53 7.5 Arithmetic Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 54 7.6 Comparison Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 55 7.7 Input and Output Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::: 55 7.8 Miscellaneous Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 56 8 Low-level Functions :::::::::::::::::::::::::::::::::::::::::: 58 8.1 Nails ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 65 9 Random Number Functions ::::::::::::::::::::::::::::::::: 67 9.1 Random State Initialization :::::::::::::::::::::::::::::::::::::::::::::::::::::: 67 9.2 Random State Seeding ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 68 9.3 Random State Miscellaneous ::::::::::::::::::::::::::::::::::::::::::::::::::::: 68 10 Formatted Output :::::::::::::::::::::::::::::::::::::::::: 69 10.1 Format Strings :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 69 10.2 Functions ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 71 10.3 C++ Formatted Output::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 72 11 Formatted Input :::::::::::::::::::::::::::::::::::::::::::: 74 11.1 Formatted Input Strings::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 74 11.2 Formatted Input Functions :::::::::::::::::::::::::::::::::::::::::::::::::::::: 76 11.3 C++ Formatted Input :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 76 12 C++ Class Interface :::::::::::::::::::::::::::::::::::::::: 78 12.1 C++ Interface General :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 78 12.2 C++ Interface Integers :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 79 12.3 C++ Interface Rationals :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 80 12.4 C++ Interface Floats ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 82 12.5 C++ Interface Random Numbers:::::::::::::::::::::::::::::::::::::::::::::::: 84 12.6 C++ Interface Limitations :::::::::::::::::::::::::::::::::::::::::::::::::::::: 85 iii 13 .Net Interface ::::::::::::::::::::::::::::::::::::::::::::::: 87 13.1 MPIR.Net Feature Overview :::::::::::::::::::::::::::::::::::::::::::::::::::: 87 13.2 Building MPIR.Net ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 90 13.3 MPIR.Net Integers :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 13.4 MPIR.Net Rationals :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 97 13.5 MPIR.Net Floats :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 100 13.6 MPIR.Net Random Numbers ::::::::::::::::::::::::::::::::::::::::::::::::::: 104 13.7 MPIR.Net Settings::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 105 14 Custom Allocation::::::::::::::::::::::::::::::::::::::::: 106 15 Language Bindings :::::::::::::::::::::::::::::::::::::::: 108 16 Algorithms ::::::::::::::::::::::::::::::::::::::::::::::::: 111 16.1 Multiplication:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 111 16.1.1 Basecase Multiplication ::::::::::::::::::::::::::::::::::::::::::::::::::: 111 16.1.2 Karatsuba Multiplication :::::::::::::::::::::::::::::::::::::::::::::::::: 112 16.1.3 Toom 3-Way Multiplication ::::::::::::::::::::::::::::::::::::::::::::::: 113 16.1.4 Toom 4-Way Multiplication ::::::::::::::::::::::::::::::::::::::::::::::: 115 16.1.5 FFT Multiplication:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 115 16.1.6 Other Multiplication :::::::::::::::::::::::::::::::::::::::::::::::::::::: 117 16.1.7 Unbalanced Multiplication::::::::::::::::::::::::::::::::::::::::::::::::: 117 16.2 Division Algorithms ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Recommended publications
  • The Qtiplot Handbook I
    The QtiPlot Handbook i The QtiPlot Handbook The QtiPlot Handbook ii Copyright © 2004 - 2011 Ion Vasilief Copyright © 2010 Stephen Besch Copyright © 2006 - june 2007 Roger Gadiou and Knut Franke Legal notice: Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documen- tation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. The QtiPlot Handbook iii COLLABORATORS TITLE : The QtiPlot Handbook ACTION NAME DATE SIGNATURE WRITTEN BY Ion Vasilief and 22 February 2011 Stephen Besch REVISION HISTORY NUMBER DATE DESCRIPTION NAME The QtiPlot Handbook iv Contents 1 Introduction 1 1.1 What QtiPlot does...................................................1 1.2 Command Line Parameters..............................................1 1.2.1 Specify a File.................................................1 1.2.2 Command Line Options...........................................2 1.3 General Concepts and Terms.............................................2 1.3.1 Tables.....................................................4 1.3.2 Matrix.....................................................5 1.3.3 Plot Window.................................................6 1.3.4 Note......................................................7 1.3.5 Log Window.................................................8 1.3.6 The Project Explorer.............................................9 2 Drawing plots with QtiPlot 10 2.1 2D
    [Show full text]
  • A CPS-Based Simulation Platform for Long Production Factories
    metals Article A CPS-Based Simulation Platform for Long Production Factories Vincenzo Iannino 1, Valentina Colla 1,*, Joachim Denker 2 and Marc Göttsche 2 1 Scuola Superiore Sant’Anna, TeCIP Institute ICT-COISP Center, Via Moruzzi 1, 56124 Pisa, Italy; [email protected] 2 ASINCO GbbH—Advanced Solutions for Industrial Control Am Kiekenbusch 11a, 47269 Duisburg, Germany; [email protected] (J.D.); [email protected] (M.G.) * Correspondence: [email protected]; Tel.: +39-050-882-328 Received: 21 August 2019; Accepted: 19 September 2019; Published: 21 September 2019 Abstract: Production technology in European steel industry has reached such a level, that significant improvements can only be reached by through process optimization strategies instead of separately improving each process step. Therefore, the connection of suitable technological models to describe process and product behavior, methods to find solutions for typical multi-criterial decisions, and a strong communication between involved plants is necessary. In this work, a virtual simulation platform for the design of cyber-physical production optimization systems for long production facilities focusing on thermal evolution and related material quality is presented. Models for describing physical processes, computers, software and networks as well as methods and algorithms for through process optimization were implemented and merged into a new and comprehensive model-based software architecture. Object-oriented languages are addressed and used because they provide modularity, a high-level of abstraction and constructs that allow direct implementation and usage of the cyber-physical production systems concepts. Simulation results show how the proper connection between models, communication, and optimization methods allows feasibility, safety and benefits of cyber-physical production systems to be established.
    [Show full text]
  • A Tool for Click Data Preprocessing
    Faculty of Science Institute of Computing and Information Science Master Thesis A tool for click data preprocessing by Marc Pieterse [email protected] Supervisor: Prof. Dr. Ir. Th. P. van der Weide Second Reader: Dr. P. van Bommel Nijmegen, Version date: 21 June, 2010 Graduation number : 124 In memory of Hans Pieterse Preface This process for me, graduating, especially in the beginning was like the great journey of a rocket leaving the Earth's atmosphere. Uncertain whether the launch would succeed. Uncertain about its chosen trajectory and uncertain about reaching its destiny: space. After a bumpy launch, the project finally kicked off. The further the rocket got, the more obstacles it had to face, so during the journey, there were times when I thought: "Houston, we have a problem!!". Luck- ily for me, I had a very stable mission control that stayed very calm and flexible. This person for me was Prof. Dr. Ir. Theo van der Weide and I hereby would like to express my gratitude for his patience, advice and support during the last two years. Not only for my supervision, but also for all his work regarding interna- tional cooperation that allowed so many students (myself included) to experience ICT in different cultures. Eventually the rocket left the Earth's atmosphere. Thereby escaping from its gravitational field: finding itself free to choose a new destination. - Marc Pieterse Special thanks go out to: • Prof. Dr. Ir. Th.P. van der Weide • Dr. P. van Bommel • M. Hermsen • M. Hinne • T. Leijten • J. Schepens • I. Schreurs • P. Tenb¨ult • Family and Friends v Abstract Keywords: IR, click data, Singular Value Decomposition, preprocessing, filtering, large matrices, sparse matrices, numerical stability, SVDLIBC This Master Thesis for Information Science describes the design and imple- mentation of a tool that performs Information Retrieval (IR) techniques on click data.
    [Show full text]
  • Arxiv:2003.10146V2 [Cs.LG] 17 May 2020 2 a Brief Introduction to the Julia Language6
    Julia Language in Machine Learning: Algorithms, Applications, and Open Issues Kaifeng Gaoa, Gang Meia,∗, Francesco Picciallib,∗, Salvatore Cuomob,∗, Jingzhi Tua, Zenan Huoa aSchool of Engineering and Technology, China University of Geosciences (Beijing), 100083, Beijing, China bDepartment of Mathematics and Applications R. Caccioppoli, University of Naples Federico II, Naples, Italy Abstract Machine learning is driving development across many fields in science and engineering. A simple and effi- cient programming language could accelerate applications of machine learning in various fields. Currently, the programming languages most commonly used to develop machine learning algorithms include Python, MATLAB, and C/C ++. However, none of these languages well balance both efficiency and simplicity. The Julia language is a fast, easy-to-use, and open-source programming language that was originally designed for high-performance computing, which can well balance the efficiency and simplicity. This paper sum- marizes the related research work and developments in the applications of the Julia language in machine learning. It first surveys the popular machine learning algorithms that are developed in the Julia language. Then, it investigates applications of the machine learning algorithms implemented with the Julia language. Finally, it discusses the open issues and the potential future directions that arise in the use of the Julia language in machine learning. Keywords: Julia language, Machine learning, Supervised learning, Unsupervised learning, Deep learning, Artificial neural networks Contents 1 Introduction 4 arXiv:2003.10146v2 [cs.LG] 17 May 2020 2 A Brief Introduction to the Julia Language6 3 Julia in Machine Learning: Algorithms7 3.1 Overview . .7 ∗Corresponding author Email addresses: [email protected] (Gang Mei), [email protected] (Francesco Piccialli), [email protected] (Salvatore Cuomo) Preprint submitted to Computer Science Review May 19, 2020 3.2 Supervised Learning Algorithms Developed in Julia .
    [Show full text]
  • Introduction to Computational Techniques
    Chapter 2 Introduction to Computational Techniques Computational techniques are fast, easier, reliable and efficient way or method for solving mathematical, scientific, engineering, geometrical, geographical and statis- tical problems via the aid of computers. Hence, the processes of resolving problems in computational technique are most time step-wise. The step-wise procedure may entail the use of iterative, looping, stereotyped or modified processes which are incomparably less stressful than solving problems-manually. Sometimes, compu- tational techniques may also focus on resolving computation challenges or issues through the use of algorithm, codes or command-line. Computational technique may contain several parameters or variables that characterize the system or model being studied. The inter-dependency of the variables is tested with the system in form of simulation or animation to observe how the changes in one or more parameters affect the outcomes. The results of the simulations, animation or arrays of numbers are used to make predictions about what will happen in the real system that is being studied in response to changing conditions. Due to the adoption of computers into everyday task, computational techniques are redefined in various disciplines to accommodate specific challenges and how they can be resolved. Fortunately, computational technique encourages multi-tasking and interdisciplinary research. Since computational technique is used to study a wide range of complex systems, its importance in environmental disciplines is to aid the interpretation of field measurements with the main focus of protecting life, prop- erty, and crops. Also, power-generating companies that rely on solar, wind or hydro sources make use of computational techniques to optimize energy production when extreme climate shifts are expected.
    [Show full text]
  • Free Download of the 'ALGLIB
    ... Log in Sign up >> WebTerminal Documentation Calendar CodeBase Articles Freelance Market MetaTrader 5 / Libraries ALGLIB ‐ Numerical Analysis Library ‐ library for MetaTrader 5 Sergey Bochkanov 22947 (98) Real author: Sergey Bochkanov. ALGLIB project website ‐ http://www.alglib.net/. The library dates back to 1999. ALGLIB is one of the largest and most complete mathematical libraries Do you need to make a fast Fourier transform or to solve a differential equation system? Do you perform a complex data analysis trying to gather all methods in one place as a source code? Then ALGLIB library of numerical methods is for you! ALGLIB is currently one of the best libraries of the multi‐language algorithms. Below are ALGLIB features mentioned on the official website: ALGLIB is a cross‐platform numerical analysis and data processing library. It supports several programming languages (C++, C#, Pascal, VBA) and several operating systems (Windows, Linux, Solaris). ALGLIB features include: Linear algebra (direct algorithms, EVD/SVD) Solvers (linear and nonlinear) Interpolation Optimization Fast Fourier transforms Numerical integration Linear and nonlinear least‐squares fitting Ordinary differential equations Special functions Statistics (descriptive statistics, hypothesis testing) Data analysis (classification/regression, including neural networks) Multiple precision versions of linear algebra, interpolation optimization and others algorithms (using MPFR for floating point computations) Why to choose ALGLIB? Because it is: portable. It can be compiled almost anywhere using almost any compiler (see compatibility matrix for more info). easy to use. It supports many programming languages. If you use one language, you don't need to study another (FORTRAN, for example) to compile and link an external library.
    [Show full text]
  • Acceleration of Numerical Solutions of Differential Equations Using FPGA
    Faculty Of Engineering Computer and Systems Engineering Department Acceleration of Numerical Solutions of Differential Equations Using FPGA-Based Emulation Technology Authors: Mohamed Tarek Ibn Ziad Supervisors: Mohamed Hossam ElDin Dr. Yousra Alkabani Mohamed Ahmad AbdElAziz Dr. Watheq El-Kharashi Mohamed Nagy Eliwa Hesham Ahmad Adel A thesis submitted in Partial Fulfillment of the Requirement for the B.Sc. Degree Computer and Systems Engineering Department, Faculty of Engineering, Ain Shams University, Cairo, Egypt July 2014 Ain Shams University Abstract Faculty Of Engineering Computer and Systems Engineering Department B.Sc. Acceleration of Numerical Solutions of Differential Equations Using FPGA-Based Emulation Technology by Mohamed Tarek Ibn Ziad Mohamed Hossam ElDin Mohamed Ahmad AbdElAziz Mohamed Nagy Eliwa Hesham Ahmad Adel Numerical analysis is the study of algorithms that use numerical approximation (as opposed to general symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). Typical applications of numerical PDE problems include but are not limited to simulation and modeling problems. In typical numerical methods such as Finite Element Methods (FEM), PDEs are dis- cretized in space to bring them into finite-dimensional subspace and solved by standard linear algebra subroutines. Spatial discretization could easily result in millions, even bil- lions, of discrete grid points, which correspond to large linear system equations with the same number of unknowns. If the problem was time-dependent, in order to simulate the transient behavior of the problem, we may need to solve the linear system equations for hundreds to thousands of discrete time steps. So, implementation of numerical solutions using software is very time consuming.
    [Show full text]