arbitrary-precision

Find exact solutions to Linear Program

这一生的挚爱 提交于 2019-12-22 10:28:37
问题 I need to find an exact real solution to a linear program (where all inputs are integers). It is important that the solver also outputs the solutions as rational numbers, ideally without doing any intermediate steps with floating point numbers. GLPK can do exact arithmetic, but cannot display the solutions as rational numbers (i.e. I get 0.3333 for 1/3). I could probably attempt to guess which number is meant by that, but that seems very fragile. I was unable to find an LP solver that can do

Get GCC To Use Carry Logic For Arbitrary Precision Arithmetic Without Inline Assembly?

ぐ巨炮叔叔 提交于 2019-12-21 01:07:22
问题 When working with arbitrary precision arithmetic (e.g. 512-bit integers), is there any way to get GCC to use ADC and similar instructions without using inline assembly? A first glance at GMP's sourcecode shows that they simply have assembly implementations for every supported platform. Here is the test code I wrote, which adds two 128-bit numbers from the command line and prints the result. (Inspired by mini-gmp's add_n): #include <stdio.h> #include <stdint.h> #include <stdlib.h> int main

SIMD versions of SHLD/SHRD instructions

白昼怎懂夜的黑 提交于 2019-12-19 02:51:29
问题 SHLD/SHRD instructions are assembly instructions to implement multiprecisions shifts. Consider the following problem: uint64_t array[4] = {/*something*/}; left_shift(array, 172); right_shift(array, 172); What is the most efficient way to implement left_shift and right_shift , two functions that operates a shift on an array of four 64-bit unsigned integer as if it was a big 256 bits unsigned integer? Is the most efficient way of doing that is by using SHLD/SHRD instructions, or is there better

Arbitrary-Precision Math in PHP

淺唱寂寞╮ 提交于 2019-12-18 19:07:25
问题 I'm currently trying to figure out how to work with arbitrary-precision numbers in PHP. So I guess my first question would be what exactly is arbitrary-precision math. I tried Googling for a good definition but for some reason nobody can put it in simple enough words. Second, what are the differences between the BCMath and GMP libraries in PHP? I've heard claims that GMP's API is "fresher", but idk. Is one better? And my final question would be what type of numbers BCMath/GMP takes. Obviously

Translation from Complex-FFT to Finite-Field-FFT

百般思念 提交于 2019-12-17 20:58:51
问题 Good afternoon! I am trying to develop an NTT algorithm based on the naive recursive FFT implementation I already have. Consider the following code ( coefficients ' length, let it be m , is an exact power of two): /// <summary> /// Calculates the result of the recursive Number Theoretic Transform. /// </summary> /// <param name="coefficients"></param> /// <returns></returns> private static BigInteger[] Recursive_NTT_Skeleton( IList<BigInteger> coefficients, IList<BigInteger> rootsOfUnity, int

Need Arbitrary-Precision-Arithmetic in C#

时光毁灭记忆、已成空白 提交于 2019-12-13 13:41:47
问题 I'm in need of floating point calculations for C# that can correctly store up to maybe 500 digits/decimals. Is there any built-in-type for this, do I have to create it myself, any library available or what is the best way to go? Thanks 回答1: MPIR, a fork of the GMP project, has C# bindings. Personally, I've found them easier to deal with when raising problems, to the point that I no longer worry about GMP (primarily due to its tendency to exit violently when running out of memory). There are

Logarithm of the very-very large number

為{幸葍}努か 提交于 2019-12-12 07:07:18
问题 I have to find log of very large number. I do this in C++ I have already made a function of multiplication, addition, subtraction, division, but there were problems with the logarithm. I do not need code, I need a simple idea how to do it using these functions. Thanks. P.S. Sorry, i forgot to tell you: i have to find only binary logarithm of that number P.S.-2 I found in Wikipedia: int floorLog2(unsigned int n) { if (n == 0) return -1; int pos = 0; if (n >= (1 <<16)) { n >>= 16; pos += 16; }

How can Javascript be used to divide a circle equally so that it's correct to 1,000,000,000% zoom?

佐手、 提交于 2019-12-12 06:11:51
问题 Split off from: https://stackoverflow.com/questions/31076846/is-it-possible-to-use-javascript-to-draw-an-svg-that-is-precise-to-1-000-000-000 Using floating point precision, there are rounding errors when calculating the position of points on a circle. Example: function pointsOnACircle (whichpoint, numberOfPoints, cx, cy, radius) { //Returns a point along the outside of a circle, starting at (whichpoint=1) = 0 degrees eachpoint = whichpoint * 2 * Math.PI /numberOfPoints; var thiscx = cx +

Laguerre polynomials in python using scipy, lack of convergence?

痞子三分冷 提交于 2019-12-11 22:21:05
问题 The laguerre polynomials don't seem to be converging at some orders as can be demonstrated by running the following code. import numpy as np from sympy import mpmath as mp from scipy.special import genlaguerre as genlag from sympy.mpmath import laguerre as genlag2 from matplotlib import pyplot as plt def laguerre(x, r_ord, phi_ord, useArbitraryPrecision=False): if (r_ord < 30 and phi_ord < 30) and not useArbitraryPrecision: polyCoef = genlag(r_ord, phi_ord) out = np.polyval(polyCoef, x) else:

“Multiplication of Arbitrary Precision Numbers” in Scheme

走远了吗. 提交于 2019-12-11 20:28:34
问题 The following is code to a problem that I have been working on for a few days. The problem I encountered is that for some reason when I call: (apa-multi '(7 3 1 2) '(6 1 4)) the return is: '(4 8 9 5 6 8) The answer that it should output is '(4 4 8 9 5 6 8) When I call: (apa-multi '(3 1 2) '(6 1 4)) The output is: '(1 9 1 5 6 8) which is correct. I have debugged my code multiple times, and I can't seem to find out what the problem is (by the way, I know that the "remove-empty" function that I