multiprecision

Outputting values from CAMPARY

被刻印的时光 ゝ 提交于 2021-02-08 10:22:06
问题 I'm trying to use the CAMPARY library (CudA Multiple Precision ARithmetic librarY). I've downloaded the code and included it in my project. Since it supports both cpu and gpu, I'm starting with cpu to understand how it works and make sure it does what I need. But the intent is to use this with CUDA. I'm able to instantiate an instance and assign a value, but I can't figure out how to get things back out. Consider: #include <time.h> #include "c:\\vss\\CAMPARY\\Doubles\\src_cpu\\multi_prec.h"

Writing boost::multiprecision data type to binary file

两盒软妹~` 提交于 2021-01-28 04:02:18
问题 I was using the boost::multiprecision::uint128_t type in order to perform bitwise operations on a 128 bit value. However I am having trouble writing the 128 bit value out to a binary file. Specifically with the need to pad out the value with zeros. As an example if the uint128_t value was 0x123456 then looking at the file in the hex editor I would want the sequence: 56 34 12 00 00 00 00 00 00 00 00 00 00 00 00 00 #include <boost/multiprecision/cpp_int.hpp> #include <fstream> boost:

How many 64-bit multiplications are needed to calculate the low 128-bits of a 64-bit by 128-bit product?

感情迁移 提交于 2020-11-24 16:39:00
问题 Consider that you want to calculate the low 128-bits of the result of multiplying a 64-bit and 128-bit unsigned number, and that the largest multiplication you have available is the C-like 64-bit multiplication which takes two 64-bit unsigned inputs and returns the low 64-bits of the result. How many multiplications are needed? Certainly you can do it with eight: break all the inputs up into 32-bit chunks and use your 64-bit multiplication to do the 4 * 2 = 8 required full-width 32*32->64

How many 64-bit multiplications are needed to calculate the low 128-bits of a 64-bit by 128-bit product?

老子叫甜甜 提交于 2020-11-24 16:38:26
问题 Consider that you want to calculate the low 128-bits of the result of multiplying a 64-bit and 128-bit unsigned number, and that the largest multiplication you have available is the C-like 64-bit multiplication which takes two 64-bit unsigned inputs and returns the low 64-bits of the result. How many multiplications are needed? Certainly you can do it with eight: break all the inputs up into 32-bit chunks and use your 64-bit multiplication to do the 4 * 2 = 8 required full-width 32*32->64

multi-precision multiplication in CUDA

一笑奈何 提交于 2020-01-26 04:27:09
问题 I am trying to implement multi-precision multiplication in CUDA. For doing that, I have implemented a kernel which should compute multiplication of uint32_t type operand with 256-bit operand and put the result in 288-bit array. So far, I have came up with this code: __device__ __constant__ UN_256fe B_const; __global__ void multiply32x256Kernel(uint32_t A, UN_288bite* result){ uint8_t tid = blockIdx.x * blockDim.x + threadIdx.x; //for managing warps //uint8_t laineid = tid % 32; //allocate

can multiprecision signed multiply be performed with imul instruction?

别等时光非礼了梦想. 提交于 2019-12-24 06:58:46
问题 I am writing a function library to provide all conventional operators and functions for signed-integer types s0128 , s0256 , s0512 , s1024 and floating-point types f0128 , f0256 , f0512 , f1024 . I am writing the s0128 , s0256 , s0512 , s1024 multiply routines now, but am getting erroneous results that confuse me. I assumed I could cascade multiplies with the 64-bit imul rcx instruction (that produces a 128-bit result in rdx:rax ) in the same way I could do the same with unsigned operands

How to use sqrt and ceil with Boost::multiprecision?

☆樱花仙子☆ 提交于 2019-12-19 22:01:06
问题 Do you know how to do this simple line of code without error using Boost::multiprecison ? boost::multiprecision::cpp_int v, uMax, candidate; //... v += 6 * ceil((sqrt(uMax * uMax - candidate) - v) / 6); Using MSVC there is an error for "sqrt" and it's possible to fix it with: v += 6 * ceil((sqrt(static_cast<boost::multiprecision::cpp_int>(uMax * uMax - candidate)) - v) / 6); Then there is an error for "ceil" and it's possible to fix it with: namespace bmp = boost::multiprecision; typedef bmp:

Multiword addition in C

一笑奈何 提交于 2019-12-18 07:00:32
问题 I have a C program which uses GCC's __uint128_t which is great, but now my needs have grown beyond it. What are my options for fast arithmetic with 196 or 256 bits? The only operation I need is addition (and I don't need the carry bit, i.e., I will be working mod 2 192 or 2 256 ). Speed is important, so I don't want to move to a general multi-precision if at all possible. (In fact my code does use multi-precision in some places, but this is in the critical loop and will run tens of billions

higher precision floating point using boost lib (higher then 16 digits)

泄露秘密 提交于 2019-12-17 20:12:04
问题 I am running a simulation of physical experiments, so I need really high floating point precision (more than 16 digits). I use Boost.Multiprecision, however I can't get a precision higher than 16 digits, no matter what I tried. I run the simulation with C++ and eclipse compiler, for example: #include <boost/math/constants/constants.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> #include <iostream> #include <limits> using boost::multiprecision::cpp_dec_float_50; void main() { cpp_dec

Boost multiprecision : Recursive template instantiation exceeded maximum length 256

元气小坏坏 提交于 2019-12-11 11:34:00
问题 Trying to play a little bit with boost's multiprecision numbers I got the following error In file included from main.cpp:1: In file included from /usr/include/boost/multiprecision/cpp_int.hpp:12: In file included from /usr/include/boost/multiprecision/number.hpp:16: In file included from /usr/include/boost/type_traits/is_signed.hpp:15: In file included from /usr/include/boost/type_traits/is_enum.hpp:14: In file included from /usr/include/boost/type_traits/intrinsics.hpp:149: /usr/include