├── .gitignore ├── libtest ├── float │ ├── runAll.sh │ ├── Makefile │ └── Log2.cpp ├── posit16 │ ├── runAll.sh │ ├── Makefile │ ├── cbrt.cpp │ ├── exp.cpp │ ├── log.cpp │ ├── exp2.cpp │ ├── exp10.cpp │ ├── log10.cpp │ ├── log2.cpp │ ├── sqrt.cpp │ ├── sinpi.cpp │ └── cospi.cpp └── bfloat16 │ ├── runAll.sh │ ├── Makefile │ ├── Exp.cpp │ ├── Log.cpp │ ├── Cbrt.cpp │ ├── Cospi.cpp │ ├── Exp2.cpp │ ├── Log2.cpp │ ├── Sqrt.cpp │ ├── Exp10.cpp │ ├── Log10.cpp │ └── Sinpi.cpp ├── include ├── float_headers │ ├── Backup │ │ ├── sinpi.h │ │ ├── cospi.h │ │ └── NewHeaders │ │ │ ├── Log2.h │ │ │ └── Cosh.h │ ├── Cospi.h │ ├── Sinpi.h │ ├── Log10.h │ ├── Log2.h │ ├── Exp2.h │ ├── Cosh.h │ └── Sinh.h ├── posit16_math.h ├── float_math.h ├── bfloat16_math.hpp └── bfloat16.hpp ├── runLibTest.sh ├── source ├── posit16 │ ├── log2.cpp │ ├── log.cpp │ ├── log10.cpp │ ├── cospi.cpp │ ├── sinpi.cpp │ ├── exp2.cpp │ ├── exp.cpp │ ├── exp10.cpp │ └── sqrt.cpp ├── bfloat16 │ ├── log2.cpp │ ├── sqrt.cpp │ ├── log10.cpp │ ├── exp.cpp │ ├── exp10.cpp │ ├── log.cpp │ ├── exp2.cpp │ ├── cospi.cpp │ ├── sinpi.cpp │ └── cbrt.cpp └── float │ ├── log2.cpp │ ├── sinpi.cpp │ ├── log.cpp │ ├── exp.cpp │ ├── log10.cpp │ ├── exp2.cpp │ ├── exp10.cpp │ ├── cosh.cpp │ ├── sinh.cpp │ └── cospi.cpp ├── LICENSE ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | **/*~ -------------------------------------------------------------------------------- /libtest/float/runAll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Testing floating math library" 3 | echo "\nLOG2" 4 | ./Log2 5 | echo "" 6 | -------------------------------------------------------------------------------- /include/float_headers/Backup/sinpi.h: -------------------------------------------------------------------------------- 1 | #define Sinpi_C0 3.141592653589793560087173318606801331043243408203125; 2 | #define Sinpi_C1 -5.16771279001643080164285493083298206329345703125; 3 | #define Sinpi_C2 2.553889772018237636075355112552642822265625; 4 | -------------------------------------------------------------------------------- /include/float_headers/Backup/cospi.h: -------------------------------------------------------------------------------- 1 | double ZeroResult = 9.99999999624209490178827763884328305721282958984375e-01; 2 | 3 | #define Cospi_C0 1.0000000000000028865798640254070051014423370361328125 4 | #define Cospi_C1 -4.93480220691509430253063328564167022705078125 5 | #define Cospi_C2 4.0605714171214888352778871194459497928619384765625 6 | -------------------------------------------------------------------------------- /libtest/posit16/runAll.sh: -------------------------------------------------------------------------------- 1 | echo "Testing Bfloat16 math library" 2 | echo "COSPI" 3 | ./cospi 4 | echo "LOG" 5 | ./log 6 | echo "LOG2" 7 | ./log2 8 | echo "LOG10" 9 | ./log10 10 | echo "SINPI" 11 | ./sinpi 12 | echo "SQRT" 13 | ./sqrt 14 | echo "EXP" 15 | ./exp 16 | echo "EXP2" 17 | ./exp 18 | echo "EXP10" 19 | ./exp 20 | echo "" 21 | -------------------------------------------------------------------------------- /libtest/float/Makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | 3 | funcNames = Log2 4 | 5 | src = $(patsubst %, %.cpp, $(funcNames)) 6 | obj = $(patsubst %, %, $(funcNames)) 7 | 8 | all: $(obj) 9 | 10 | %: %.cpp 11 | $(CC) -std=c++11 -I../../helper/ -I../../include/ $^ ../../lib/floatMathLib.a -lm -lmpfr -lgmp -o $@ 12 | 13 | clean: 14 | rm -rf $(obj) *.dSYM 15 | -------------------------------------------------------------------------------- /libtest/posit16/Makefile: -------------------------------------------------------------------------------- 1 | objects = log2 log log10 sinpi cospi sqrt exp exp2 exp10 2 | 3 | all: $(objects) 4 | 5 | $(objects): %: %.cpp 6 | g++ -std=c++14 $^ -lm -lmpfr -lgmp ../../lib/posit16MathLib.a $(SOFTPOSITPATH)/build/Linux-x86_64-GCC/softposit.a -I$(SOFTPOSITPATH)/source/include -I../../include/ -o $@ 7 | 8 | 9 | clean: 10 | rm -rf $(objects) *.dSYM 11 | -------------------------------------------------------------------------------- /libtest/bfloat16/runAll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Testing Bfloat16 math library" 3 | echo "CBRT" 4 | ./Cbrt 5 | echo "COSPI" 6 | ./Cospi 7 | echo "EXP" 8 | ./Exp 9 | echo "EXP2" 10 | ./Exp2 11 | echo "EXP10" 12 | ./Exp10 13 | echo "LOG" 14 | ./Log 15 | echo "LOG2" 16 | ./Log2 17 | echo "LOG10" 18 | ./Log10 19 | echo "SINPI" 20 | ./Sinpi 21 | echo "SQRT" 22 | ./Sqrt 23 | echo "" 24 | -------------------------------------------------------------------------------- /include/float_headers/Cospi.h: -------------------------------------------------------------------------------- 1 | #define C0 1.0000000000000028865798640254070051014423370361328125000000000000000000000000000000000000000000000000e+00 2 | #define C1 -4.9348022069150943025306332856416702270507812500000000000000000000000000000000000000000000000000000000e+00 3 | #define C2 4.0605714171214888352778871194459497928619384765625000000000000000000000000000000000000000000000000000e+00 4 | -------------------------------------------------------------------------------- /include/float_headers/Sinpi.h: -------------------------------------------------------------------------------- 1 | #define S0 3.1415926535897935600871733186068013310432434082031250000000000000000000000000000000000000000000000000e+00 2 | #define S1 -5.1677127900164308016428549308329820632934570312500000000000000000000000000000000000000000000000000000e+00 3 | #define S2 2.5538897720182376360753551125526428222656250000000000000000000000000000000000000000000000000000000000e+00 4 | -------------------------------------------------------------------------------- /libtest/bfloat16/Makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | 3 | funcNames = Log2 Log Log10 Sinpi Cospi Sqrt Cbrt Exp Exp2 Exp10 4 | 5 | src = $(patsubst %, %.cpp, $(funcNames)) 6 | obj = $(patsubst %, %, $(funcNames)) 7 | 8 | all: $(obj) 9 | 10 | %: %.cpp 11 | $(CC) -std=c++14 $^ ../../lib/bfloat16MathLib.a -lm -lmpfr -lgmp -I../../helper/ -I../../include/ -o $@ 12 | 13 | clean: 14 | rm -rf $(obj) *.dSYM 15 | -------------------------------------------------------------------------------- /include/posit16_math.h: -------------------------------------------------------------------------------- 1 | #include "softposit.h" 2 | #include 3 | #include "math.h" 4 | 5 | typedef union { 6 | double d; 7 | unsigned long long x; 8 | } dint; 9 | 10 | posit16_t rlibm_cospi(posit16_t x); 11 | posit16_t rlibm_log(posit16_t x); 12 | posit16_t rlibm_log2(posit16_t x); 13 | posit16_t rlibm_log10(posit16_t x); 14 | posit16_t rlibm_sinpi(posit16_t x); 15 | posit16_t rlibm_sqrt(posit16_t x); 16 | posit16_t rlibm_exp(posit16_t x); 17 | posit16_t rlibm_exp2(posit16_t x); 18 | posit16_t rlibm_exp10(posit16_t x); 19 | -------------------------------------------------------------------------------- /include/float_math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | typedef union { 6 | double d; 7 | uint64_t x; 8 | } doubleX; 9 | 10 | typedef union { 11 | float f; 12 | unsigned int x; 13 | } floatX; 14 | 15 | float rlibm_log(float); 16 | float rlibm_log2(float); 17 | float rlibm_log10(float); 18 | float rlibm_exp(float); 19 | float rlibm_exp2(float); 20 | float rlibm_exp10(float); 21 | float rlibm_sinh(float); 22 | float rlibm_cosh(float); 23 | float rlibm_sinpi(float); 24 | float rlibm_cospi(float); 25 | -------------------------------------------------------------------------------- /include/bfloat16_math.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bfloat16.hpp" 3 | #include 4 | 5 | typedef union { 6 | double d; 7 | uint64_t x; 8 | } dx; 9 | 10 | typedef union { 11 | float f; 12 | unsigned int x; 13 | } fx; 14 | 15 | bfloat16 rlibm_exp(bfloat16); 16 | bfloat16 rlibm_exp2(bfloat16); 17 | bfloat16 rlibm_exp10(bfloat16); 18 | bfloat16 rlibm_log(bfloat16); 19 | bfloat16 rlibm_log2(bfloat16); 20 | bfloat16 rlibm_log10(bfloat16); 21 | bfloat16 rlibm_sinpi(bfloat16); 22 | bfloat16 rlibm_cospi(bfloat16); 23 | bfloat16 rlibm_sqrt(bfloat16); 24 | bfloat16 rlibm_cbrt(bfloat16); 25 | -------------------------------------------------------------------------------- /include/float_headers/Log10.h: -------------------------------------------------------------------------------- 1 | #define C0 4.3429448190365405046975411096354946494102478027343750000000000000000000000000000000000000000000000000e-01 2 | #define C1 -2.1714724168578289353881416445801733061671257019042968750000000000000000000000000000000000000000000000e-01 3 | #define C2 1.4476512372779321013993580891110468655824661254882812500000000000000000000000000000000000000000000000e-01 4 | #define C3 -1.0861350240983312642750746590536436997354030609130859375000000000000000000000000000000000000000000000e-01 5 | #define C4 8.7979072619215642481194095125829335302114486694335937500000000000000000000000000000000000000000000000e-02 6 | -------------------------------------------------------------------------------- /runLibTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | echo -e "\033[1mBuilding math libraries \033[0m" 5 | make -s clean 6 | make -s 7 | 8 | 9 | echo -e "\033[1mTesting bfloat16 math library correctness \033[0m" 10 | cd libtest/bfloat16 11 | make -s clean 12 | make -s 13 | ./runAll.sh 14 | make -s clean 15 | 16 | 17 | echo -e "\033[1mTesting posit16 math library correctness \033[0m" 18 | cd ../posit16 19 | make -s clean 20 | make -s 21 | ./runAll.sh 22 | make -s clean 23 | 24 | 25 | echo -e "\033[1mTesting float math library correctness \033[0m" 26 | cd ../float 27 | make -s clean 28 | make -s 29 | ./runAll.sh 30 | make -s clean 31 | 32 | 33 | cd ../.. 34 | -------------------------------------------------------------------------------- /include/float_headers/Log2.h: -------------------------------------------------------------------------------- 1 | //#define bitsSame 7 2 | //#define N 0 3 | #define C0 1.4426950408983432172504990376182831823825836181640625000000000000000000000000000000000000000000000000e+00 4 | #define C1 -7.2134753829891251619699232833227142691612243652343750000000000000000000000000000000000000000000000000e-01 5 | #define C2 4.8090713122852124516981575652607716619968414306640625000000000000000000000000000000000000000000000000e-01 6 | #define C3 -3.6229559281288897798489756496564950793981552124023437500000000000000000000000000000000000000000000000e-01 7 | #define C4 3.8662151480904477507394290114461909979581832885742187500000000000000000000000000000000000000000000000e-01 8 | -------------------------------------------------------------------------------- /include/float_headers/Backup/NewHeaders/Log2.h: -------------------------------------------------------------------------------- 1 | unsigned bitsSame = 7; 2 | unsigned N = 0 3 | double coeffs[1][5] = { 4 | { 5 | 1.4426950408983432172504990376182831823825836181640625000000000000000000000000000000000000000000000000e+00, 6 | -7.2134753829891251619699232833227142691612243652343750000000000000000000000000000000000000000000000000e-01, 7 | 4.8090713122852124516981575652607716619968414306640625000000000000000000000000000000000000000000000000e-01, 8 | -3.6229559281288897798489756496564950793981552124023437500000000000000000000000000000000000000000000000e-01, 9 | 3.8662151480904477507394290114461909979581832885742187500000000000000000000000000000000000000000000000e-01 10 | } 11 | }; 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/posit16/log2.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_log2(posit16_t x) { 4 | if (x.v == 0x0 || x.v >= 0x8000) { 5 | // If x == 0, NaR, or negative, then resutl should be NaR 6 | x.v = 0x8000; 7 | return x; 8 | } 9 | 10 | // Extract exponent and mantissa (where mantissa is between [1, 2)) 11 | int m; 12 | double fx = frexp(convertP16ToDouble(x), &m); 13 | fx *= 2.0; 14 | m--; 15 | 16 | // Cody and Waite Transformation on input 17 | double dx = fx; 18 | double codyX = (dx - 1) / (dx + 1); 19 | 20 | double codyX2 = codyX * codyX; 21 | // Now compute polynomial 22 | double y = 6.8022527114824737903830964569351635873317718505859375e-01; 23 | y *= codyX2; 24 | y += 3.36729567454907396939489672149647958576679229736328125e-01; 25 | y *= codyX2; 26 | y += 5.827497609092706642996972732362337410449981689453125e-01; 27 | y *= codyX2; 28 | y += 9.616405555684151007511673014960251748561859130859375e-01; 29 | y *= codyX2; 30 | y += 2.88539115994917327867597123258747160434722900390625; 31 | y *= codyX; 32 | y += (double)m; 33 | 34 | return convertDoubleToP16(y); 35 | } 36 | -------------------------------------------------------------------------------- /source/bfloat16/log2.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_log2(bfloat16 x) { 4 | // If x == 0, then it should be -inf 5 | if (x.val == 0x0 || x.val == 0x8000) { 6 | x.val = 0xFF80; 7 | return x; 8 | } 9 | 10 | // If x == inf, then it should be infinity 11 | if (x.val == 0x7f80) { 12 | return x; 13 | } 14 | 15 | // If x == NaN or negative, then it should be NaN 16 | if (x.val > 0x7F80) { 17 | x.val = 0xFFFF; 18 | return x; 19 | } 20 | 21 | float fInput = (float)x; 22 | 23 | // Extract exponent and mantissa (where mantissa is between [1, 2) 24 | int m; 25 | float fx = frexpf(fInput, &m); 26 | fx *= 2.0; 27 | m--; 28 | 29 | // Cody and Waite Transformation on input 30 | double dx = (double)fx; 31 | double codyX = (dx - 1) / (dx + 1); 32 | double codyX2 = codyX * codyX; 33 | 34 | // Now compute polynomial 35 | double y = 7.307375337145580740383365991874597966670989990234375e-01; 36 | y *= codyX2; 37 | y += 9.477394346709135941608792563783936202526092529296875e-01; 38 | y *= codyX2; 39 | y += 2.885725930059220178947043677908368408679962158203125; 40 | y *= codyX; 41 | y += (double)m; 42 | return y; 43 | } 44 | -------------------------------------------------------------------------------- /source/posit16/log.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_log(posit16_t x) { 4 | if (x.v == 0x0 || x.v >= 0x8000) { 5 | // If x == 0, NaR, or negative, then resutl should be NaR 6 | x.v = 0x8000; 7 | return x; 8 | } 9 | 10 | // Extract exponent and mantissa (where mantissa is between [1, 2) 11 | int m; 12 | double fx = frexp(convertP16ToDouble(x), &m); 13 | fx *= 2.0; 14 | m--; 15 | 16 | // Cody and Waite Transformation on input 17 | double dx = fx; 18 | double codyX = (dx - 1) / (dx + 1); 19 | double codyX2 = codyX * codyX; 20 | 21 | // Now compute polynomial 22 | double y = 4.5254178489671204044242358577321283519268035888671875e-01; 23 | y *= codyX2; 24 | y += 3.9449243216490248453709455134230665862560272216796875e-01; 25 | y *= codyX2; 26 | y += 5.7802192858859535729010303839459083974361419677734375e-01; 27 | y *= codyX2; 28 | y += 9.6177728824005104257821585633791983127593994140625e-01; 29 | y *= codyX2; 30 | y += 2.8853901812623536926594169926829636096954345703125; 31 | y *= codyX; 32 | 33 | // Range propagation 34 | y = (m + y) / 1.442695040888963387004650940070860087871551513671875; 35 | 36 | return convertDoubleToP16(y); 37 | } 38 | -------------------------------------------------------------------------------- /source/posit16/log10.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_log10(posit16_t x) { 4 | if (x.v == 0x0 || x.v >= 0x8000) { 5 | // If x == 0, NaR, or negative, then resutl should be NaR 6 | x.v = 0x8000; 7 | return x; 8 | } 9 | 10 | // Extract exponent and mantissa (where mantissa is between [1, 2) 11 | int m; 12 | double fx = frexp(convertP16ToDouble(x), &m); 13 | fx *= 2.0; 14 | m--; 15 | 16 | // Cody and Waite Transformation on input 17 | double dx = fx; 18 | double codyX = (dx - 1) / (dx + 1); 19 | double codyX2 = codyX * codyX; 20 | 21 | // Now compute polynomial 22 | double y = 6.91650888349585102332639507949352264404296875e-01; 23 | y *= codyX2; 24 | y += 3.30016589138880600540204568460467271506786346435546875e-01; 25 | y *= codyX2; 26 | y += 5.837756666515827586039222296676598489284515380859375e-01; 27 | y *= codyX2; 28 | y += 9.6158476800643521986700079651200212538242340087890625e-01; 29 | y *= codyX2; 30 | y += 2.885392110906054075059046226670034229755401611328125; 31 | y *= codyX; 32 | 33 | // Range propagation 34 | y = (m + y) / 3.321928094887362181708567732130177319049835205078125; 35 | 36 | return convertDoubleToP16(y); 37 | } 38 | -------------------------------------------------------------------------------- /source/bfloat16/sqrt.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_sqrt(bfloat16 x) { 4 | 5 | // If x == 0, then it should be 0 6 | if (x.val == 0x0 || x.val == 0x8000) { 7 | return x; 8 | } 9 | 10 | // If x == inf, then it should be infinity 11 | if (x.val == 0x7f80) { 12 | return x; 13 | } 14 | 15 | // If x == NaN or negative, then it should be NaN 16 | if (x.val > 0x7F80) { 17 | x.val = 0xFFFF; 18 | return x; 19 | } 20 | 21 | 22 | // Extract exponent and mantissa (where mantissa is between [1, 4)) 23 | int m; 24 | float fx = frexpf((float)x, &m); 25 | fx *= 2.0; 26 | m--; 27 | 28 | if ((m & 0x1) == 1) { 29 | fx *= 2.0; 30 | m--; 31 | } 32 | 33 | m >>= 1; 34 | 35 | // Now compute polynomial 36 | double y = -3.0848915765425755954043385287377532222308218479156494140625e-03; 37 | y *= fx; 38 | y += 3.800384608453956369888970812098705209791660308837890625e-02; 39 | y *= fx; 40 | y += -1.99230719933062794257949690290843136608600616455078125e-01; 41 | y *= fx; 42 | y += 7.923315194006106398916244870633818209171295166015625e-01; 43 | y *= fx; 44 | y += 3.7202139260816802224240973373525775969028472900390625e-01; 45 | 46 | return ldexp(y, m); 47 | } 48 | -------------------------------------------------------------------------------- /source/bfloat16/log10.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_log10(bfloat16 x) { 4 | // If x == 0, then it should be -inf 5 | if (x.val == 0x0 || x.val == 0x8000) { 6 | x.val = 0xFF80; 7 | return x; 8 | } 9 | 10 | // If x == inf, then it should be infinity 11 | if (x.val == 0x7f80) { 12 | return x; 13 | } 14 | 15 | // If x == NaN or negative, then it should be NaN 16 | if (x.val > 0x7F80) { 17 | x.val = 0xFFFF; 18 | return x; 19 | } 20 | 21 | float fInput = (float)x; 22 | 23 | // Extract exponent and mantissa (where mantissa is between [1, 2) 24 | int m; 25 | float fx = frexpf(fInput, &m); 26 | fx *= 2.0; 27 | m--; 28 | 29 | // Cody and Waite Transformation on input 30 | double dx = (double)fx; 31 | double codyX = (dx - 1) / (dx + 1); 32 | double codyX2 = codyX * codyX; 33 | 34 | // Now compute polynomial 35 | double y = 6.710954935542725596775426311069168150424957275390625e-01; 36 | y *= codyX2; 37 | y += 9.56484867363945223672772044665180146694183349609375e-01; 38 | y *= codyX2; 39 | y += 2.88545942229525831379532974096946418285369873046875; 40 | y *= codyX; 41 | 42 | // Range propagation 43 | y = (m + y) / 3.321928094887362181708567732130177319049835205078125; 44 | return y; 45 | } 46 | -------------------------------------------------------------------------------- /source/bfloat16/exp.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_exp(bfloat16 x) { 4 | float fInput = (float)x; 5 | 6 | // Take care of 0 case 7 | if (fInput <= -93.0f) { 8 | return 0.0; 9 | } 10 | 11 | // Take care of infinity case 12 | if (fInput >= 89.0f) { 13 | x.val = 0x7F80; 14 | return x; 15 | } 16 | 17 | // Take care of NaN 18 | if ((x.val & 0x7FFF) > 0x7F80) { 19 | return x; 20 | } 21 | 22 | if (fInput <= 3.890991e-03 && fInput >= -1.953125e-03) { 23 | return 1.0; 24 | } 25 | 26 | double xprime = fInput * 1.442695040888963387004650940070860087871551513671875; 27 | double intPart; 28 | double fracPart = modf(xprime, &intPart); 29 | if (fracPart < 0.0f) { 30 | fracPart += 1.0; 31 | intPart -= 1.0; 32 | } 33 | 34 | double y = 1.45139853027161404297462610202273936010897159576416015625e-02; 35 | y *= fracPart; 36 | y += 5.014719237694532927296364732683287002146244049072265625e-02; 37 | y *= fracPart; 38 | y += 2.42560224581628236517616414857911877334117889404296875e-01; 39 | y *= fracPart; 40 | y += 6.9279247181322956006255253669223748147487640380859375e-01; 41 | y *= fracPart; 42 | y += 1.0000095976211798021182630691328085958957672119140625; 43 | 44 | return ldexp(y, intPart); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Jay Lim and Santosh Nagarakatte 2 | Rutgers, The State University of New Jersey 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /source/float/log2.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/constants.h" 3 | #include "float_headers/Log2_8.h" 4 | 5 | float rlibm_log2(float x) { 6 | floatX fix, fit; 7 | fix.f = x; 8 | int m = 0; 9 | 10 | if (fix.x < 0x800000 || fix.x >= 0x7F800000) { 11 | if ((fix.x & 0x7FFFFFFF) == 0) { // log(+/-0) = -infty 12 | fix.x = 0xFF800000; 13 | return fix.f; 14 | } 15 | 16 | if (fix.x > 0x7FFFFFFF) { // Log(-val) = NaN 17 | return (x-x) / 0; 18 | 19 | } 20 | 21 | if (fix.x >= 0x7F800000) { 22 | return x + x; 23 | } 24 | 25 | fix.f *= 8.388608e+06; 26 | m -= 23; 27 | } 28 | 29 | m += fix.x >> 23; 30 | m -= 127; 31 | fix.x &= 0x007FFFFF; 32 | fix.x |= 0x3F800000; 33 | 34 | fit.x = fix.x & 0x007F0000; 35 | int FIndex = fit.x >> 16; 36 | fit.x |= 0x3F800000; 37 | 38 | double f = fix.f - fit.f; 39 | f *= log_oneByF[FIndex]; 40 | 41 | // Find the index of polynomial coefficients 42 | doubleX dX; 43 | dX.d = f; 44 | unsigned long index = (dX.x & 0x01FFFFFFFFFFFFFFlu) >> 49lu; 45 | const double* coeff = coeffs8[index]; 46 | 47 | double y = coeff[2]; 48 | y *= f; 49 | y += coeff[1]; 50 | y *= f; 51 | y += coeff[0]; 52 | y *= f; 53 | 54 | return y + log2_lut[FIndex] + m; 55 | } 56 | -------------------------------------------------------------------------------- /source/bfloat16/exp10.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_exp10(bfloat16 x) { 4 | float fInput = (float)x; 5 | 6 | // Take care of when result is 0 7 | if (fInput <= -40.5f) { 8 | return 0.0f; 9 | } 10 | 11 | // Take care of infinity case 12 | if (fInput >= 38.75f) { 13 | x.val = 0x7F80; 14 | return x; 15 | } 16 | 17 | // Take care of NaN 18 | if ((x.val & 0x7FFF) > 0x7F80) { 19 | return x; 20 | } 21 | 22 | if ((fInput >= -8.4686279296875e-04) && (fInput <= 1.68609619140625e-03)) { 23 | // The values in these range return 1.0. 24 | return 1.0f; 25 | } 26 | 27 | double xprime = fInput * 3.321928094887362181708567732130177319049835205078125; 28 | double intPart; 29 | double fracPart = modf(xprime, &intPart); 30 | if (fracPart < 0.0f) { 31 | fracPart += 1.0; 32 | intPart -= 1.0; 33 | } 34 | 35 | double y = 1.63907658064124488184187811157244141213595867156982421875e-02; 36 | y *= fracPart; 37 | y += 4.5758952998196537886865797872815164737403392791748046875e-02; 38 | y *= fracPart; 39 | y += 2.459833280009494360651700617381720803678035736083984375e-01; 40 | y *= fracPart; 41 | y += 6.9179740083422547325397999884444288909435272216796875e-01; 42 | y *= fracPart; 43 | y += 1.0000778485054981903346060789772309362888336181640625; 44 | 45 | return ldexp(y, intPart); 46 | } 47 | -------------------------------------------------------------------------------- /source/bfloat16/log.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_log(bfloat16 x) { 4 | // If x == 0, then it should be -inf 5 | if (x.val == 0x0 || x.val == 0x8000) { 6 | x.val = 0xFF80; 7 | return x; 8 | } 9 | 10 | // If x == inf, then it should be infinity 11 | if (x.val == 0x7f80) { 12 | return x; 13 | } 14 | 15 | // If x == NaN or negative, then it should be NaN 16 | if (x.val > 0x7F80) { 17 | x.val = 0xFFFF; 18 | return x; 19 | } 20 | 21 | float fInput = (float)x; 22 | 23 | // Extract exponent and mantissa (where mantissa is between [1, 2) 24 | int m; 25 | float fx = frexpf(fInput, &m); 26 | fx *= 2.0; 27 | m--; 28 | 29 | // Cody and Waite Transformation on input 30 | double dx = (double)fx; 31 | double codyX = (dx - 1) / (dx + 1); 32 | double codyX2 = codyX * codyX; 33 | 34 | // Now compute polynomial 35 | double y = 1.2722152807088404902202682933420874178409576416015625; 36 | y *= codyX2; 37 | y += 3.91172520217394070751737444879836402833461761474609375e-01; 38 | y *= codyX2; 39 | y += 9.749438269300123582894457285874523222446441650390625e-01; 40 | y *= codyX2; 41 | y += 2.885102725620722008414986703428439795970916748046875; 42 | y *= codyX; 43 | 44 | // Range propagation 45 | y = (m + y) / 1.442695040888963387004650940070860087871551513671875; 46 | return y; 47 | } 48 | -------------------------------------------------------------------------------- /source/bfloat16/exp2.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | 4 | bfloat16 rlibm_exp2(bfloat16 x) { 5 | float fInput = (float)x; 6 | 7 | // Take care of 0 case 8 | if (fInput <= -134.0f) { 9 | return 0.0f; 10 | } 11 | 12 | // Take care of infinity case 13 | if (fInput >= 128.0f) { 14 | x.val = 0x7F80; 15 | return x; 16 | } 17 | 18 | // Take care of NaN 19 | if ((x.val & 0x7FFFFFFF) > 0x7F800000) { 20 | return x.val; 21 | } 22 | 23 | // Take care of when result is 1: 24 | if (fInput >= -2.8076171875e-03 && fInput <= 2.8076171875e-03) { 25 | return 1.0f; 26 | } 27 | 28 | // Range Reduction 29 | double intPart; 30 | double fracPart = modf(fInput, &intPart); 31 | if (fracPart < 0.0f) { 32 | fracPart += 1.0; 33 | intPart -= 1.0; 34 | } 35 | 36 | // Polynomial approximation 37 | double y = 1.557767964117490015751865684023869107477366924285888671875e-02; 38 | y *= fracPart; 39 | y += 4.8046547014740259573528646797058172523975372314453125e-02; 40 | y *= fracPart; 41 | y += 2.437159431324379121885925769674940966069698333740234375e-01; 42 | y *= fracPart; 43 | y += 6.9265463004053107187729665383812971413135528564453125e-01; 44 | y *= fracPart; 45 | y += 1.0000091388165410766220020377659238874912261962890625; 46 | 47 | // Output compensation 48 | return ldexp(y, intPart); 49 | } 50 | -------------------------------------------------------------------------------- /source/float/sinpi.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Sinpi.h" 3 | #include "float_headers/Cospi.h" 4 | #include "float_headers/constants.h" 5 | 6 | #define PI 3.141592653589793115997963468544185161590576171875 7 | 8 | float rlibm_sinpi(float x) { 9 | floatX fX; 10 | fX.f = x; 11 | unsigned s = fX.x & 0x80000000; 12 | fX.x &= 0x7FFFFFFF; 13 | 14 | // Special cases: 15 | if (fX.x <= 0x33fc1537) { 16 | return PI * (double)x; 17 | } 18 | 19 | if (fX.x >= 0x4b000000) { 20 | if (fX.x >= 0x7F800000) { 21 | return 0.0f/0.0f; 22 | } 23 | return 0.0f; 24 | } 25 | 26 | double xp = fX.f * 512; 27 | unsigned N = (unsigned)xp; 28 | unsigned N2 = N & 0xFF; 29 | unsigned I = N >> 8; 30 | double R; 31 | 32 | if (I & 0x1) { 33 | N2 = 255 - N2; 34 | R = (N + 1) * 0.001953125 - fX.f; 35 | } else R = fX.f - N * 0.001953125; 36 | 37 | if (I & 0x2) s ^= 0x80000000; 38 | 39 | double R2 = R * R; 40 | 41 | double cospiR, sinpiR; 42 | sinpiR = S2; 43 | sinpiR *= R2; 44 | sinpiR += S1; 45 | sinpiR *= R2; 46 | sinpiR += S0; 47 | sinpiR *= R; 48 | 49 | cospiR = C2; 50 | cospiR *= R2; 51 | cospiR += C1; 52 | cospiR *= R2; 53 | cospiR += C0; 54 | 55 | fX.f = sinpiMBy512[N2] * cospiR + cospiMBy512[N2] * sinpiR; 56 | fX.x ^= s; 57 | 58 | return fX.f; 59 | } 60 | -------------------------------------------------------------------------------- /source/posit16/cospi.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_cospi(posit16_t x) { 4 | if (x.v == 0x8000) { 5 | // Take care of NaN 6 | x.v = 0x8000; 7 | return x; 8 | } 9 | 10 | double dx = convertP16ToDouble(x); 11 | double modifier = 1; 12 | 13 | // cos(-x) = cos(x) 14 | if (dx < 0.0f) dx = -1 * dx; 15 | 16 | // How do we reduce range of x? 17 | // Reduce x to [0, 1) 18 | double intPart; 19 | double frac = modf(dx, &intPart); 20 | int iIntPart = intPart; 21 | 22 | // if iIntPart is odd, then flip modifier 23 | if (iIntPart % 2 == 1) modifier *= -1; 24 | 25 | // cos(pi - x) = -cos(x) 26 | if (frac >= 0.5) { 27 | frac = 1.0 - frac; 28 | modifier *= -1; 29 | } 30 | 31 | double y = 0; 32 | if (frac <= 0.003509521484375) { 33 | y = 1.0001220703125; 34 | } else if (frac < 0.5f) { 35 | double xSquared = frac * frac; 36 | y = 2.215338495769658688772096866159699857234954833984375e-01; 37 | y *= xSquared; 38 | y += -1.3327362938689424343152722940430976450443267822265625; 39 | y *= xSquared; 40 | y += 4.05853647916781223869975292473100125789642333984375; 41 | y *= xSquared; 42 | y += -4.93479863229652071510145106003619730472564697265625; 43 | y *= xSquared; 44 | y += 1.000000009410458634562246515997685492038726806640625; 45 | } else { 46 | y = 0.0f; 47 | } 48 | 49 | y *= modifier; 50 | return convertDoubleToP16(y); 51 | } 52 | -------------------------------------------------------------------------------- /source/float/log.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/constants.h" 3 | #include "float_headers/Log.h" 4 | 5 | #define LN2HIGH 0.69314718055994528622676398299518041312694549560546875 6 | 7 | float rlibm_log(float x) { 8 | floatX fix, fit; 9 | fix.f = x; 10 | int m = 0; 11 | 12 | if (fix.x < 0x800000 || fix.x >= 0x7F800000) { 13 | if ((fix.x & 0x7FFFFFFF) == 0) { // log(+/-0) = -infty 14 | fix.x = 0xFF800000; 15 | return fix.f; 16 | } 17 | 18 | if (fix.x > 0x7FFFFFFF) { // Log(-val) = NaN 19 | return (x-x) / 0; 20 | 21 | } 22 | 23 | if (fix.x >= 0x7F800000) { 24 | return x + x; 25 | } 26 | 27 | fix.f *= 8.388608e+06; 28 | m -= 23; 29 | } 30 | 31 | m += fix.x >> 23; 32 | m -= 127; 33 | fix.x &= 0x007FFFFF; 34 | fix.x |= 0x3F800000; 35 | 36 | fit.x = fix.x & 0x007F0000; 37 | int FIndex = fit.x >> 16; 38 | fit.x |= 0x3F800000; 39 | 40 | double f = fix.f - fit.f; 41 | f *= log_oneByF[FIndex]; 42 | 43 | // Find the index of polynomial coefficients 44 | doubleX dX; 45 | dX.d = f; 46 | unsigned long index = (dX.x & 0x01FFFFFFFFFFFFFFlu) >> 47lu; 47 | const double* coeffs = logCoeffs[index]; 48 | 49 | double y = coeffs[2]; 50 | y *= f; 51 | y += coeffs[1]; 52 | y *= f; 53 | y += coeffs[0]; 54 | y *= f; 55 | 56 | y += ln_lutHIGH[FIndex]; 57 | y += m * LN2HIGH; 58 | 59 | return y; 60 | } 61 | -------------------------------------------------------------------------------- /source/posit16/sinpi.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_sinpi(posit16_t x) { 4 | if (x.v == 0x8000) { 5 | // Take care of NaN 6 | x.v = 0x8000; 7 | return x; 8 | } 9 | 10 | double dx = convertP16ToDouble(x); 11 | double modifier = 1; 12 | 13 | // sin(-x) = -sin(x) 14 | if (dx < 0.0f) { 15 | dx = -1.0 * dx; 16 | modifier *= -1; 17 | } 18 | 19 | // How do we reduce range of x? 20 | // Reduce x to [0, 1) 21 | double intPart; 22 | double frac = modf(dx, &intPart); 23 | int iIntPart = intPart; 24 | 25 | // if iIntPart is odd, then flip modifier 26 | if (iIntPart % 2 == 1) modifier *= -1; 27 | 28 | // sin(x) = sin(pi - x) 29 | if (frac >= 0.5) { 30 | frac = 1.0 - frac; 31 | } 32 | double fracPart = frac; 33 | double y = 0; 34 | if (fracPart <= 0.00252532958984375000) { 35 | y = 3.141577060931899811890843920991756021976470947265625 * fracPart; 36 | } else { 37 | double xSquared = fracPart * fracPart; 38 | y = 9.47599641221426869375221713198698125779628753662109375e-02; 39 | y *= xSquared; 40 | y += -6.0547119473342603246379667325527407228946685791015625e-01; 41 | y *= xSquared; 42 | y += 2.55098424541712009983029929571785032749176025390625; 43 | y *= xSquared; 44 | y += -5.1677486367595673044661452877335250377655029296875; 45 | y *= xSquared; 46 | y += 3.141593069399674309494230328709818422794342041015625; 47 | y *= fracPart; 48 | } 49 | 50 | y *= modifier; 51 | return convertDoubleToP16(y); 52 | } 53 | -------------------------------------------------------------------------------- /source/float/exp.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Exp.h" 3 | #include "float_headers/constants.h" 4 | #include "math.h" 5 | 6 | float rlibm_exp(float x) { 7 | floatX fx; 8 | fx.f = x; 9 | 10 | // Take care of special cases 11 | if (0x42b17218 <= fx.x && fx.x <= 0xb3000000) { 12 | if (fx.x <= 0x7F800000) return 1.0/0.0; 13 | if (fx.x < 0x80000000) return 0.0/0.0; 14 | return 1.0; 15 | } 16 | 17 | if (fx.x <= 0x337fffff) { 18 | return 1.0; 19 | } 20 | 21 | if (fx.x >= 0xc2cff218) { 22 | if (fx.x <= 0xFF800000) return 0.0; 23 | return 0.0/0.0; 24 | } 25 | 26 | // Perform range reduction 27 | double xp = x * 92.332482616893656768297660164535045623779296875; 28 | int N = (int)xp; 29 | int N2 = N % 64; 30 | if (N2 < 0) N2 += 64; 31 | int N1 = N - N2; 32 | 33 | int M = N1 / 64; 34 | int J = N2; 35 | double R = x - N * 36 | 0.01083042469624914509729318723429969395510852336883544921875; 37 | 38 | doubleX dX; 39 | dX.d = R; 40 | 41 | // Find the polynomial coefficients to use. 42 | const double* coeff; 43 | unsigned index = (dX.x & 0x03FFFFFFFFFFFFFF) >> 51; 44 | if (dX.x > 0x8000000000000000) coeff = expNegCoeffs[index]; 45 | else coeff = expPosCoeffs[index]; 46 | 47 | // Compute polynomial 48 | double y = coeff[4]; 49 | y *= R; 50 | y += coeff[3]; 51 | y *= R; 52 | y += coeff[2]; 53 | y *= R; 54 | y += coeff[1]; 55 | y *= R; 56 | y += coeff[0]; 57 | 58 | // Perform output compensation 59 | return y * ldexp(exp2JBy64[J], M); 60 | } 61 | -------------------------------------------------------------------------------- /source/bfloat16/cospi.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_cospi(bfloat16 x) { 4 | if ((x.val & 0x7FFF) > 0x7F80) { 5 | // Take care of NaN 6 | return x; 7 | } 8 | 9 | if ((x.val & 0x7FFF) == 0x7F80) { 10 | x.val = 0x7FFF; 11 | return x; 12 | } 13 | 14 | float fInput = (float)x; 15 | 16 | if (fInput >= 256.0f || fInput <= -256.0f) { 17 | return 1.0f; 18 | } 19 | 20 | double modifier = 1; 21 | 22 | // cos(-x) = cos(x) 23 | if (fInput < 0.0f) fInput = -fInput; 24 | 25 | // How do we reduce range of x? 26 | // Reduce x to [0, 1) 27 | double intPart; 28 | double frac = modf((double)fInput, &intPart); 29 | int iIntPart = intPart; 30 | 31 | // if iIntPart is odd, then flip modifier 32 | if (iIntPart % 2 == 1) modifier *= -1; 33 | 34 | // cos(pi - x) = -cos(x) 35 | if (frac >= 0.5) { 36 | frac = 1.0 - frac; 37 | modifier *= -1; 38 | } 39 | 40 | double fracPart = frac; 41 | double y = 0; 42 | if (fracPart <= 0.01989746093750000000) { 43 | y = 1.00390625; 44 | } else if (fracPart < 0.5f) { 45 | double xSquared = fracPart * fracPart; 46 | y = -1.1640167711700171171429474270553328096866607666015625; 47 | y *= xSquared; 48 | y += 4.02150995405109146219047033810056746006011962890625; 49 | y *= xSquared; 50 | y += -4.9324802047472200428046562592498958110809326171875; 51 | y *= xSquared; 52 | y += 9.9997996859304827399483883709763176739215850830078125e-01; 53 | } else { 54 | y = 0.0f; 55 | } 56 | 57 | return y * modifier; 58 | } 59 | -------------------------------------------------------------------------------- /source/float/log10.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/constants.h" 3 | #include "float_headers/Log10_8.h" 4 | 5 | #define LOG102HIGH 0.30102999566398114250631579125183634459972381591796875 6 | #define LOG102LOW 5.27074231034726570126349709198449199648263806413338306011695522101945243775844573974609375e-17 7 | 8 | float rlibm_log10(float x) { 9 | floatX fix, fit; 10 | fix.f = x; 11 | int m = 0; 12 | 13 | if (fix.x < 0x800000 || fix.x >= 0x7F800000) { 14 | if ((fix.x & 0x7FFFFFFF) == 0) { // log(+/-0) = -infty 15 | fix.x = 0xFF800000; 16 | return fix.f; 17 | } 18 | 19 | if (fix.x > 0x7FFFFFFF) { // Log(-val) = NaN 20 | return (x-x) / 0; 21 | 22 | } 23 | 24 | if (fix.x >= 0x7F800000) { 25 | return x + x; 26 | } 27 | 28 | fix.f *= 8.388608e+06; 29 | m -= 23; 30 | } 31 | 32 | m += fix.x >> 23; 33 | m -= 127; 34 | fix.x &= 0x007FFFFF; 35 | fix.x |= 0x3F800000; 36 | 37 | fit.x = fix.x & 0x007F0000; 38 | int FIndex = fit.x >> 16; 39 | fit.x |= 0x3F800000; 40 | 41 | double f = fix.f - fit.f; 42 | f *= log_oneByF[FIndex]; 43 | 44 | // Find the index of polynomial coefficients 45 | doubleX dX; 46 | dX.d = f; 47 | unsigned long index = (dX.x & 0x01FFFFFFFFFFFFFFlu) >> 49lu; 48 | const double* coeff = log10coeffs8[index]; 49 | 50 | double y = coeff[2]; 51 | y *= f; 52 | y += coeff[1]; 53 | y *= f; 54 | y += coeff[0]; 55 | y *= f; 56 | 57 | y += m * LOG102LOW; 58 | y += log10_lut[FIndex]; 59 | y += m * LOG102HIGH; 60 | return y; 61 | } 62 | -------------------------------------------------------------------------------- /source/float/exp2.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Exp2.h" 3 | #include "float_headers/constants.h" 4 | #include "math.h" 5 | 6 | float rlibm_exp2(float x) { 7 | floatX fx; 8 | fx.f = x; 9 | 10 | // Take care of special cases 11 | if (0x43000000 <= fx.x && fx.x <= 0xb338aa3b) { 12 | if (fx.x <= 0x7F800000) return 1.0/0.0; 13 | if (fx.x < 0x80000000) return 0.0/0.0; 14 | return 1.0; 15 | } 16 | 17 | if (fx.x <= 0x33b8aa3a) { 18 | return 1.0; 19 | } 20 | 21 | if (fx.x >= 0xc3160000) { 22 | if (fx.x <= 0xFF800000) return 0.0; 23 | return 0.0/0.0; 24 | } 25 | 26 | // Perform range reduction 27 | double xp = x * 64; 28 | int N = (int)xp; 29 | int N2 = N % 64; 30 | if (N2 < 0) N2 += 64; 31 | int N1 = N - N2; 32 | 33 | int M = N1 / 64; 34 | int J = N2; 35 | double R = x - N * 0.015625; 36 | 37 | double y; 38 | 39 | doubleX dX; 40 | dX.d = R; 41 | 42 | // Find the polynomial coefficients to use. 43 | const double* coeff; 44 | if (dX.x > 0x8000000000000000) { 45 | unsigned long index = (dX.x & 0x01FFFFFFFFFFFFFFlu) >> 53lu; 46 | coeff = exp2NegCoeffs[index]; 47 | } 48 | else { 49 | unsigned long index = (dX.x & 0x01FFFFFFFFFFFFFFlu) >> 54lu; 50 | coeff = exp2PosCoeffs[index]; 51 | } 52 | 53 | // Compute polynomial 54 | y = coeff[4]; 55 | y *= R; 56 | y += coeff[3]; 57 | y *= R; 58 | y += coeff[2]; 59 | y *= R; 60 | y += coeff[1]; 61 | y *= R; 62 | y += coeff[0]; 63 | 64 | // Perform output compensation 65 | return y * ldexp(exp2JBy64[J], M); 66 | } 67 | -------------------------------------------------------------------------------- /source/bfloat16/sinpi.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_sinpi(bfloat16 x) { 4 | if ((x.val & 0x7FFF) > 0x7F80) { 5 | // Take care of NaN 6 | return x; 7 | } 8 | 9 | if ((x.val & 0x7FFF) == 0x7F80) { 10 | x.val = 0x7FFF; 11 | return x; 12 | } 13 | 14 | float fInput = (float)x; 15 | 16 | if (fInput >= 256.0f || fInput <= -256.0f) { 17 | return 0.0f; 18 | } 19 | 20 | double modifier = 1; 21 | 22 | // sin(-x) = -sin(x) 23 | if (fInput < 0.0f) { 24 | fInput = -fInput; 25 | modifier *= -1; 26 | } 27 | 28 | // How do we reduce range of x? 29 | // Reduce x to [0, 1) 30 | double intPart; 31 | double frac = modf((double)fInput, &intPart); 32 | int iIntPart = intPart; 33 | 34 | // if iIntPart is odd, then flip modifier 35 | if (iIntPart % 2 == 1) modifier *= -1; 36 | 37 | // sin(x) = sin(pi - x) 38 | if (frac >= 0.5) { 39 | frac = 1.0 - frac; 40 | } 41 | double fracPart = frac; 42 | double y = 0; 43 | if (fracPart <= 0.006011962890625) { 44 | y = 3.14159292035398163278614447335712611675262451171875 * fracPart; 45 | } else { 46 | double xSquared = fracPart * fracPart; 47 | y = -4.43008519856437021910977591687696985900402069091796875e-01; 48 | y *= xSquared; 49 | y += 2.50692180297728217652775128954090178012847900390625; 50 | y *= xSquared; 51 | y += -5.16405991738943459523625278961844742298126220703125; 52 | y *= xSquared; 53 | y += 3.141515487020253072358855206402949988842010498046875; 54 | y *= fracPart; 55 | } 56 | 57 | return y * modifier; 58 | } 59 | -------------------------------------------------------------------------------- /source/posit16/exp2.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_exp2(posit16_t x) { 4 | 5 | if (x.v > 0x8000 & x.v <= 0x8d3f) { 6 | // Take care of when result is minpos. exp(x) for posit should never 7 | // return 0, because exp(x) is always > 0 as long as x != -infinity 8 | x.v = 0x1; 9 | return x; 10 | } else if (x.v >= 0x72c1 && x.v < 0x8000) { 11 | // Take care of maxpos case. 12 | x.v = 0x7FFF; 13 | return x; 14 | } else if (x.v == 0x8000) { 15 | // Take care of NaR 16 | return x; 17 | } else if ((x.v >= 0xff64) || (x.v <= 0xdc)) { 18 | // The values in these range return 1.0. 19 | x.v = 0x4000; 20 | return x; 21 | } 22 | 23 | // Extract exponent and mantissa (where mantissa is between [1, 2) 24 | double xprime = convertP16ToDouble(x); 25 | double modifier; 26 | double f = modf(xprime, &modifier); 27 | if (f < 0.0f) { 28 | f += 1.0; 29 | modifier -= 1.0; 30 | } 31 | 32 | // Now compute polynomial 33 | double y = 3.65720720951589702875372811519127935753203928470611572265625e-04 ; 34 | y *= f; 35 | y += 7.694531242965385771370723233530952711589634418487548828125e-04; 36 | y *= f; 37 | y += 1.02531888584330328761939910009459708817303180694580078125e-02; 38 | y *= f; 39 | y += 5.5157921920287643346991757198338746093213558197021484375e-02; 40 | y *= f; 41 | y += 2.40314607704837424062560558013501577079296112060546875e-01; 42 | y *= f; 43 | y += 6.9313911175081532878294865440693683922290802001953125e-01; 44 | y *= f; 45 | y += 1.0; 46 | 47 | y = ldexp(y, modifier); 48 | 49 | return convertDoubleToP16(y); 50 | } 51 | -------------------------------------------------------------------------------- /source/bfloat16/cbrt.cpp: -------------------------------------------------------------------------------- 1 | #include "bfloat16_math.hpp" 2 | 3 | bfloat16 rlibm_cbrt(bfloat16 x) { 4 | 5 | // If x == 0, then it should be 0 6 | if (x.val == 0x0 || x.val == 0x8000) { 7 | return x; 8 | } 9 | 10 | // If x == inf, then it should be infinity 11 | if ((x.val & 0x7f80) == 0x7f80) { 12 | return x; 13 | } 14 | 15 | // If x == NaN, then it should be NaN 16 | if ((x.val & 0x7f80) > 0x7F80) { 17 | x.val = 0xFFFF; 18 | return x; 19 | } 20 | 21 | // Extract exponent and mantissa (where mantissa is between [1, 8)) 22 | int m; 23 | float rx = frexpf((float)x, &m); 24 | rx *= 2.0; 25 | m--; 26 | 27 | int leftOver = m % 3; 28 | if (leftOver != 0) { 29 | if (leftOver < 0) leftOver += 3; 30 | 31 | fx fi; 32 | fi.x = 0x3f800000 + (leftOver << 23); 33 | rx *= fi.f; 34 | m -= leftOver; 35 | } 36 | 37 | m /= 3; 38 | if (rx < 0) rx *= -1; 39 | 40 | // Now compute polynomial 41 | double y = -1.7372029717703960593165601888898663673899136483669281005859375e-05; 42 | y *= rx; 43 | y += 5.241080546145838146843143334763226448558270931243896484375e-04; 44 | y *= rx; 45 | y += -6.5208421736825845915763721905022975988686084747314453125e-03; 46 | y *= rx; 47 | y += 4.3868412288261666998057108912689727731049060821533203125e-02; 48 | y *= rx; 49 | y += -1.80364291120356845521399691278929822146892547607421875e-01; 50 | y *= rx; 51 | y += 5.752913905623990853399618572439067065715789794921875e-01; 52 | y *= rx; 53 | y += 5.6860957346246798760347473944420926272869110107421875e-01; 54 | 55 | if (x < 0) y *= -1; 56 | return ldexp(y, m); 57 | } 58 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | 3 | bf16FNames = log log2 log10 sinpi cospi sqrt cbrt exp exp2 exp10 4 | p16FNames = cospi log log2 log10 sinpi sqrt exp exp2 exp10 5 | floatFNames = cosh cospi exp exp2 exp10 log log2 log10 sinh sinpi 6 | 7 | bf16SrcDir = source/bfloat16 8 | bf16ObjDir = obj/bfloat16 9 | p16SrcDir = source/posit16 10 | p16ObjDir = obj/posit16 11 | floatSrcDir = source/float 12 | floatObjDir = obj/float 13 | libDir = lib 14 | 15 | bf16Src = $(patsubst %, $(bf16SrcDir)/%.cpp, $(bf16FNames)) 16 | bf16Obj = $(patsubst %, $(bf16ObjDir)/%.o, $(bf16FNames)) 17 | p16Src = $(patsubst %, $(p16SrcDir)/%.cpp, $(p16FNames)) 18 | p16Obj = $(patsubst %, $(p16ObjDir)/%.o, $(p16FNames)) 19 | floatSrc = $(patsubst %, $(floatSrcDir)/%.cpp, $(floatFNames)) 20 | floatObj = $(patsubst %, $(floatObjDir)/%.o, $(floatFNames)) 21 | 22 | all: $(libDir)/bfloat16MathLib.a $(libDir)/posit16MathLib.a $(libDir)/floatMathLib.a 23 | 24 | $(bf16ObjDir)/%.o: $(bf16SrcDir)/%.cpp 25 | @mkdir -p $(bf16ObjDir) 26 | $(CC) -std=c++11 -O3 -c $^ -Iinclude/ -o $@ 27 | 28 | $(libDir)/bfloat16MathLib.a: $(bf16Obj) 29 | @mkdir -p $(libDir) 30 | ar rc $@ $^ 31 | 32 | $(p16ObjDir)/%.o: $(p16SrcDir)/%.cpp 33 | @mkdir -p $(p16ObjDir) 34 | $(CC) -std=c++11 -O3 -c $^ -Iinclude/ -I$(SOFTPOSITPATH)/source/include -o $@ 35 | 36 | $(libDir)/posit16MathLib.a: $(p16Obj) 37 | @mkdir -p $(libDir) 38 | ar rc $@ $^ $(SOFTPOSITPATH)/build/Linux-x86_64-GCC/softposit.a 39 | 40 | $(floatObjDir)/%.o: $(floatSrcDir)/%.cpp 41 | @mkdir -p $(floatObjDir) 42 | $(CC) -std=c++11 -O3 -c $^ -Iinclude/ -o $@ 43 | 44 | $(libDir)/floatMathLib.a: $(floatObj) 45 | @mkdir -p $(libDir) 46 | ar rc $@ $^ 47 | 48 | bfloat16mlib: $(libDir)/bfloat16MathLib.a 49 | 50 | posit16mlib: $(libDir)/posit16MathLib.a 51 | 52 | floatmlib: $(libDir)/floatMathLib.a 53 | 54 | clean: 55 | rm -rf obj lib *.dSYM 56 | -------------------------------------------------------------------------------- /source/posit16/exp.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_exp(posit16_t x) { 4 | 5 | if (x.v == 0x8000) { 6 | // Take care of NaR 7 | return x; 8 | } else if (x.v > 0x8000 & x.v <= 0x8f52) { 9 | // Take care of when result is minpos. exp(x) for posit should never 10 | // return 0, because exp(x) is always > 0 as long as x != -infinity 11 | x.v = 0x1; 12 | return x; 13 | } else if (x.v >= 0x70ae && x.v < 0x8000) { 14 | // Take care of maxpos case. 15 | x.v = 0x7FFF; 16 | return x; 17 | } else if ((x.v >= 0xff80) || (x.v <= 0xbf)) { 18 | // The values in these range return 1.0. 19 | x.v = 0x4000; 20 | return x; 21 | } 22 | 23 | // Extract exponent and mantissa (where mantissa is between [1, 2) 24 | double xprime = convertP16ToDouble(x) * 25 | 1.442695040888963387004650940070860087871551513671875; 26 | double modifier; 27 | double f = modf(xprime, &modifier); 28 | if (f < 0.0f) { 29 | f += 1.0; 30 | modifier -= 1.0; 31 | } 32 | 33 | // Now compute polynomial 34 | double y = 3.880795968797916273285153465621988289058208465576171875e-04 ; 35 | y *= f; 36 | y += 7.56416228767151587429606873769216690561734139919281005859375e-04; 37 | y *= f; 38 | y += 1.019728060416365440776775841413837042637169361114501953125e-02; 39 | y *= f; 40 | y += 5.522989323495941516029006379540078341960906982421875e-02; 41 | y *= f; 42 | y += 2.40286646236610668125877054990269243717193603515625e-01; 43 | y *= f; 44 | y += 6.93141820259879803955982424668036401271820068359375e-01; 45 | y *= f; 46 | y += 1.0000001298120355652798707524198107421398162841796875; 47 | 48 | y = ldexp(y, modifier); 49 | 50 | return convertDoubleToP16(y); 51 | } 52 | -------------------------------------------------------------------------------- /source/posit16/exp10.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_exp10(posit16_t x) { 4 | 5 | if (x.v > 0x8000 & x.v <= 0x97df) { 6 | // Take care of when result is minpos. exp(x) for posit should never 7 | // return 0, because exp(x) is always > 0 as long as x != -infinity 8 | x.v = 0x1; 9 | return x; 10 | } else if (x.v >= 0x6821 && x.v < 0x8000) { 11 | // Take care of maxpos case. 12 | x.v = 0x7FFF; 13 | return x; 14 | } else if (x.v == 0x8000) { 15 | // Take care of NaR 16 | return x; 17 | } else if ((x.v >= 0xffa9) || (x.v <= 0x77)) { 18 | // The values in these range return 1.0. 19 | x.v = 0x4000; 20 | return x; 21 | } 22 | 23 | // Extract exponent and mantissa (where mantissa is between [1, 2) 24 | double xprime = convertP16ToDouble(x) * 3.321928094887362181708567732130177319049835205078125;; 25 | double modifier; 26 | double f = modf(xprime, &modifier); 27 | if (f < 0.0f) { 28 | f += 1.0; 29 | modifier -= 1.0; 30 | } 31 | 32 | // Now compute polynomial 33 | double y = 3.3019478519002672979587575952109546051360666751861572265625e-04 ; 34 | y *= f; 35 | y += 9.031838553965111128507547988419901230372488498687744140625e-04; 36 | y *= f; 37 | y += 1.006802205059511255702542342760352767072618007659912109375e-02; 38 | y *= f; 39 | y += 5.5274346317151945573442617387627251446247100830078125e-02; 40 | y *= f; 41 | y += 2.40282388412963510138098399693262763321399688720703125e-01; 42 | y *= f; 43 | y += 6.93141854936602630488096110639162361621856689453125e-01; 44 | y *= f; 45 | y += 1.0000000800001294098962034695432521402835845947265625; 46 | 47 | y = ldexp(y, modifier); 48 | 49 | return convertDoubleToP16(y); 50 | } 51 | -------------------------------------------------------------------------------- /source/float/exp10.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Exp10.h" 3 | #include "float_headers/constants.h" 4 | #include "math.h" 5 | 6 | float rlibm_exp10(float x) { 7 | floatX fx; 8 | fx.f = x; 9 | 10 | // Take care of special cases 11 | if (0x421a209b <= fx.x && fx.x <= 0xb25e5bd8) { 12 | if (fx.x <= 0x7F800000) return 1.0/0.0; 13 | if (fx.x < 0x80000000) return 0.0/0.0; 14 | return 1.0; 15 | } 16 | 17 | if (fx.x <= 0x32de5bd8) { 18 | return 1.0; 19 | } 20 | 21 | if (fx.x >= 0xc2349e36) { 22 | if (fx.x <= 0xFF800000) return 0.0; 23 | return 0.0/0.0; 24 | } 25 | 26 | // Perform range reduction 27 | double xp = x * 2.12603398072791179629348334856331348419189453125e+02; 28 | int N = (int)xp; 29 | int N2 = N % 64; 30 | if (N2 < 0) N2 += 64; 31 | int N1 = N - N2; 32 | 33 | int M = N1 / 64; 34 | int J = N2; 35 | double R = x - N * 36 | 4.703593682249706219022922226713490090332925319671630859375e-03; 37 | 38 | doubleX dX; 39 | dX.d = R; 40 | 41 | // Find the polynomial coefficients to use. 42 | double y; 43 | if (dX.x > 0x8000000000000000) { 44 | unsigned index = (dX.x & 0x03FFFFFFFFFFFFFF) >> 52lu; 45 | const double* coeff = exp10NegCoeffs[index]; 46 | 47 | y = coeff[4]; 48 | y *= R; 49 | y += coeff[3]; 50 | y *= R; 51 | y += coeff[2]; 52 | y *= R; 53 | y += coeff[1]; 54 | y *= R; 55 | y += coeff[0]; 56 | } 57 | else { 58 | unsigned index = (dX.x & 0x03FFFFFFFFFFFFFF) >> 50lu; 59 | const double* coeff = exp10PosCoeffs[index]; 60 | y = coeff[3]; 61 | y *= R; 62 | y += coeff[2]; 63 | y *= R; 64 | y += coeff[1]; 65 | y *= R; 66 | y += coeff[0]; 67 | } 68 | 69 | // Perform output compensation 70 | return y * ldexp(exp2JBy64[J], M); 71 | } 72 | -------------------------------------------------------------------------------- /source/float/cosh.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Sinh.h" 3 | #include "float_headers/Cosh.h" 4 | #include "float_headers/constants.h" 5 | 6 | #define CONST64BYLN2 92.332482616893656768297660164535045623779296875 7 | #define LN2BY64 0.01083042469624914509729318723429969395510852336883544921875 8 | 9 | float rlibm_cosh(float x) { 10 | floatX fx; 11 | fx.f = x; 12 | fx.x &= 0x7FFFFFFF; 13 | 14 | // Take care of special cases 15 | if (fx.x <= 968164595) return 1.0; 16 | 17 | if (fx.x >= 1119016189) { 18 | if (fx.x > 0x7F800000) return 0.0f/0.0f; 19 | return 1.0f / 0.0f; 20 | } 21 | 22 | // Perform range reduction 23 | double xp = fx.f * CONST64BYLN2; 24 | int N = (int)xp; 25 | int N2 = N % 64; 26 | if (N2 < 0) N2 += 64; 27 | int N1 = N - N2; 28 | int I = N1 / 64; 29 | double R = fx.f - N * LN2BY64; 30 | double R2 = R * R; 31 | 32 | double sinhHigh = sinhKLn2[I]; 33 | double coshHigh = coshKLn2[I]; 34 | double sinhMid = sinhKLn2By64[N2]; 35 | double coshMid = coshKLn2By64[N2]; 36 | 37 | double sinhHM = sinhHigh * coshMid + coshHigh * sinhMid; 38 | double coshHM = sinhHigh * sinhMid + coshHigh * coshMid; 39 | 40 | doubleX dX; 41 | dX.d = R; 42 | 43 | // Find the polynomial coefficients to use. 44 | unsigned long Index = (dX.x & 0x03FFFFFFFFFFFFFFlu) >> 52lu; 45 | 46 | const double* sinhCoeff = Sinh[Index]; 47 | const double* coshCoeff = Cosh[Index]; 48 | 49 | // Compute sinh component 50 | double sinhL = sinhCoeff[2]; 51 | sinhL *= R2; 52 | sinhL += sinhCoeff[1]; 53 | sinhL *= R2; 54 | sinhL += sinhCoeff[0]; 55 | sinhL *= R; 56 | 57 | // Compute cosh component 58 | double coshL = coshCoeff[2]; 59 | coshL *= R2; 60 | coshL += coshCoeff[1]; 61 | coshL *= R2; 62 | coshL += coshCoeff[0]; 63 | 64 | // Perform output compensation 65 | return sinhHM * sinhL + coshHM * coshL; 66 | } 67 | -------------------------------------------------------------------------------- /source/float/sinh.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Sinh.h" 3 | #include "float_headers/Cosh.h" 4 | #include "float_headers/constants.h" 5 | 6 | #define CONST64BYLN2 92.332482616893656768297660164535045623779296875 7 | #define LN2BY64 0.01083042469624914509729318723429969395510852336883544921875 8 | 9 | float rlibm_sinh(float x) { 10 | floatX fx; 11 | fx.f = x; 12 | unsigned sign = fx.x & 0x80000000; 13 | fx.x &= 0x7FFFFFFF; 14 | 15 | // Take care of special cases 16 | if (fx.x <= 971544424) return x; 17 | 18 | if (fx.x >= 1119016189) { 19 | if (fx.x > 0x7F800000) return 0.0f/0.0f; 20 | return x / 0.0f; 21 | } 22 | 23 | // Perform range reduction 24 | double xp = fx.f * CONST64BYLN2; 25 | int N = (int)xp; 26 | int N2 = N % 64; 27 | if (N2 < 0) N2 += 64; 28 | int N1 = N - N2; 29 | int I = N1 / 64; 30 | double R = fx.f - N * LN2BY64; 31 | double R2 = R * R; 32 | 33 | double sinhHigh = sinhKLn2[I]; 34 | double coshHigh = coshKLn2[I]; 35 | double sinhMid = sinhKLn2By64[N2]; 36 | double coshMid = coshKLn2By64[N2]; 37 | 38 | double sinhHM = sinhHigh * coshMid + coshHigh * sinhMid; 39 | double coshHM = sinhHigh * sinhMid + coshHigh * coshMid; 40 | 41 | doubleX dX; 42 | dX.d = R; 43 | 44 | // Find the polynomial coefficients to use. 45 | unsigned long Index = (dX.x & 0x03FFFFFFFFFFFFFFlu) >> 52lu; 46 | 47 | const double* sinhCoeff = Sinh[Index]; 48 | const double* coshCoeff = Cosh[Index]; 49 | 50 | // Compute sinh component 51 | double sinhL = sinhCoeff[2]; 52 | sinhL *= R2; 53 | sinhL += sinhCoeff[1]; 54 | sinhL *= R2; 55 | sinhL += sinhCoeff[0]; 56 | sinhL *= R; 57 | 58 | // Compute cosh component 59 | double coshL = coshCoeff[2]; 60 | coshL *= R2; 61 | coshL += coshCoeff[1]; 62 | coshL *= R2; 63 | coshL += coshCoeff[0]; 64 | 65 | // Perform output compensation 66 | fx.f = sinhHM * coshL + coshHM * sinhL; 67 | fx.x |= sign; 68 | return fx.f; 69 | } 70 | -------------------------------------------------------------------------------- /source/float/cospi.cpp: -------------------------------------------------------------------------------- 1 | #include "float_math.h" 2 | #include "float_headers/Sinpi.h" 3 | #include "float_headers/Cospi.h" 4 | #include "float_headers/constants.h" 5 | #include "stdio.h" 6 | 7 | float rlibm_cospi(float x) { 8 | floatX fX; 9 | fX.f = x; 10 | fX.x &= 0x7FFFFFFF; 11 | 12 | // Special cases: 13 | // If x is smaller than 0x38a2f983, then it's 1.0f 14 | if (fX.x <= 0x38a2f983) { 15 | return 1.0f; 16 | } 17 | 18 | if (fX.x >= 0x4b000000) { 19 | // If x >= 0x7F800000, then result is NaN 20 | if (fX.x >= 0x7F800000) return 0.0f/0.0f; 21 | // If x >= 2^24, then result is always 1.0f 22 | if (fX.x >= 0x4b800000) return 1.0f; 23 | // If x >= 2^23, then if x is even, then 1.0f 24 | if ((fX.x & 0x1) == 0) return 1.0f; 25 | // Otherwise, then -1.0f 26 | return -1.0f; 27 | } 28 | 29 | // Range Reduction 30 | double xp = fX.f * 512.0; 31 | unsigned N = (unsigned)xp; 32 | unsigned N2 = N & 0xFF; 33 | unsigned I = (N >> 8) + 1; 34 | double R, cospiM, sinpiM; 35 | unsigned s = (I & 0x2) ? 0x80000000 : 0; 36 | 37 | if (I & 1) { 38 | if (N2 == 0) { 39 | R = fX.f - N * 0.001953125; 40 | cospiM = 1.0; 41 | sinpiM = 0.0; 42 | } 43 | else { 44 | N2++; 45 | R = (N + 1) * 0.001953125 - fX.f; 46 | cospiM = sinpiMBy512[256 - N2]; 47 | sinpiM = cospiMBy512[256 - N2]; 48 | } 49 | } else { 50 | R = fX.f - N * 0.001953125; 51 | cospiM = sinpiMBy512[N2]; 52 | sinpiM = cospiMBy512[N2]; 53 | } 54 | 55 | double R2 = R * R; 56 | double cospiR, sinpiR; 57 | 58 | sinpiR = S2; 59 | sinpiR *= R2; 60 | sinpiR += S1; 61 | sinpiR *= R2; 62 | sinpiR += S0; 63 | sinpiR *= R; 64 | 65 | cospiR = C2; 66 | cospiR *= R2; 67 | cospiR += C1; 68 | cospiR *= R2; 69 | cospiR += C0; 70 | 71 | fX.f = cospiM * cospiR + sinpiM * sinpiR; 72 | fX.x ^= s; 73 | 74 | return fX.f; 75 | } 76 | -------------------------------------------------------------------------------- /source/posit16/sqrt.cpp: -------------------------------------------------------------------------------- 1 | #include "posit16_math.h" 2 | 3 | posit16_t rlibm_sqrt(posit16_t x) { 4 | if (x.v >= 0x8000) { 5 | x.v = 0x8000; 6 | return x; 7 | } else if (x.v == 0x0) { 8 | return x; 9 | } 10 | 11 | // Extract exponent and mantissa 12 | int m; 13 | float fx = frexpf(convertP16ToDouble(x), &m); 14 | 15 | if ((m & 0x1) == 0) { 16 | fx *= 4.0; 17 | m -= 2; 18 | } else { 19 | fx *= 2.0; 20 | m--; 21 | } 22 | 23 | // Instead of [0.5, 2) make it [1/8, 0.5) 24 | m >>= 1; 25 | 26 | double y = 0; 27 | 28 | if (fx <= 2.14599609375) { 29 | y = -2.3530402643644897538177662710268123191781342029571533203125e-03; 30 | y *= fx; 31 | y += 2.62819293630375920567399106175798806361854076385498046875e-02; 32 | y *= fx; 33 | y += -1.27171841275129426929169085269677452743053436279296875e-01; 34 | y *= fx; 35 | y += 3.530868073027828568655195340397767722606658935546875e-01; 36 | y *= fx; 37 | y += -6.4843843364755160418866353211342357099056243896484375e-01; 38 | y *= fx; 39 | y += 1.129000996028148851024752730154432356357574462890625; 40 | y *= fx; 41 | y += 2.69593592709484630720595532693550921976566314697265625e-01; 42 | } else { 43 | y = -2.1374405303079146056961790112183052769978530704975128173828125e-05; 44 | y *= fx; 45 | y += 5.74776888286255573622118841825567869818769395351409912109375e-04; 46 | y *= fx; 47 | y += -6.6014424010839810319506426594671211205422878265380859375e-03; 48 | y *= fx; 49 | y += 4.305139568476913647376846938641392625868320465087890625e-02; 50 | y *= fx; 51 | y += -1.842527001546831189049413524116971530020236968994140625e-01; 52 | y *= fx; 53 | y += 7.4313621747255442784307888359762728214263916015625e-01; 54 | y *= fx; 55 | y += 4.09156298855834987815427439272752963006496429443359375e-01; 56 | } 57 | 58 | y = ldexp(y, m); 59 | return convertDoubleToP16(y); 60 | } 61 | -------------------------------------------------------------------------------- /libtest/bfloat16/Exp.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateExp(bfloat16 x) { 9 | mpfr_set_d(mval, (double)x, MPFR_RNDN); 10 | mpfr_exp(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_exp(x); 63 | bfloat16 bmy = MpfrCalculateExp(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Log.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateLog(bfloat16 x) { 9 | mpfr_set_d(mval, (float)x, MPFR_RNDN); 10 | mpfr_log(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_log(x); 63 | bfloat16 bmy = MpfrCalculateLog(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Cbrt.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateCbrt(bfloat16 x) { 9 | mpfr_set_d(mval, (float)x, MPFR_RNDN); 10 | mpfr_cbrt(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_cbrt(x); 63 | bfloat16 bmy = MpfrCalculateCbrt(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Cospi.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateCospi(bfloat16 x) { 9 | mpfr_const_pi(mval, MPFR_RNDN); 10 | mpfr_mul_d(mval, mval, (double)x, MPFR_RNDN); 11 | mpfr_cos(mval, mval, MPFR_RNDN); 12 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 13 | 14 | if (retVal == 0) return 0.0; 15 | if (retVal != retVal) { 16 | return retVal; 17 | } 18 | 19 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 20 | return 0; 21 | } 22 | 23 | long exp; 24 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 25 | fr *= 2; 26 | exp--; 27 | 28 | if (mpfr_cmp_d(mval, 0.0) > 0) { 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 30 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 31 | 32 | } else { 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 34 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 35 | } 36 | 37 | if (exp >= -132 && exp <= -127) { 38 | int prec = 134 + exp; 39 | mpfr_t r; 40 | mpfr_init2(r, prec); 41 | mpfr_set(r, mval, MPFR_RNDN); 42 | retVal = mpfr_get_d(r, MPFR_RNDN); 43 | mpfr_clear(r); 44 | return retVal; 45 | } else { 46 | mpfr_t r; 47 | mpfr_init2(r, 8); 48 | mpfr_set(r, mval, MPFR_RNDN); 49 | retVal = mpfr_get_d(r, MPFR_RNDN); 50 | mpfr_clear(r); 51 | return retVal; 52 | } 53 | } 54 | 55 | int main(int argc, char** argv) { 56 | mpfr_init2(mval, MPFR_PREC); 57 | int wrongBfloatCount = 0; 58 | unsigned long long count = 0; 59 | 60 | bfloat16 x = 0.0; 61 | for (; count < 0x10000; count++) { 62 | x.val = count; 63 | bfloat16 bres = rlibm_cospi(x); 64 | bfloat16 bmy = MpfrCalculateCospi(x); 65 | 66 | // if bres is nan and bmy is nan, continue 67 | if (bres != bres && bmy != bmy) continue; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Exp2.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateExp2(bfloat16 x) { 9 | mpfr_set_d(mval, (double)x, MPFR_RNDN); 10 | mpfr_exp2(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_exp2(x); 63 | bfloat16 bmy = MpfrCalculateExp2(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Log2.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateLog2(bfloat16 x) { 9 | mpfr_set_d(mval, (float)x, MPFR_RNDN); 10 | mpfr_log2(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_log2(x); 63 | bfloat16 bmy = MpfrCalculateLog2(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Sqrt.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateSqrt(bfloat16 x) { 9 | mpfr_set_d(mval, (float)x, MPFR_RNDN); 10 | mpfr_sqrt(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_sqrt(x); 63 | bfloat16 bmy = MpfrCalculateSqrt(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Exp10.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateExp10(bfloat16 x) { 9 | mpfr_set_d(mval, (double)x, MPFR_RNDN); 10 | mpfr_exp10(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_exp10(x); 63 | bfloat16 bmy = MpfrCalculateExp10(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Log10.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateLog10(bfloat16 x) { 9 | mpfr_set_d(mval, (float)x, MPFR_RNDN); 10 | mpfr_log10(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 29 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 33 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 34 | } 35 | 36 | if (exp >= -132 && exp <= -127) { 37 | int prec = 134 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 8); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongBfloatCount = 0; 57 | unsigned long long count = 0; 58 | 59 | bfloat16 x = 0.0; 60 | for (; count < 0x10000; count++) { 61 | x.val = count; 62 | bfloat16 bres = rlibm_log10(x); 63 | bfloat16 bmy = MpfrCalculateLog10(x); 64 | 65 | // if bres is nan and bmy is nan, continue 66 | if (bres != bres && bmy != bmy) continue; 67 | if (bres != bmy) wrongBfloatCount++; 68 | } 69 | 70 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/bfloat16/Sinpi.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "bfloat16_math.hpp" 3 | #include "bfloat16.hpp" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateSinpi(bfloat16 x) { 9 | mpfr_const_pi(mval, MPFR_RNDN); 10 | mpfr_mul_d(mval, mval, (double)x, MPFR_RNDN); 11 | mpfr_sin(mval, mval, MPFR_RNDN); 12 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 13 | 14 | if (retVal == 0) return 0.0; 15 | if (retVal != retVal) { 16 | return retVal; 17 | } 18 | 19 | if (mpfr_cmp_d(mval, pow(2, -134)) <= 0 && mpfr_cmp_d(mval, -pow(2, -134)) >= 0) { 20 | return 0; 21 | } 22 | 23 | long exp; 24 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 25 | fr *= 2; 26 | exp--; 27 | 28 | if (mpfr_cmp_d(mval, 0.0) > 0) { 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -133)) < 0) return pow(2, -133); 30 | if (mpfr_cmp_d(mval, pow(2, -132)) < 0) return pow(2, -132); 31 | 32 | } else { 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -133)) > 0) return -pow(2, -133); 34 | if (mpfr_cmp_d(mval, -pow(2, -132)) > 0) return -pow(2, -132); 35 | } 36 | 37 | if (exp >= -132 && exp <= -127) { 38 | int prec = 134 + exp; 39 | mpfr_t r; 40 | mpfr_init2(r, prec); 41 | mpfr_set(r, mval, MPFR_RNDN); 42 | retVal = mpfr_get_d(r, MPFR_RNDN); 43 | mpfr_clear(r); 44 | return retVal; 45 | } else { 46 | mpfr_t r; 47 | mpfr_init2(r, 8); 48 | mpfr_set(r, mval, MPFR_RNDN); 49 | retVal = mpfr_get_d(r, MPFR_RNDN); 50 | mpfr_clear(r); 51 | return retVal; 52 | } 53 | } 54 | 55 | int main(int argc, char** argv) { 56 | mpfr_init2(mval, MPFR_PREC); 57 | int wrongBfloatCount = 0; 58 | unsigned long long count = 0; 59 | 60 | bfloat16 x = 0.0; 61 | for (; count < 0x10000; count++) { 62 | x.val = count; 63 | bfloat16 bres = rlibm_sinpi(x); 64 | bfloat16 bmy = MpfrCalculateSinpi(x); 65 | 66 | // if bres is nan and bmy is nan, continue 67 | if (bres != bres && bmy != bmy) continue; 68 | if (bres != bmy) wrongBfloatCount++; 69 | } 70 | 71 | printf("Found %d/%llu values that did not calculate correctly\n", wrongBfloatCount, count); 72 | mpfr_clear(mval); 73 | } 74 | -------------------------------------------------------------------------------- /libtest/posit16/cbrt.cpp: -------------------------------------------------------------------------------- 1 | #import "mpfr.h" 2 | #import "posit16_math.h" 3 | #import "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | mpfr_t mval; 7 | 8 | double MpfrCalculateSqrt(posit16 x) { 9 | mpfr_set_d(mval, x.toDouble(), MPFR_RNDN); 10 | mpfr_sqrt(mval, mval, MPFR_RNDN); 11 | 12 | // Check for Nan 13 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 14 | // Check for infinity 15 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 16 | // Check for 0 17 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 18 | 19 | // Otherwise we need to run non-zero values. 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, pow(2, 26)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 24 | if (mpfr_cmp_d(mval, pow(2, -26)) <= 0) return castP16(0x0002); 25 | } else { 26 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 27 | if (mpfr_cmp_d(mval, -pow(2, 26)) <= 0) return castP16(0x8002); 28 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 29 | if (mpfr_cmp_d(mval, -pow(2, -26)) >= 0) return castP16(0xfffe); 30 | } 31 | 32 | long exp; 33 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 34 | long origExp = exp; 35 | fr *= 2; 36 | exp--; 37 | if (exp < 0) { 38 | exp *= -1; 39 | exp--;; 40 | } 41 | exp >>= 1; 42 | long p = 13 - exp; 43 | mpfr_t r; 44 | mpfr_init2(r, p); 45 | mpfr_set(r, mval, MPFR_RNDN); 46 | double retVal = mpfr_get_d(r, MPFR_RNDN); 47 | mpfr_clear(r); 48 | return convertDoubleToP16(retVal); 49 | } 50 | 51 | int main(int argc, char** argv) { 52 | mpfr_init2(mval, MPFR_PREC); 53 | int wrongDoubleCount = 0; 54 | int count = 0; 55 | 56 | posit16 x = 0.0; 57 | for (; count < 0x10000; count++) { 58 | x.value = count; 59 | posit16 bres = rlibm_sqrt(x); 60 | posit16 bmy = MpfrCalculateSqrt(x); 61 | 62 | // if bres is nan and bmy is nan, continue 63 | if (bres != bres && bmy != bmy) continue; 64 | if (bres != bmy) { 65 | printf("x = %.30e\n", x.toDouble()); 66 | wrongDoubleCount++; 67 | } 68 | } 69 | 70 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 71 | mpfr_clear(mval); 72 | } 73 | -------------------------------------------------------------------------------- /libtest/float/Log2.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "float_math.h" 3 | #include 4 | 5 | #define MPFR_PREC 24 6 | mpfr_t mval; 7 | 8 | float MpfrCalculateLog2(float x) { 9 | mpfr_set_d(mval, (float)x, MPFR_RNDN); 10 | mpfr_log2(mval, mval, MPFR_RNDN); 11 | double retVal = mpfr_get_d(mval, MPFR_RNDN); 12 | 13 | if (retVal == 0) return 0.0; 14 | if (retVal != retVal) { 15 | return retVal; 16 | } 17 | 18 | if (mpfr_cmp_d(mval, pow(2, -150)) <= 0 && mpfr_cmp_d(mval, -pow(2, -150)) >= 0) { 19 | return 0; 20 | } 21 | 22 | long exp; 23 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 24 | fr *= 2; 25 | exp--; 26 | 27 | if (mpfr_cmp_d(mval, 0.0) > 0) { 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -149)) < 0) return pow(2, -149); 29 | if (mpfr_cmp_d(mval, pow(2, -148)) < 0) return pow(2, -148); 30 | 31 | } else { 32 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -149)) > 0) return -pow(2, -149); 33 | if (mpfr_cmp_d(mval, -pow(2, -148)) > 0) return -pow(2, -148); 34 | } 35 | 36 | if (exp >= -148 && exp <= -127) { 37 | int prec = 150 + exp; 38 | mpfr_t r; 39 | mpfr_init2(r, prec); 40 | mpfr_set(r, mval, MPFR_RNDN); 41 | retVal = mpfr_get_d(r, MPFR_RNDN); 42 | mpfr_clear(r); 43 | return retVal; 44 | } else { 45 | mpfr_t r; 46 | mpfr_init2(r, 24); 47 | mpfr_set(r, mval, MPFR_RNDN); 48 | retVal = mpfr_get_d(r, MPFR_RNDN); 49 | mpfr_clear(r); 50 | return retVal; 51 | } 52 | } 53 | 54 | int main(int argc, char** argv) { 55 | mpfr_init2(mval, MPFR_PREC); 56 | int wrongFloat16Count = 0; 57 | unsigned long long count = 0; 58 | 59 | float x; 60 | floatX xbase; 61 | for (count = 0x0; count < 0x100000000; count++) { 62 | xbase.x = count; 63 | x = xbase.f; 64 | 65 | float bres = rlibm_log2(x); 66 | float bmy = MpfrCalculateLog2(x); 67 | 68 | // if bres is nan and bmy is nan, continue 69 | if (bres != bres && bmy != bmy) continue; 70 | if (bres != bmy) wrongFloat16Count++; 71 | 72 | if (count % 100000 == 0 && count != 0) { 73 | printf("Found %d/%llu values that did not calculate correctly\r", wrongFloat16Count, count); 74 | fflush(stdout); 75 | } 76 | } 77 | 78 | printf("Found %d/%llu values that did not calculate correctly\n", wrongFloat16Count, count); 79 | mpfr_clear(mval); 80 | } 81 | -------------------------------------------------------------------------------- /libtest/posit16/exp.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateExp(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_exp(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | int main(int argc, char** argv) { 63 | mpfr_init2(mval, MPFR_PREC); 64 | int wrongDoubleCount = 0; 65 | int count = 0; 66 | 67 | for (; count < 0x10000; count++) { 68 | posit16_t x = castP16(count); 69 | posit16_t bres = rlibm_exp(x); 70 | posit16_t bmy = MpfrCalculateExp(x); 71 | 72 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 73 | } 74 | 75 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 76 | 77 | mpfr_clear(mval); 78 | } 79 | -------------------------------------------------------------------------------- /libtest/posit16/log.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateLog(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_log(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | int main(int argc, char** argv) { 63 | mpfr_init2(mval, MPFR_PREC); 64 | int wrongDoubleCount = 0; 65 | int count = 0; 66 | 67 | for (; count < 0x10000; count++) { 68 | posit16_t x = castP16(count); 69 | posit16_t bres = rlibm_log(x); 70 | posit16_t bmy = MpfrCalculateLog(x); 71 | 72 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 73 | } 74 | 75 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 76 | 77 | mpfr_clear(mval); 78 | } 79 | -------------------------------------------------------------------------------- /libtest/posit16/exp2.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateExp2(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_exp2(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | int main(int argc, char** argv) { 63 | mpfr_init2(mval, MPFR_PREC); 64 | int wrongDoubleCount = 0; 65 | int count = 0; 66 | 67 | for (; count < 0x10000; count++) { 68 | posit16_t x = castP16(count); 69 | posit16_t bres = rlibm_exp2(x); 70 | posit16_t bmy = MpfrCalculateExp2(x); 71 | 72 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 73 | } 74 | 75 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 76 | 77 | mpfr_clear(mval); 78 | } 79 | -------------------------------------------------------------------------------- /libtest/posit16/exp10.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateExp10(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_exp10(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | int main(int argc, char** argv) { 63 | mpfr_init2(mval, MPFR_PREC); 64 | int wrongDoubleCount = 0; 65 | int count = 0; 66 | 67 | for (; count < 0x10000; count++) { 68 | posit16_t x = castP16(count); 69 | posit16_t bres = rlibm_exp10(x); 70 | posit16_t bmy = MpfrCalculateExp10(x); 71 | 72 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 73 | } 74 | 75 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 76 | 77 | mpfr_clear(mval); 78 | } 79 | -------------------------------------------------------------------------------- /libtest/posit16/log10.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateLog10(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_log10(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | int main(int argc, char** argv) { 63 | mpfr_init2(mval, MPFR_PREC); 64 | int wrongDoubleCount = 0; 65 | int count = 0; 66 | 67 | for (; count < 0x10000; count++) { 68 | posit16_t x = castP16(count); 69 | posit16_t bres = rlibm_log10(x); 70 | posit16_t bmy = MpfrCalculateLog10(x); 71 | 72 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 73 | } 74 | 75 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 76 | 77 | mpfr_clear(mval); 78 | } 79 | -------------------------------------------------------------------------------- /libtest/posit16/log2.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateLog2(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_log2(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | 63 | int main(int argc, char** argv) { 64 | mpfr_init2(mval, MPFR_PREC); 65 | int wrongDoubleCount = 0; 66 | int count = 0; 67 | 68 | for (; count < 0x10000; count++) { 69 | posit16_t x = castP16(count); 70 | posit16_t bres = rlibm_log2(x); 71 | posit16_t bmy = MpfrCalculateLog2(x); 72 | 73 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 74 | } 75 | 76 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 77 | 78 | mpfr_clear(mval); 79 | } 80 | -------------------------------------------------------------------------------- /libtest/posit16/sqrt.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateSqrt(posit16_t x) { 10 | mpfr_set_d(mval, convertP16ToDouble(x), MPFR_RNDN); 11 | mpfr_sqrt(mval, mval, MPFR_RNDN); 12 | 13 | // Check for Nan 14 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 15 | // Check for infinity 16 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 17 | // Check for 0 18 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 19 | 20 | if (mpfr_cmp_d(mval, 0) > 0) { 21 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 22 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 23 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 24 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 25 | 26 | 27 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 28 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 29 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 30 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 31 | } else { 32 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 33 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 34 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 35 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 36 | 37 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 38 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 39 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 40 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 41 | } 42 | 43 | long exp; 44 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 45 | long origExp = exp; 46 | fr *= 2; 47 | exp--; 48 | if (exp < 0) { 49 | exp *= -1; 50 | exp--;; 51 | } 52 | exp >>= 1; 53 | long p = 13 - exp; 54 | mpfr_t r; 55 | mpfr_init2(r, p); 56 | mpfr_set(r, mval, MPFR_RNDN); 57 | double retVal = mpfr_get_d(r, MPFR_RNDN); 58 | mpfr_clear(r); 59 | return convertDoubleToP16(retVal); 60 | } 61 | 62 | int main(int argc, char** argv) { 63 | mpfr_init2(mval, MPFR_PREC); 64 | int wrongDoubleCount = 0; 65 | int count = 0; 66 | 67 | for (; count < 0x10000; count++) { 68 | posit16_t x = castP16(count); 69 | 70 | posit16_t bres = rlibm_sqrt(x); 71 | posit16_t bmy = MpfrCalculateSqrt(x); 72 | 73 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 74 | } 75 | 76 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 77 | mpfr_clear(mval); 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RLibm 2 | 3 | RLibm is a math library that provides correctly rounded result for all inputs. Currently, RLibm supports a number of elementary functions for bfloat16, posit16, and float representations. rlibm is generated using the technique described from this [paper](https://arxiv.org/pdf/2007.05344.pdf). 4 | 5 | ## Installation 6 | To compile the math library, please follow the instructions below. 7 | This compilation instruction conrates separate math library for each of the available representations. 8 | 9 | ### Prerequisite 10 | If you want to compile the math library for posit16, you have to install SoftPosit. Please follow the instructions from the [SoftPosit GitLab](https://gitlab.com/cerlane/SoftPosit). 11 | 12 | ### Installation step 13 | 1. Clone the rlibm repository 14 | ``` 15 | git clone https://github.com/rutgers-apl/rlibm.git 16 | ``` 17 | 18 | 2. Create an environment variable SOFTPOSITPATH that points to the directory of SoftPosit: 19 | ``` 20 | export SOFTPOSITPATH= 21 | ``` 22 | 23 | 3. Build the math library 24 | 1. If you want to build all the math libraries, simply use make rule 25 | ``` 26 | cd rlibm 27 | make 28 | ``` 29 | 30 | 2. If you want to build math libraries for each representation separately, you can use these make rule 31 | ``` 32 | cd rlibm 33 | make bfloat16mlib 34 | make posit16mlib 35 | make floatmlib 36 | ``` 37 | 4. (Optional) Test that the math library does produce the correct value. This step requires MPFR installed. 38 | 1. To run the correctness bench suite for all math libraries, run 39 | ``` 40 | ./runLibTest.sh 41 | ``` 42 | 2. The correctness bench suite for math library is located in the libtest folder. 43 | ``` 44 | cd libtest/bfloat16 45 | make 46 | ./runAll.sh 47 | ``` 48 | 49 | ## USAGE 50 | The math library will be located in the lib directory: 51 | * bfloat16MathLib.a : math library for bfloat16 52 | * floatMathLib.a : math library for float 53 | * posit16MathLib.a : math library for posit16. 54 | 55 | The header files for each library is located in the include directory: 56 | * bfloat16_math.hpp : header for bfloat16 math library 57 | * float_math.h : header for float math library 58 | * posit16_math.h : header for posit16 math library 59 | 60 | If you want to use the bfloat16 math library, you need to also include `bfloat16.hpp` which constains our custom bfloat16 class. 61 | 62 | You can use our library in the code similar to how standard math library is used, except our function names start with "rlibm_": 63 | ``` 64 | test.cpp: 65 | #include "float_math.h" 66 | int main() { 67 | float result = rlibm_cospi(1.5f); 68 | return 0; 69 | } 70 | ``` 71 | 72 | To build the program, include the math library in the compilation command: 73 | ``` 74 | g++ test.cpp ../../lib/floatMathLib.a -lm -o test 75 | ``` 76 | Currently, RLibm uses some functions from the default math library for range reduction, such as to decompose a floating point value into the integral part and fractional part. 77 | -------------------------------------------------------------------------------- /libtest/posit16/sinpi.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateSinpi(posit16_t x) { 10 | double dx = convertP16ToDouble(x); 11 | double integral, frac; 12 | frac = modf(dx, &integral); 13 | if (frac == 0.0) { 14 | return castP16(0x0); 15 | } 16 | 17 | mpfr_const_pi(mval, MPFR_RNDN); 18 | mpfr_mul_d(mval, mval, convertP16ToDouble(x), MPFR_RNDN); 19 | mpfr_sin(mval, mval, MPFR_RNDN); 20 | 21 | // Check for Nan 22 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 23 | // Check for infinity 24 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 25 | // Check for 0 26 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 27 | 28 | if (mpfr_cmp_d(mval, 0) > 0) { 29 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 30 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 31 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 32 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 33 | 34 | 35 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 36 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 37 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 38 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 39 | } else { 40 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 41 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 42 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 43 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 44 | 45 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 46 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 47 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 48 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 49 | } 50 | 51 | long exp; 52 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 53 | long origExp = exp; 54 | fr *= 2; 55 | exp--; 56 | if (exp < 0) { 57 | exp *= -1; 58 | exp--;; 59 | } 60 | exp >>= 1; 61 | long p = 13 - exp; 62 | mpfr_t r; 63 | mpfr_init2(r, p); 64 | mpfr_set(r, mval, MPFR_RNDN); 65 | double retVal = mpfr_get_d(r, MPFR_RNDN); 66 | mpfr_clear(r); 67 | return convertDoubleToP16(retVal); 68 | } 69 | 70 | int main(int argc, char** argv) { 71 | mpfr_init2(mval, MPFR_PREC); 72 | int wrongDoubleCount = 0; 73 | int count = 0; 74 | 75 | for (; count < 0x10000; count++) { 76 | posit16_t x = castP16(count); 77 | posit16_t bres = rlibm_sinpi(x); 78 | posit16_t bmy = MpfrCalculateSinpi(x); 79 | 80 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 81 | } 82 | 83 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 84 | 85 | mpfr_clear(mval); 86 | } 87 | -------------------------------------------------------------------------------- /libtest/posit16/cospi.cpp: -------------------------------------------------------------------------------- 1 | #include "mpfr.h" 2 | #include "posit16_math.h" 3 | #include "softposit.h" 4 | 5 | #define MPFR_PREC 2000 6 | 7 | mpfr_t mval; 8 | 9 | posit16_t MpfrCalculateCospi(posit16_t x) { 10 | // Special case that MPFR can't handle: 11 | double dx = convertP16ToDouble(x); 12 | double integral, frac; 13 | frac = modf(dx, &integral); 14 | if (frac == 0.5 || frac == -0.5) { 15 | return castP16(0x0); 16 | } 17 | mpfr_const_pi(mval, MPFR_RNDN); 18 | mpfr_mul_d(mval, mval, convertP16ToDouble(x), MPFR_RNDN); 19 | mpfr_cos(mval, mval, MPFR_RNDN); 20 | 21 | // Check for Nan 22 | if (mpfr_nan_p(mval) != 0) return castP16(0x8000); 23 | // Check for infinity 24 | if (mpfr_inf_p(mval) != 0) return castP16(0x8000); 25 | // Check for 0 26 | if (mpfr_cmp_d(mval, 0.0) == 0) return castP16(0x0); 27 | 28 | if (mpfr_cmp_d(mval, 0) > 0) { 29 | if (mpfr_cmp_d(mval, pow(2, 27)) > 0) return castP16(0x7fff); 30 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 25)) >= 0) return castP16(0x7ffe); 31 | if (mpfr_cmp_d(mval, 1.5 * pow(2, 24)) > 0) return castP16(0x7ffd); 32 | if (mpfr_cmp_d(mval, pow(2, 24)) >= 0) return castP16(0x7ffc); 33 | 34 | 35 | if (mpfr_cmp_d(mval, pow(2, -27)) < 0) return castP16(0x0001); 36 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -26)) <= 0) return castP16(0x0002); 37 | if (mpfr_cmp_d(mval, 1.5 * pow(2, -25)) < 0) return castP16(0x0003); 38 | if (mpfr_cmp_d(mval, pow(2, -24)) <= 0) return castP16(0x0004); 39 | } else { 40 | if (mpfr_cmp_d(mval, -pow(2, 27)) < 0) return castP16(0x8001); 41 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 25)) <= 0) return castP16(0x8002); 42 | if (mpfr_cmp_d(mval, -1.5 * pow(2, 24)) < 0) return castP16(0x8003); 43 | if (mpfr_cmp_d(mval, -pow(2, 24)) <= 0) return castP16(0x8004); 44 | 45 | if (mpfr_cmp_d(mval, -pow(2, -27)) > 0) return castP16(0xffff); 46 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -26)) >= 0) return castP16(0xfffe); 47 | if (mpfr_cmp_d(mval, -1.5 * pow(2, -25)) > 0) return castP16(0xfffd); 48 | if (mpfr_cmp_d(mval, -pow(2, -24)) >= 0) return castP16(0xfffc); 49 | } 50 | 51 | long exp; 52 | double fr = mpfr_get_d_2exp(&exp, mval, MPFR_RNDN); 53 | long origExp = exp; 54 | fr *= 2; 55 | exp--; 56 | if (exp < 0) { 57 | exp *= -1; 58 | exp--;; 59 | } 60 | exp >>= 1; 61 | long p = 13 - exp; 62 | mpfr_t r; 63 | mpfr_init2(r, p); 64 | mpfr_set(r, mval, MPFR_RNDN); 65 | double retVal = mpfr_get_d(r, MPFR_RNDN); 66 | mpfr_clear(r); 67 | return convertDoubleToP16(retVal); 68 | } 69 | 70 | int main(int argc, char** argv) { 71 | mpfr_init2(mval, MPFR_PREC); 72 | int wrongDoubleCount = 0; 73 | int count = 0; 74 | 75 | for (; count < 0x10000; count++) { 76 | posit16_t x = castP16(count); 77 | posit16_t bres = rlibm_cospi(x); 78 | posit16_t bmy = MpfrCalculateCospi(x); 79 | 80 | if (!p16_eq(bres, bmy)) wrongDoubleCount++; 81 | } 82 | 83 | printf("Found %d/%d values that did not calculate correctly\n", wrongDoubleCount, count); 84 | 85 | mpfr_clear(mval); 86 | } 87 | -------------------------------------------------------------------------------- /include/bfloat16.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | union floatint{ 8 | float f; 9 | unsigned int x; 10 | }; 11 | 12 | union doubleint{ 13 | double d; 14 | unsigned long long int x; 15 | }; 16 | 17 | // In bfloat16, we assume the RNE rounding mode: 18 | // Round to nearest tie goes to even. We have to do correct rounding 19 | // for every cast from float/double to bfloat16. 20 | inline unsigned short RoundFloatToBFloat16(float v) { 21 | floatint temp; 22 | temp.f = v; 23 | 24 | // There is one exception we much check: If it's NaN, make sure 25 | // it stays at NaN. The only case is when x111 1111 1111 1111: 26 | // There should not be any rounding up. 27 | if (((temp.x >> 16) & 0x7FFF) == 0x7FFF) { 28 | return temp.x >> 16; 29 | } 30 | 31 | // Calculate last bit, bit+1, and S bit: 32 | unsigned short lb = (temp.x >> 16) & 0x1; 33 | unsigned short bp1 = (temp.x >> 15) & 0x1; 34 | unsigned short sb = ((temp.x & 0x7FFF) == 0) ? 0 : 1; 35 | 36 | // Apply rounding rule 37 | unsigned short round = (lb & bp1) | (bp1 & sb); 38 | return (temp.x >> 16) + round; 39 | } 40 | 41 | // In bfloat16, we assume the RNE rounding mode: 42 | // Round to nearest tie goes to even. We have to do correct rounding 43 | // for every cast from float/double to bfloat16. 44 | inline unsigned short RoundDoubleToBFloat16(double v) { 45 | doubleint temp; 46 | temp.d = v; 47 | // Take care of Infinity 48 | if (temp.x >= 0x47EFF00000000000 && temp.x <= 0x7FF0000000000000) { 49 | return 0x7F80; 50 | } 51 | if (temp.x >= 0xC7EFF00000000000 && temp.x <= 0xFFF0000000000000) { 52 | return 0xFF80; 53 | } 54 | 55 | // Take care of NaN 56 | if ((temp.x & 0x7FF0000000000000) == 0x7FF0000000000000) { 57 | return temp.x >> 48; 58 | } 59 | 60 | long long int exp = (temp.x >> 52) & 0x7FF; 61 | exp -= 1023; 62 | bool lb, bp1, sb; 63 | unsigned long long int mask = 0x1; 64 | unsigned short mantissa; 65 | unsigned short expbits; 66 | unsigned short signedBit = ((temp.x >> 48) & 0x8000); 67 | 68 | 69 | if (exp <= -135) { 70 | return (temp.x >> 48) & 0x8000; 71 | } 72 | 73 | if (exp == -134) { 74 | lb = false; 75 | bp1 = true; 76 | sb = (temp.x & ((mask << 52) - 1)) != 0; 77 | mantissa = 0; 78 | expbits = 0; 79 | } 80 | 81 | else if (exp == -133) { 82 | lb = true; 83 | bp1 = ((temp.x >> 51) & 0x1) == 0x1; 84 | sb = (temp.x & ((mask << 51) - 1)) != 0; 85 | mantissa = 1; 86 | expbits = 0; 87 | } 88 | 89 | else if (-132 <= exp && exp <= -127) { 90 | unsigned long long int shift1 = (unsigned long long int)(-exp) - 81; 91 | unsigned long long int shift2 = (unsigned long long int)(-exp) - 82; 92 | lb = ((temp.x >> shift1) & 0x1) == 0x1; 93 | bp1 = ((temp.x >> shift2) & 0x1) == 0x1; 94 | sb = (temp.x & ((mask << shift2) - 1)) != 0; 95 | mantissa = ((temp.x & 0x000FFFFFFFFFFFFF) | 0x0010000000000000) >> shift1; 96 | expbits = 0; 97 | } 98 | 99 | else if (exp >= -126) { 100 | lb = ((temp.x >> 45) & 0x1) == 0x1; 101 | bp1 = ((temp.x >> 44) & 0x1) == 0x1; 102 | sb = (temp.x & ((mask << 44) - 1)) != 0; 103 | mantissa = (temp.x >> 45) & 0x7F; 104 | expbits = (exp + 127) << 7; 105 | } 106 | 107 | // Put everything together: 108 | unsigned short intermediateRes = signedBit | mantissa | expbits; 109 | 110 | // Perform rounding 111 | if ((lb && bp1) || (bp1 && sb)) { 112 | intermediateRes++; 113 | } 114 | 115 | return intermediateRes; 116 | } 117 | 118 | 119 | 120 | 121 | class bfloat16 { 122 | public : 123 | unsigned short val; 124 | bfloat16() { 125 | val = 0; 126 | } 127 | bfloat16(float v) { 128 | val = RoundFloatToBFloat16(v); 129 | } 130 | 131 | bfloat16(double v) { 132 | val = RoundDoubleToBFloat16(v); 133 | } 134 | 135 | bfloat16(unsigned short v) { 136 | val = v; 137 | } 138 | 139 | explicit operator float() const { 140 | floatint temp; 141 | temp.x = val; 142 | temp.x <<= 16; 143 | return temp.f; 144 | } 145 | 146 | explicit operator double() const { 147 | floatint temp; 148 | temp.x = val; 149 | temp.x <<= 16; 150 | return (double)temp.f; 151 | } 152 | 153 | const bool operator==(const bfloat16& other) { 154 | return (float)(*this) == (float)other; 155 | } 156 | 157 | const bool operator<(const bfloat16& other) { 158 | return (float)(*this) < (float)other; 159 | } 160 | 161 | const bool operator!=(const bfloat16& other) { 162 | return !(*this == other); 163 | } 164 | const bool operator<=(const bfloat16& other) { 165 | return (*this == other) || (*this < other); 166 | } 167 | const bool operator>(const bfloat16& other) { 168 | return !(*this < other) && (*this != other); 169 | } 170 | const bool operator>=(const bfloat16& other) { 171 | return !(*this < other); 172 | } 173 | 174 | const bool operator==(const float& other) { 175 | return (float)(*this) == other; 176 | } 177 | 178 | const bool operator<(const float& other) { 179 | return (float)(*this) < other; 180 | } 181 | 182 | const bool operator!=(const float& other) { 183 | return !(*this == other); 184 | } 185 | const bool operator<=(const float& other) { 186 | return (*this == other) || (*this < other); 187 | } 188 | const bool operator>(const float& other) { 189 | return !(*this < other) && (*this != other); 190 | } 191 | const bool operator>=(const float& other) { 192 | return !(*this < other); 193 | } 194 | 195 | }; 196 | -------------------------------------------------------------------------------- /include/float_headers/Exp2.h: -------------------------------------------------------------------------------- 1 | //#define bitsSame 7 2 | //#define N 4 3 | static const double exp2NegCoeffs[16][5] = { 4 | { 5 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 6 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 7 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 8 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 9 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 10 | }, 11 | { 12 | 1.0000000031165947600442223119898699223995208740234375000000000000000000000000000000000000000000000000e+00, 13 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 14 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 15 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 16 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 17 | }, 18 | { 19 | 1.0000000128568629076397655808250419795513153076171875000000000000000000000000000000000000000000000000e+00, 20 | 1.3273943165938058008634925499791279435157775878906250000000000000000000000000000000000000000000000000e+00, 21 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 22 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 23 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 24 | }, 25 | { 26 | 1.0000000005255809121251786564243957400321960449218750000000000000000000000000000000000000000000000000e+00, 27 | 7.0537118239547524911614573284168727695941925048828125000000000000000000000000000000000000000000000000e-01, 28 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 29 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 30 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 31 | }, 32 | { 33 | 1.0000000000000146549439250520663335919380187988281250000000000000000000000000000000000000000000000000e+00, 34 | 6.9314731742851731777221857555559836328029632568359375000000000000000000000000000000000000000000000000e-01, 35 | 5.4503127010973584365416400032700039446353912353515625000000000000000000000000000000000000000000000000e-01, 36 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 37 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 38 | }, 39 | { 40 | 1.0000000000000117683640610266593284904956817626953125000000000000000000000000000000000000000000000000e+00, 41 | 6.9314720718263134191516883220174349844455718994140625000000000000000000000000000000000000000000000000e-01, 42 | 2.5305322562915555373308507114415988326072692871093750000000000000000000000000000000000000000000000000e-01, 43 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 44 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 45 | }, 46 | { 47 | 1.0000000000000894839757847876171581447124481201171875000000000000000000000000000000000000000000000000e+00, 48 | 6.9314722489639635227831604424864053726196289062500000000000000000000000000000000000000000000000000000e-01, 49 | 2.4478374958753720824766730856936192139983177185058593750000000000000000000000000000000000000000000000e-01, 50 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 51 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 52 | }, 53 | { 54 | 1.0000000000000641708908233340480364859104156494140625000000000000000000000000000000000000000000000000e+00, 55 | 6.9314718823059995322921622573630884289741516113281250000000000000000000000000000000000000000000000000e-01, 56 | 2.4043163806388942460579016824340214952826499938964843750000000000000000000000000000000000000000000000e-01, 57 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 58 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 59 | }, 60 | { 61 | 1.0000000000002371436380599334370344877243041992187500000000000000000000000000000000000000000000000000e+00, 62 | 6.9314718672919972686230494218762032687664031982421875000000000000000000000000000000000000000000000000e-01, 63 | 2.4025872750564966628950003268982982262969017028808593750000000000000000000000000000000000000000000000e-01, 64 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 65 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 66 | }, 67 | { 68 | 1.0000000000004580780199603395885787904262542724609375000000000000000000000000000000000000000000000000e+00, 69 | 6.9314718601838265499281988013535737991333007812500000000000000000000000000000000000000000000000000000e-01, 70 | 2.4024616918530497522432654022850329056382179260253906250000000000000000000000000000000000000000000000e-01, 71 | 7.7093204927958666750065219730458920821547508239746093750000000000000000000000000000000000000000000000e-02, 72 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 73 | }, 74 | { 75 | 1.0000000000002149391775674303062260150909423828125000000000000000000000000000000000000000000000000000e+00, 76 | 6.9314718118755236364592065001488663256168365478515625000000000000000000000000000000000000000000000000e-01, 77 | 2.4022705612511199846359488674352178350090980529785156250000000000000000000000000000000000000000000000e-01, 78 | 5.5634995496935575609587232293051783926784992218017578125000000000000000000000000000000000000000000000e-02, 79 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 80 | }, 81 | { 82 | 1.0000000000007753797603982093278318643569946289062500000000000000000000000000000000000000000000000000e+00, 83 | 6.9314718135564545864468755098641850054264068603515625000000000000000000000000000000000000000000000000e-01, 84 | 2.4022679696554993800106103662983514368534088134765625000000000000000000000000000000000000000000000000e-01, 85 | 5.5548296397392213363808366466400912031531333923339843750000000000000000000000000000000000000000000000e-02, 86 | 1.1995513181274206765403178565065900329500436782836914062500000000000000000000000000000000000000000000e-02 87 | }, 88 | { 89 | 1.0000000000055071502913506265031173825263977050781250000000000000000000000000000000000000000000000000e+00, 90 | 6.9314718241720574276598654250847175717353820800781250000000000000000000000000000000000000000000000000e-01, 91 | 2.4022673602258573510859207544854143634438514709472656250000000000000000000000000000000000000000000000e-01, 92 | 5.5516164004214330063291527039837092161178588867187500000000000000000000000000000000000000000000000000e-02, 93 | 9.8253942477901940605322650412745133507996797561645507812500000000000000000000000000000000000000000000e-03 94 | }, 95 | { 96 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 97 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 98 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 99 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 100 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 101 | }, 102 | { 103 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 104 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 105 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 106 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 107 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 108 | }, 109 | { 110 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 111 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 112 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 113 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 114 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 115 | } 116 | }; 117 | 118 | 119 | //unsigned bitsSame = 7; 120 | //unsigned N = 3 121 | static const double exp2PosCoeffs[8][5] = { 122 | { 123 | 1.0000000003077651467009445696021430194377899169921875000000000000000000000000000000000000000000000000e+00, 124 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 125 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 126 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 127 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 128 | }, 129 | { 130 | 9.9999999940810757603770753121352754533290863037109375000000000000000000000000000000000000000000000000e-01, 131 | 7.0012859417044592813539338749251328408718109130859375000000000000000000000000000000000000000000000000e-01, 132 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 133 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 134 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 135 | }, 136 | { 137 | 1.0000000000000235367281220533186569809913635253906250000000000000000000000000000000000000000000000000e+00, 138 | 6.9314712357467145320555346188484691083431243896484375000000000000000000000000000000000000000000000000e-01, 139 | 2.6964467438497036200217849000182468444108963012695312500000000000000000000000000000000000000000000000e-01, 140 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 141 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 142 | }, 143 | { 144 | 9.9999999999991984189762206369778141379356384277343750000000000000000000000000000000000000000000000000e-01, 145 | 6.9314721215507357765517326697590760886669158935546875000000000000000000000000000000000000000000000000e-01, 146 | 2.3768150448518915451856514664541464298963546752929687500000000000000000000000000000000000000000000000e-01, 147 | 5.3434601369952908100913191447034478187561035156250000000000000000000000000000000000000000000000000000e+01, 148 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 149 | }, 150 | { 151 | 9.9999999999994604316100321739213541150093078613281250000000000000000000000000000000000000000000000000e-01, 152 | 6.9314718207034065056149074735003523528575897216796875000000000000000000000000000000000000000000000000e-01, 153 | 2.4021701572604822749745778764918213710188865661621093750000000000000000000000000000000000000000000000e-01, 154 | 7.1264574700197841350401972704275976866483688354492187500000000000000000000000000000000000000000000000e-02, 155 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 156 | }, 157 | { 158 | 1.0000000000000288657986402540700510144233703613281250000000000000000000000000000000000000000000000000e+00, 159 | 6.9314718048482570900148402870399877429008483886718750000000000000000000000000000000000000000000000000e-01, 160 | 2.4022654947335245201323061792209045961499214172363281250000000000000000000000000000000000000000000000e-01, 161 | 5.5495493706561156710410642745046061463654041290283203125000000000000000000000000000000000000000000000e-02, 162 | 1.0203487920493317653303222414251649752259254455566406250000000000000000000000000000000000000000000000e-02 163 | }, 164 | { 165 | 1.0000000000206363814925225597107782959938049316406250000000000000000000000000000000000000000000000000e+00, 166 | 6.9314717293505800910224934341385960578918457031250000000000000000000000000000000000000000000000000000e-01, 167 | 2.4022754370022078584945290913310600444674491882324218750000000000000000000000000000000000000000000000e-01, 168 | 5.5442430410123352824136588878900511190295219421386718750000000000000000000000000000000000000000000000e-02, 169 | 1.0993164052745130893073977063068014103919267654418945312500000000000000000000000000000000000000000000e-02 170 | }, 171 | { 172 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 173 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 174 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 175 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 176 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 177 | } 178 | }; 179 | 180 | 181 | -------------------------------------------------------------------------------- /include/float_headers/Cosh.h: -------------------------------------------------------------------------------- 1 | //#define bitsSame 6 2 | //#define N 6 3 | static const double Cosh[64][3] = { 4 | { 5 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 6 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 7 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 8 | }, 9 | { 10 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 11 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 12 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 13 | }, 14 | { 15 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 16 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 17 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 18 | }, 19 | { 20 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 21 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 22 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 23 | }, 24 | { 25 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 26 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 27 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 28 | }, 29 | { 30 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 31 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 32 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 33 | }, 34 | { 35 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 36 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 37 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 38 | }, 39 | { 40 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 41 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 42 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 43 | }, 44 | { 45 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 46 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 47 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 48 | }, 49 | { 50 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 51 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 52 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 53 | }, 54 | { 55 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 56 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 57 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 58 | }, 59 | { 60 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 61 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 62 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 63 | }, 64 | { 65 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 66 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 67 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 68 | }, 69 | { 70 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 71 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 72 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 73 | }, 74 | { 75 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 76 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 77 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 78 | }, 79 | { 80 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 81 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 82 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 83 | }, 84 | { 85 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 86 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 87 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 88 | }, 89 | { 90 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 91 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 92 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 93 | }, 94 | { 95 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 96 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 97 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 98 | }, 99 | { 100 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 101 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 102 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 103 | }, 104 | { 105 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 106 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 107 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 108 | }, 109 | { 110 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 111 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 112 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 113 | }, 114 | { 115 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 116 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 117 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 118 | }, 119 | { 120 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 121 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 122 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 123 | }, 124 | { 125 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 126 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 127 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 128 | }, 129 | { 130 | 1.0000000679769509570604668624582700431346893310546875000000000000000000000000000000000000000000000000e+00, 131 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 132 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 133 | }, 134 | { 135 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 136 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 137 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 138 | }, 139 | { 140 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 141 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 142 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 143 | }, 144 | { 145 | 1.0000000132282746978518161995452828705310821533203125000000000000000000000000000000000000000000000000e+00, 146 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 147 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 148 | }, 149 | { 150 | 1.0000000085418998541086921250098384916782379150390625000000000000000000000000000000000000000000000000e+00, 151 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 152 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 153 | }, 154 | { 155 | 1.0000000283524321798012124418164603412151336669921875000000000000000000000000000000000000000000000000e+00, 156 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 157 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 158 | }, 159 | { 160 | 1.0000000001956959039262073929421603679656982421875000000000000000000000000000000000000000000000000000e+00, 161 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 162 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 163 | }, 164 | { 165 | 1.0000000001833804219586454564705491065979003906250000000000000000000000000000000000000000000000000000e+00, 166 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 167 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 168 | }, 169 | { 170 | 1.0000000018512198440845395452925004065036773681640625000000000000000000000000000000000000000000000000e+00, 171 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 172 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 173 | }, 174 | { 175 | 1.0000000003073830079358685907209292054176330566406250000000000000000000000000000000000000000000000000e+00, 176 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 177 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 178 | }, 179 | { 180 | 1.0000000023144024474675006786128506064414978027343750000000000000000000000000000000000000000000000000e+00, 181 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 182 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 183 | }, 184 | { 185 | 1.0000000000308382208658031231607310473918914794921875000000000000000000000000000000000000000000000000e+00, 186 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 187 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 188 | }, 189 | { 190 | 1.0000000005881501952131884536356665194034576416015625000000000000000000000000000000000000000000000000e+00, 191 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 192 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 193 | }, 194 | { 195 | 1.0000000004624904903494098107330501079559326171875000000000000000000000000000000000000000000000000000e+00, 196 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 197 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 198 | }, 199 | { 200 | 1.0000000000902207197839288710383698344230651855468750000000000000000000000000000000000000000000000000e+00, 201 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 202 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 203 | }, 204 | { 205 | 1.0000000001316948772256409938563592731952667236328125000000000000000000000000000000000000000000000000e+00, 206 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 207 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 208 | }, 209 | { 210 | 1.0000000000675646205650082265492528676986694335937500000000000000000000000000000000000000000000000000e+00, 211 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 212 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 213 | }, 214 | { 215 | 1.0000000000008466560785791443777270615100860595703125000000000000000000000000000000000000000000000000e+00, 216 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 217 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 218 | }, 219 | { 220 | 1.0000000000107662767589999930351041257381439208984375000000000000000000000000000000000000000000000000e+00, 221 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 222 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 223 | }, 224 | { 225 | 1.0000000000045505821333335916278883814811706542968750000000000000000000000000000000000000000000000000e+00, 226 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 227 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 228 | }, 229 | { 230 | 9.9999999999899025215910342012648470699787139892578125000000000000000000000000000000000000000000000000e-01, 231 | 5.2421605070205568033259169169468805193901062011718750000000000000000000000000000000000000000000000000e-01, 232 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 233 | }, 234 | { 235 | 9.9999999999629629598985047778114676475524902343750000000000000000000000000000000000000000000000000000e-01, 236 | 5.3792664250287502980540921271312981843948364257812500000000000000000000000000000000000000000000000000e-01, 237 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 238 | }, 239 | { 240 | 9.9999999999777167136727484830771572887897491455078125000000000000000000000000000000000000000000000000e-01, 241 | 5.0346822522879852712662795966025441884994506835937500000000000000000000000000000000000000000000000000e-01, 242 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 243 | }, 244 | { 245 | 9.9999999999951350027060925640398636460304260253906250000000000000000000000000000000000000000000000000e-01, 246 | 5.0019528918848377152528428268851712346076965332031250000000000000000000000000000000000000000000000000e-01, 247 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 248 | }, 249 | { 250 | 9.9999999999949573670221525389933958649635314941406250000000000000000000000000000000000000000000000000e-01, 251 | 5.0004969465310844523031619246467016637325286865234375000000000000000000000000000000000000000000000000e-01, 252 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 253 | }, 254 | { 255 | 9.9999999999967870145667347969720140099525451660156250000000000000000000000000000000000000000000000000e-01, 256 | 5.0000642172153708653326020794338546693325042724609375000000000000000000000000000000000000000000000000e-01, 257 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 258 | }, 259 | { 260 | 9.9999999999993860466673822884331457316875457763671875000000000000000000000000000000000000000000000000e-01, 261 | 5.0000056153810346071253434274694882333278656005859375000000000000000000000000000000000000000000000000e-01, 262 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 263 | }, 264 | { 265 | 9.9999999999996669330926124530378729104995727539062500000000000000000000000000000000000000000000000000e-01, 266 | 5.0000009239919751546921133922296576201915740966796875000000000000000000000000000000000000000000000000e-01, 267 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 268 | }, 269 | { 270 | 1.0000000000000202060590481778490357100963592529296875000000000000000000000000000000000000000000000000e+00, 271 | 4.9999997141850721638078880459943320602178573608398437500000000000000000000000000000000000000000000000e-01, 272 | 5.1077778785664496030705095108714886009693145751953125000000000000000000000000000000000000000000000000e-02 273 | }, 274 | { 275 | 1.0000000000000199840144432528177276253700256347656250000000000000000000000000000000000000000000000000e+00, 276 | 4.9999999586698340436896614846773445606231689453125000000000000000000000000000000000000000000000000000e-01, 277 | 4.1864446644970375321914701771675026975572109222412109375000000000000000000000000000000000000000000000e-02 278 | }, 279 | { 280 | 1.0000000000000182076576038525672629475593566894531250000000000000000000000000000000000000000000000000e+00, 281 | 4.9999999877348610954896912517142482101917266845703125000000000000000000000000000000000000000000000000e-01, 282 | 4.1685345243943149051712993014007224701344966888427734375000000000000000000000000000000000000000000000e-02 283 | }, 284 | { 285 | 1.0000000000001092459456231154035776853561401367187500000000000000000000000000000000000000000000000000e+00, 286 | 4.9999999731279898274038941963226534426212310791015625000000000000000000000000000000000000000000000000e-01, 287 | 4.1682427257835892586701476147936773486435413360595703125000000000000000000000000000000000000000000000e-02 288 | }, 289 | { 290 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 291 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 292 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 293 | }, 294 | { 295 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 296 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 297 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 298 | }, 299 | { 300 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 301 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 302 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 303 | }, 304 | { 305 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 306 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 307 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 308 | }, 309 | { 310 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 311 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 312 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 313 | }, 314 | { 315 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 316 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 317 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 318 | }, 319 | { 320 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 321 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 322 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 323 | } 324 | }; 325 | 326 | 327 | -------------------------------------------------------------------------------- /include/float_headers/Sinh.h: -------------------------------------------------------------------------------- 1 | //#define bitsSame 6 2 | //#define N 6 3 | static const double Sinh[64][3] = { 4 | { 5 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 6 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 7 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 8 | }, 9 | { 10 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 11 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 12 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 13 | }, 14 | { 15 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 16 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 17 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 18 | }, 19 | { 20 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 21 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 22 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 23 | }, 24 | { 25 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 26 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 27 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 28 | }, 29 | { 30 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 31 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 32 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 33 | }, 34 | { 35 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 36 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 37 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 38 | }, 39 | { 40 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 41 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 42 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 43 | }, 44 | { 45 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 46 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 47 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 48 | }, 49 | { 50 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 51 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 52 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 53 | }, 54 | { 55 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 56 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 57 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 58 | }, 59 | { 60 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 61 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 62 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 63 | }, 64 | { 65 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 66 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 67 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 68 | }, 69 | { 70 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 71 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 72 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 73 | }, 74 | { 75 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 76 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 77 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 78 | }, 79 | { 80 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 81 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 82 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 83 | }, 84 | { 85 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 86 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 87 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 88 | }, 89 | { 90 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 91 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 92 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 93 | }, 94 | { 95 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 96 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 97 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 98 | }, 99 | { 100 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 101 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 102 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 103 | }, 104 | { 105 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 106 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 107 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 108 | }, 109 | { 110 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 111 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 112 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 113 | }, 114 | { 115 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 116 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 117 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 118 | }, 119 | { 120 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 121 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 122 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 123 | }, 124 | { 125 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 126 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 127 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 128 | }, 129 | { 130 | 1.0000000679769509570604668624582700431346893310546875000000000000000000000000000000000000000000000000e+00, 131 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 132 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 133 | }, 134 | { 135 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 136 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 137 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 138 | }, 139 | { 140 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 141 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 142 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 143 | }, 144 | { 145 | 1.0000000132282746978518161995452828705310821533203125000000000000000000000000000000000000000000000000e+00, 146 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 147 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 148 | }, 149 | { 150 | 1.0000000085418996320640871999785304069519042968750000000000000000000000000000000000000000000000000000e+00, 151 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 152 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 153 | }, 154 | { 155 | 1.0000000283524321798012124418164603412151336669921875000000000000000000000000000000000000000000000000e+00, 156 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 157 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 158 | }, 159 | { 160 | 1.0000000001956959039262073929421603679656982421875000000000000000000000000000000000000000000000000000e+00, 161 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 162 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 163 | }, 164 | { 165 | 1.0000000001833804219586454564705491065979003906250000000000000000000000000000000000000000000000000000e+00, 166 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 167 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 168 | }, 169 | { 170 | 1.0000000018512198440845395452925004065036773681640625000000000000000000000000000000000000000000000000e+00, 171 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 172 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 173 | }, 174 | { 175 | 1.0000000003073827858912636656896211206912994384765625000000000000000000000000000000000000000000000000e+00, 176 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 177 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 178 | }, 179 | { 180 | 1.0000000023144022254228957535815425217151641845703125000000000000000000000000000000000000000000000000e+00, 181 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 182 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 183 | }, 184 | { 185 | 1.0000000000308382208658031231607310473918914794921875000000000000000000000000000000000000000000000000e+00, 186 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 187 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 188 | }, 189 | { 190 | 1.0000000005881497511239786035730503499507904052734375000000000000000000000000000000000000000000000000e+00, 191 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 192 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 193 | }, 194 | { 195 | 1.0000000004624898242155950356391258537769317626953125000000000000000000000000000000000000000000000000e+00, 196 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 197 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 198 | }, 199 | { 200 | 1.0000000000902171670702500705374404788017272949218750000000000000000000000000000000000000000000000000e+00, 201 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 202 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 203 | }, 204 | { 205 | 1.0000000001316819986385553420404903590679168701171875000000000000000000000000000000000000000000000000e+00, 206 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 207 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 208 | }, 209 | { 210 | 1.0000000000675453026843797488254494965076446533203125000000000000000000000000000000000000000000000000e+00, 211 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 212 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 213 | }, 214 | { 215 | 1.0000000000006981082378842984326183795928955078125000000000000000000000000000000000000000000000000000e+00, 216 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 217 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 218 | }, 219 | { 220 | 1.0000000000101965103027623626985587179660797119140625000000000000000000000000000000000000000000000000e+00, 221 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 222 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 223 | }, 224 | { 225 | 1.0000000000020576873538402651320211589336395263671875000000000000000000000000000000000000000000000000e+00, 226 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 227 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 228 | }, 229 | { 230 | 1.0000000000037154723742105488781817257404327392578125000000000000000000000000000000000000000000000000e+00, 231 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 232 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 233 | }, 234 | { 235 | 9.9999999999629585190064062771853059530258178710937500000000000000000000000000000000000000000000000000e-01, 236 | 2.0459579389350379674539226471097208559513092041015625000000000000000000000000000000000000000000000000e-01, 237 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 238 | }, 239 | { 240 | 9.9999999999777233750108962340163998305797576904296875000000000000000000000000000000000000000000000000e-01, 241 | 1.7013399405368795358484135249454993754625320434570312500000000000000000000000000000000000000000000000e-01, 242 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 243 | }, 244 | { 245 | 9.9999999999951327822600433137267827987670898437500000000000000000000000000000000000000000000000000000e-01, 246 | 1.6686202763047927599693309730355395004153251647949218750000000000000000000000000000000000000000000000e-01, 247 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 248 | }, 249 | { 250 | 9.9999999999949573670221525389933958649635314941406250000000000000000000000000000000000000000000000000e-01, 251 | 1.6671637396417415821758822858100757002830505371093750000000000000000000000000000000000000000000000000e-01, 252 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 253 | }, 254 | { 255 | 9.9999999999967859043437101718154735863208770751953125000000000000000000000000000000000000000000000000e-01, 256 | 1.6667308848742179439028632259578444063663482666015625000000000000000000000000000000000000000000000000e-01, 257 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 258 | }, 259 | { 260 | 9.9999999999993960386746039148420095443725585937500000000000000000000000000000000000000000000000000000e-01, 261 | 1.6666721614895502190378806517401244491338729858398437500000000000000000000000000000000000000000000000e-01, 262 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 263 | }, 264 | { 265 | 9.9999999999997934985174197208834812045097351074218750000000000000000000000000000000000000000000000000e-01, 266 | 1.6666671570087729370435170039854710921645164489746093750000000000000000000000000000000000000000000000e-01, 267 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 268 | }, 269 | { 270 | 9.9999999999996247446176766970893368124961853027343750000000000000000000000000000000000000000000000000e-01, 271 | 1.6666670560346769081050410932220984250307083129882812500000000000000000000000000000000000000000000000e-01, 272 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 273 | }, 274 | { 275 | 1.0000000000000202060590481778490357100963592529296875000000000000000000000000000000000000000000000000e+00, 276 | 1.6666666244585565115343683828541543334722518920898437500000000000000000000000000000000000000000000000e-01, 277 | 8.5366478596254243005336803662430611439049243927001953125000000000000000000000000000000000000000000000e-03 278 | }, 279 | { 280 | 1.0000000000000193178806284777238033711910247802734375000000000000000000000000000000000000000000000000e+00, 281 | 1.6666666538591143331693444906704826280474662780761718750000000000000000000000000000000000000000000000e-01, 282 | 8.3524939288317900237812452246544125955551862716674804687500000000000000000000000000000000000000000000e-03 283 | }, 284 | { 285 | 1.0000000000001059152765492399339564144611358642578125000000000000000000000000000000000000000000000000e+00, 286 | 1.6666666406190572269352401235664729028940200805664062500000000000000000000000000000000000000000000000e-01, 287 | 8.3484897908092485507847158032745937816798686981201171875000000000000000000000000000000000000000000000e-03 288 | }, 289 | { 290 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 291 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 292 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 293 | }, 294 | { 295 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 296 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 297 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 298 | }, 299 | { 300 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 301 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 302 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 303 | }, 304 | { 305 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 306 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 307 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 308 | }, 309 | { 310 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 311 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 312 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 313 | }, 314 | { 315 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 316 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 317 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 318 | }, 319 | { 320 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 321 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 322 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 323 | } 324 | }; 325 | 326 | 327 | -------------------------------------------------------------------------------- /include/float_headers/Backup/NewHeaders/Cosh.h: -------------------------------------------------------------------------------- 1 | unsigned bitsSame = 6; 2 | unsigned N = 7 3 | double coeffs[128][3] = { 4 | { 5 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 6 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 7 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 8 | }, 9 | { 10 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 11 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 12 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 13 | }, 14 | { 15 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 16 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 17 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 18 | }, 19 | { 20 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 21 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 22 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 23 | }, 24 | { 25 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 26 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 27 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 28 | }, 29 | { 30 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 31 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 32 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 33 | }, 34 | { 35 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 36 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 37 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 38 | }, 39 | { 40 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 41 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 42 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 43 | }, 44 | { 45 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 46 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 47 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 48 | }, 49 | { 50 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 51 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 52 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 53 | }, 54 | { 55 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 56 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 57 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 58 | }, 59 | { 60 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 61 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 62 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 63 | }, 64 | { 65 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 66 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 67 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 68 | }, 69 | { 70 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 71 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 72 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 73 | }, 74 | { 75 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 76 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 77 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 78 | }, 79 | { 80 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 81 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 82 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 83 | }, 84 | { 85 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 86 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 87 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 88 | }, 89 | { 90 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 91 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 92 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 93 | }, 94 | { 95 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 96 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 97 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 98 | }, 99 | { 100 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 101 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 102 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 103 | }, 104 | { 105 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 106 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 107 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 108 | }, 109 | { 110 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 111 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 112 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 113 | }, 114 | { 115 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 116 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 117 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 118 | }, 119 | { 120 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 121 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 122 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 123 | }, 124 | { 125 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 126 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 127 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 128 | }, 129 | { 130 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 131 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 132 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 133 | }, 134 | { 135 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 136 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 137 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 138 | }, 139 | { 140 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 141 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 142 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 143 | }, 144 | { 145 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 146 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 147 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 148 | }, 149 | { 150 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 151 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 152 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 153 | }, 154 | { 155 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 156 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 157 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 158 | }, 159 | { 160 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 161 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 162 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 163 | }, 164 | { 165 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 166 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 167 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 168 | }, 169 | { 170 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 171 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 172 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 173 | }, 174 | { 175 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 176 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 177 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 178 | }, 179 | { 180 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 181 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 182 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 183 | }, 184 | { 185 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 186 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 187 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 188 | }, 189 | { 190 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 191 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 192 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 193 | }, 194 | { 195 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 196 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 197 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 198 | }, 199 | { 200 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 201 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 202 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 203 | }, 204 | { 205 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 206 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 207 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 208 | }, 209 | { 210 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 211 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 212 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 213 | }, 214 | { 215 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 216 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 217 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 218 | }, 219 | { 220 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 221 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 222 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 223 | }, 224 | { 225 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 226 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 227 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 228 | }, 229 | { 230 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 231 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 232 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 233 | }, 234 | { 235 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 236 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 237 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 238 | }, 239 | { 240 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 241 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 242 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 243 | }, 244 | { 245 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 246 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 247 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 248 | }, 249 | { 250 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 251 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 252 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 253 | }, 254 | { 255 | 1.0000000679769509570604668624582700431346893310546875000000000000000000000000000000000000000000000000e+00, 256 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 257 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 258 | }, 259 | { 260 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 261 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 262 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 263 | }, 264 | { 265 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 266 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 267 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 268 | }, 269 | { 270 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 271 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 272 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 273 | }, 274 | { 275 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 276 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 277 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 278 | }, 279 | { 280 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 281 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 282 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 283 | }, 284 | { 285 | 1.0000000132282746978518161995452828705310821533203125000000000000000000000000000000000000000000000000e+00, 286 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 287 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 288 | }, 289 | { 290 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 291 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 292 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 293 | }, 294 | { 295 | 1.0000000085418998541086921250098384916782379150390625000000000000000000000000000000000000000000000000e+00, 296 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 297 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 298 | }, 299 | { 300 | 1.0000000304361194025659642647951841354370117187500000000000000000000000000000000000000000000000000000e+00, 301 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 302 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 303 | }, 304 | { 305 | 1.0000000551333074749749130205600522458553314208984375000000000000000000000000000000000000000000000000e+00, 306 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 307 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 308 | }, 309 | { 310 | 1.0000000283524321798012124418164603412151336669921875000000000000000000000000000000000000000000000000e+00, 311 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 312 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 313 | }, 314 | { 315 | 1.0000000001956959039262073929421603679656982421875000000000000000000000000000000000000000000000000000e+00, 316 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 317 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 318 | }, 319 | { 320 | 1.0000000017156920328886826609959825873374938964843750000000000000000000000000000000000000000000000000e+00, 321 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 322 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 323 | }, 324 | { 325 | 1.0000000001833804219586454564705491065979003906250000000000000000000000000000000000000000000000000000e+00, 326 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 327 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 328 | }, 329 | { 330 | 1.0000000153462758056832626607501879334449768066406250000000000000000000000000000000000000000000000000e+00, 331 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 332 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 333 | }, 334 | { 335 | 1.0000000098003360982090725883608683943748474121093750000000000000000000000000000000000000000000000000e+00, 336 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 337 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 338 | }, 339 | { 340 | 1.0000000018512198440845395452925004065036773681640625000000000000000000000000000000000000000000000000e+00, 341 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 342 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 343 | }, 344 | { 345 | 1.0000000003073830079358685907209292054176330566406250000000000000000000000000000000000000000000000000e+00, 346 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 347 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 348 | }, 349 | { 350 | 1.0000000132131416918923605408053845167160034179687500000000000000000000000000000000000000000000000000e+00, 351 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 352 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 353 | }, 354 | { 355 | 1.0000000038334317942201323603512719273567199707031250000000000000000000000000000000000000000000000000e+00, 356 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 357 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 358 | }, 359 | { 360 | 1.0000000023144024474675006786128506064414978027343750000000000000000000000000000000000000000000000000e+00, 361 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 362 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 363 | }, 364 | { 365 | 1.0000000000308382208658031231607310473918914794921875000000000000000000000000000000000000000000000000e+00, 366 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 367 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 368 | }, 369 | { 370 | 1.0000000038314669215111507583060301840305328369140625000000000000000000000000000000000000000000000000e+00, 371 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 372 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 373 | }, 374 | { 375 | 1.0000000005881501952131884536356665194034576416015625000000000000000000000000000000000000000000000000e+00, 376 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 377 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 378 | }, 379 | { 380 | 1.0000000010962657448487789224600419402122497558593750000000000000000000000000000000000000000000000000e+00, 381 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 382 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 383 | }, 384 | { 385 | 1.0000000004624904903494098107330501079559326171875000000000000000000000000000000000000000000000000000e+00, 386 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 387 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 388 | }, 389 | { 390 | 1.0000000005370865974185790037154220044612884521484375000000000000000000000000000000000000000000000000e+00, 391 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 392 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 393 | }, 394 | { 395 | 1.0000000001911415470345900757820345461368560791015625000000000000000000000000000000000000000000000000e+00, 396 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 397 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 398 | }, 399 | { 400 | 1.0000000000902207197839288710383698344230651855468750000000000000000000000000000000000000000000000000e+00, 401 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 402 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 403 | }, 404 | { 405 | 1.0000000001986437681011921085882931947708129882812500000000000000000000000000000000000000000000000000e+00, 406 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 407 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 408 | }, 409 | { 410 | 1.0000000001316948772256409938563592731952667236328125000000000000000000000000000000000000000000000000e+00, 411 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 412 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 413 | }, 414 | { 415 | 1.0000000000675646205650082265492528676986694335937500000000000000000000000000000000000000000000000000e+00, 416 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 417 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 418 | }, 419 | { 420 | 1.0000000000873616734509141679154708981513977050781250000000000000000000000000000000000000000000000000e+00, 421 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 422 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 423 | }, 424 | { 425 | 1.0000000000008466560785791443777270615100860595703125000000000000000000000000000000000000000000000000e+00, 426 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 427 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 428 | }, 429 | { 430 | 1.0000000000089537266489969624672085046768188476562500000000000000000000000000000000000000000000000000e+00, 431 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 432 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 433 | }, 434 | { 435 | 1.0000000000107662767589999930351041257381439208984375000000000000000000000000000000000000000000000000e+00, 436 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 437 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 438 | }, 439 | { 440 | 1.0000000000229689600672600136022083461284637451171875000000000000000000000000000000000000000000000000e+00, 441 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 442 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 443 | }, 444 | { 445 | 1.0000000000045505821333335916278883814811706542968750000000000000000000000000000000000000000000000000e+00, 446 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 447 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 448 | }, 449 | { 450 | 1.0000000000087156948325173289049416780471801757812500000000000000000000000000000000000000000000000000e+00, 451 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 452 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 453 | }, 454 | { 455 | 1.0000000000103563824183083852403797209262847900390625000000000000000000000000000000000000000000000000e+00, 456 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 457 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 458 | }, 459 | { 460 | 1.0000000000178630443770089186728000640869140625000000000000000000000000000000000000000000000000000000e+00, 461 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 462 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 463 | }, 464 | { 465 | 9.9999999999065469769021774482098408043384552001953125000000000000000000000000000000000000000000000000e-01, 466 | 6.0248331833248325306584547433885745704174041748046875000000000000000000000000000000000000000000000000e-01, 467 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 468 | }, 469 | { 470 | 9.9999999997523858485948267116327770054340362548828125000000000000000000000000000000000000000000000000e-01, 471 | 6.4383733044107160914393261919030919671058654785156250000000000000000000000000000000000000000000000000e-01, 472 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 473 | }, 474 | { 475 | 9.9999999999343847090216286233044229447841644287109375000000000000000000000000000000000000000000000000e-01, 476 | 5.1670237172253896673623785318341106176376342773437500000000000000000000000000000000000000000000000000e-01, 477 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 478 | }, 479 | { 480 | 9.9999999999777167136727484830771572887897491455078125000000000000000000000000000000000000000000000000e-01, 481 | 5.0346822522879852712662795966025441884994506835937500000000000000000000000000000000000000000000000000e-01, 482 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 483 | }, 484 | { 485 | 9.9999999999927347005268529755994677543640136718750000000000000000000000000000000000000000000000000000e-01, 486 | 5.0039705190578187554706346418242901563644409179687500000000000000000000000000000000000000000000000000e-01, 487 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 488 | }, 489 | { 490 | 9.9999999999838129483009652176406234502792358398437500000000000000000000000000000000000000000000000000e-01, 491 | 5.0059831425893197565102354928967542946338653564453125000000000000000000000000000000000000000000000000e-01, 492 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 493 | }, 494 | { 495 | 9.9999999999762312352658000236260704696178436279296875000000000000000000000000000000000000000000000000e-01, 496 | 5.0038505595259719083145455442718230187892913818359375000000000000000000000000000000000000000000000000e-01, 497 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 498 | }, 499 | { 500 | 9.9999999999845989862023998284712433815002441406250000000000000000000000000000000000000000000000000000e-01, 501 | 5.0012219578398176000888497583218850195407867431640625000000000000000000000000000000000000000000000000e-01, 502 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 503 | }, 504 | { 505 | 9.9999999999923894211661945519153960049152374267578125000000000000000000000000000000000000000000000000e-01, 506 | 5.0003212822078324517605096843908540904521942138671875000000000000000000000000000000000000000000000000e-01, 507 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 508 | }, 509 | { 510 | 9.9999999999957689400531535284244455397129058837890625000000000000000000000000000000000000000000000000e-01, 511 | 5.0000821687690510941592947347089648246765136718750000000000000000000000000000000000000000000000000000e-01, 512 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 513 | }, 514 | { 515 | 9.9999999999973532283092936268076300621032714843750000000000000000000000000000000000000000000000000000e-01, 516 | 5.0000291083860992635834463726496323943138122558593750000000000000000000000000000000000000000000000000e-01, 517 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 518 | }, 519 | { 520 | 9.9999999999927458027570992271648719906806945800781250000000000000000000000000000000000000000000000000e-01, 521 | 5.0000377520907202111288825108204036951065063476562500000000000000000000000000000000000000000000000000e-01, 522 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 523 | }, 524 | { 525 | 9.9999999999991828758538758847862482070922851562500000000000000000000000000000000000000000000000000000e-01, 526 | 5.0000025419216354016782588587375357747077941894531250000000000000000000000000000000000000000000000000e-01, 527 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 528 | }, 529 | { 530 | 9.9999999999990218935153052370878867805004119873046875000000000000000000000000000000000000000000000000e-01, 531 | 5.0000016712518369210727087192935869097709655761718750000000000000000000000000000000000000000000000000e-01, 532 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 533 | }, 534 | { 535 | 9.9999999999977329245837154303444549441337585449218750000000000000000000000000000000000000000000000000e-01, 536 | 5.0000022785053044316327941487543284893035888671875000000000000000000000000000000000000000000000000000e-01, 537 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 538 | }, 539 | { 540 | 9.9999999999965560881776127644116058945655822753906250000000000000000000000000000000000000000000000000e-01, 541 | 5.0000024516451568867836385834380052983760833740234375000000000000000000000000000000000000000000000000e-01, 542 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 543 | }, 544 | { 545 | 1.0000000000001332267629550187848508358001708984375000000000000000000000000000000000000000000000000000e+00, 546 | 4.9999995468853208890891437476966530084609985351562500000000000000000000000000000000000000000000000000e-01, 547 | 4.5353722956445345626530496474515530280768871307373046875000000000000000000000000000000000000000000000e-02 548 | }, 549 | { 550 | 1.0000000000002040589919261037721298635005950927734375000000000000000000000000000000000000000000000000e+00, 551 | 4.9999996666617685381339697414659895002841949462890625000000000000000000000000000000000000000000000000e-01, 552 | 4.2997605186598515658591423971301992423832416534423828125000000000000000000000000000000000000000000000e-02 553 | }, 554 | { 555 | 1.0000000000001887379141862766118720173835754394531250000000000000000000000000000000000000000000000000e+00, 556 | 4.9999998458773697862511653511319309473037719726562500000000000000000000000000000000000000000000000000e-01, 557 | 4.1974100969091501789343112704955274239182472229003906250000000000000000000000000000000000000000000000e-02 558 | }, 559 | { 560 | 1.0000000000001749711486809246707707643508911132812500000000000000000000000000000000000000000000000000e+00, 561 | 4.9999999232932879067448084242641925811767578125000000000000000000000000000000000000000000000000000000e-01, 562 | 4.1749258273409757535876707379429717548191547393798828125000000000000000000000000000000000000000000000e-02 563 | }, 564 | { 565 | 1.0000000000001092459456231154035776853561401367187500000000000000000000000000000000000000000000000000e+00, 566 | 4.9999999731279898274038941963226534426212310791015625000000000000000000000000000000000000000000000000e-01, 567 | 4.1682427257835892586701476147936773486435413360595703125000000000000000000000000000000000000000000000e-02 568 | }, 569 | { 570 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 571 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 572 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 573 | }, 574 | { 575 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 576 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 577 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 578 | }, 579 | { 580 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 581 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 582 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 583 | }, 584 | { 585 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 586 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 587 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 588 | }, 589 | { 590 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 591 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 592 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 593 | }, 594 | { 595 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 596 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 597 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 598 | }, 599 | { 600 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 601 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 602 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 603 | }, 604 | { 605 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 606 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 607 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 608 | }, 609 | { 610 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 611 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 612 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 613 | }, 614 | { 615 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 616 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 617 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 618 | }, 619 | { 620 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 621 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 622 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 623 | }, 624 | { 625 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 626 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 627 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 628 | }, 629 | { 630 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 631 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 632 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 633 | }, 634 | { 635 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 636 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 637 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 638 | }, 639 | { 640 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 641 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00, 642 | 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+00 643 | } 644 | }; 645 | 646 | 647 | --------------------------------------------------------------------------------