#[allow(unused_imports)]
use super::{BinaryStorage, ComputeStorage};
#[cfg(table_format = "q16_16")]
use crate::fixed_point::frac_config;
#[allow(unused_imports)]
use crate::fixed_point::i256::I256;
#[allow(unused_imports)]
use crate::fixed_point::i512::I512;
#[allow(unused_imports)]
use crate::fixed_point::I1024;
#[cfg(table_format = "q256_256")]
use crate::fixed_point::I2048;
use crate::fixed_point::domains::symbolic::rational::rational_number::OverflowDetected;
#[allow(unused_imports)]
#[cfg(any(table_format = "q64_64", table_format = "q128_128", table_format = "q256_256", table_format = "q32_32", table_format = "q16_16"))]
use crate::fixed_point::domains::binary_fixed::transcendental::{
sqrt_binary_i256, sqrt_binary_i512,
};
#[allow(unused_imports)]
#[cfg(table_format = "q256_256")]
use crate::fixed_point::domains::binary_fixed::transcendental::ln_binary_i1024;
#[cfg(table_format = "q256_256")]
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::{
sin_compute_tier_i1024, cos_compute_tier_i1024, sincos_compute_tier_i1024, pi_half_i1024,
};
#[cfg(table_format = "q128_128")]
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::{
sin_compute_tier_i512, cos_compute_tier_i512, sincos_compute_tier_i512,
};
#[cfg(table_format = "q64_64")]
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::{
sin_compute_tier_i256, cos_compute_tier_i256, sincos_compute_tier_i256,
};
#[cfg(table_format = "q16_16")]
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::{
sin_compute_tier_i64, cos_compute_tier_i64, sincos_compute_tier_i64,
};
#[cfg(table_format = "q256_256")]
use crate::fixed_point::domains::binary_fixed::transcendental::atan_tier_n_plus_1::{
atan_compute_tier_i1024, atan2_compute_tier_i1024,
};
#[cfg(table_format = "q128_128")]
use crate::fixed_point::domains::binary_fixed::transcendental::atan_tier_n_plus_1::{
atan_compute_tier_i512, atan2_compute_tier_i512,
};
#[cfg(table_format = "q64_64")]
use crate::fixed_point::domains::binary_fixed::transcendental::atan_tier_n_plus_1::{
atan_compute_tier_i256, atan2_compute_tier_i256,
};
#[cfg(table_format = "q16_16")]
use crate::fixed_point::domains::binary_fixed::transcendental::atan_tier_n_plus_1::{
atan_compute_tier_i64, atan2_compute_tier_i64,
};
#[cfg(table_format = "q256_256")]
use crate::fixed_point::domains::binary_fixed::transcendental::sqrt_tier_n_plus_1::sqrt_binary_i1024;
#[cfg(table_format = "q16_16")]
use crate::fixed_point::domains::binary_fixed::transcendental::sqrt_tier_n_plus_1::sqrt_binary_i64;
#[cfg(table_format = "q32_32")]
use crate::fixed_point::domains::binary_fixed::transcendental::{
sin_binary_i128, cos_binary_i128, sqrt_binary_i128,
atan_binary_i128, atan2_binary_i128,
};
#[cfg(table_format = "q32_32")]
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::pi_half_i128;
pub(crate) fn upscale_to_compute(val: BinaryStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{
I1024::from_i512(val) << 256
}
#[cfg(table_format = "q128_128")]
{
I512::from_i256(val) << 128
}
#[cfg(table_format = "q64_64")]
{
I256::from_i128(val) << 64
}
#[cfg(table_format = "q32_32")]
{
(val as i128) << 32
}
#[cfg(table_format = "q16_16")]
{
(val as i64) << frac_config::FRAC_BITS
}
}
#[inline]
pub(crate) fn downscale_to_storage(val: ComputeStorage) -> Result<BinaryStorage, OverflowDetected> {
#[cfg(table_format = "q256_256")]
{
let round_bit = (val & (I1024::from_i128(1) << 255)) != I1024::zero();
let shifted = val >> 256;
if !shifted.fits_in_i512() {
return Err(OverflowDetected::TierOverflow);
}
let mut result = shifted.as_i512();
if round_bit {
result = result + I512::from_i128(1);
}
Ok(result)
}
#[cfg(table_format = "q128_128")]
{
let round_bit = (val & (I512::from_i128(1) << 127)) != I512::zero();
let shifted = val >> 128;
if !shifted.fits_in_i256() {
return Err(OverflowDetected::TierOverflow);
}
let mut result = shifted.as_i256();
if round_bit {
result = result + I256::from_i128(1);
}
Ok(result)
}
#[cfg(table_format = "q64_64")]
{
let round_bit = (val & (I256::from_i128(1) << 63)) != I256::zero();
let shifted = val >> 64;
if !shifted.fits_in_i128() {
return Err(OverflowDetected::TierOverflow);
}
let mut result = shifted.as_i128();
if round_bit {
result += 1;
}
Ok(result)
}
#[cfg(table_format = "q32_32")]
{
let round_bit = (val & (1i128 << 31)) != 0;
let shifted = val >> 32;
if shifted > i64::MAX as i128 || shifted < i64::MIN as i128 {
return Err(OverflowDetected::TierOverflow);
}
let mut result = shifted as i64;
if round_bit {
result += 1;
}
Ok(result)
}
#[cfg(table_format = "q16_16")]
{
let round_bit = (val & (1i64 << frac_config::FRAC_ROUND_BIT)) != 0;
let shifted = val >> frac_config::FRAC_BITS;
if shifted > i32::MAX as i64 || shifted < i32::MIN as i64 {
return Err(OverflowDetected::TierOverflow);
}
let mut result = shifted as i32;
if round_bit {
result += 1;
}
Ok(result)
}
}
#[inline]
pub(super) fn decimal_to_compute_storage(decimals: u8, scaled: BinaryStorage) -> Result<ComputeStorage, OverflowDetected> {
if decimals == 0 {
#[cfg(table_format = "q256_256")]
{ return Ok(I1024::from_i512(scaled) << 512); }
#[cfg(table_format = "q128_128")]
{ return Ok(I512::from_i256(scaled) << 256); }
#[cfg(table_format = "q64_64")]
{ return Ok(I256::from_i128(scaled) << 128); }
#[cfg(table_format = "q32_32")]
{ return Ok((scaled as i128) << 64); }
#[cfg(table_format = "q16_16")]
{ return Ok((scaled as i64) << frac_config::COMPUTE_FRAC_BITS); }
}
let den = pow10_compute(decimals)?;
#[cfg(table_format = "q256_256")]
{
let num = I1024::from_i512(scaled) << 512;
Ok(num / den)
}
#[cfg(table_format = "q128_128")]
{
let num = I512::from_i256(scaled) << 256;
Ok(num / den)
}
#[cfg(table_format = "q64_64")]
{
let num = I256::from_i128(scaled) << 128;
Ok(num / den)
}
#[cfg(table_format = "q32_32")]
{
let num = (scaled as i128) << 64;
Ok(num / den)
}
#[cfg(table_format = "q16_16")]
{
let num = (scaled as i64) << frac_config::COMPUTE_FRAC_BITS;
Ok(num / den)
}
}
#[inline]
pub(super) fn pow10_compute(exp: u8) -> Result<ComputeStorage, OverflowDetected> {
#[cfg(table_format = "q64_64")]
{
const TABLE: [I256; 39] = pow10_table_i256();
if (exp as usize) < TABLE.len() {
Ok(TABLE[exp as usize])
} else if exp <= 76 {
Ok(pow10_compute_fallback_i256(exp))
} else {
Err(OverflowDetected::Overflow)
}
}
#[cfg(table_format = "q128_128")]
{
const TABLE: [I512; 77] = pow10_table_i512();
if (exp as usize) < TABLE.len() {
Ok(TABLE[exp as usize])
} else if exp <= 153 {
Ok(pow10_compute_fallback_i512(exp))
} else {
Err(OverflowDetected::Overflow)
}
}
#[cfg(table_format = "q256_256")]
{
const TABLE: [I1024; 155] = pow10_table_i1024();
if (exp as usize) < TABLE.len() {
Ok(TABLE[exp as usize])
} else {
Ok(pow10_compute_fallback_i1024(exp))
}
}
#[cfg(table_format = "q32_32")]
{
const TABLE: [i128; 39] = pow10_table_i128();
if (exp as usize) < TABLE.len() {
Ok(TABLE[exp as usize])
} else {
Err(OverflowDetected::Overflow)
}
}
#[cfg(table_format = "q16_16")]
{
const TABLE: [i64; 19] = pow10_table_i64();
if (exp as usize) < TABLE.len() {
Ok(TABLE[exp as usize])
} else {
Err(OverflowDetected::Overflow)
}
}
}
const fn mul10_words<const N: usize>(words: [u64; N]) -> [u64; N] {
let mut result = [0u64; N];
let mut carry: u64 = 0;
let mut i = 0;
while i < N {
let prod = words[i] as u128 * 10 + carry as u128;
result[i] = prod as u64;
carry = (prod >> 64) as u64;
i += 1;
}
result
}
#[allow(dead_code)]
pub(super) const fn pow10_table_i256() -> [I256; 39] {
let mut table = [I256::from_words([0; 4]); 39];
let mut words = [0u64; 4];
words[0] = 1; table[0] = I256::from_words(words);
let mut i = 1;
while i < 39 {
words = mul10_words(words);
table[i] = I256::from_words(words);
i += 1;
}
table
}
#[cfg(any(table_format = "q128_128", table_format = "q256_256"))]
pub(super) const fn pow10_table_i512() -> [I512; 77] {
let mut table = [I512::from_words([0; 8]); 77];
let mut words = [0u64; 8];
words[0] = 1;
table[0] = I512::from_words(words);
let mut i = 1;
while i < 77 {
words = mul10_words(words);
table[i] = I512::from_words(words);
i += 1;
}
table
}
#[cfg(table_format = "q256_256")]
pub(super) const fn pow10_table_i1024() -> [I1024; 155] {
let mut table = [I1024::from_words([0; 16]); 155];
let mut words = [0u64; 16];
words[0] = 1;
table[0] = I1024::from_words(words);
let mut i = 1;
while i < 155 {
words = mul10_words(words);
table[i] = I1024::from_words(words);
i += 1;
}
table
}
#[cfg(table_format = "q32_32")]
pub(super) const fn pow10_table_i128() -> [i128; 39] {
let mut table = [0i128; 39];
table[0] = 1;
let mut i = 1;
while i < 39 {
table[i] = table[i - 1] * 10;
i += 1;
}
table
}
#[cfg(table_format = "q16_16")]
pub(super) const fn pow10_table_i64() -> [i64; 19] {
let mut table = [0i64; 19];
table[0] = 1;
let mut i = 1;
while i < 19 {
table[i] = table[i - 1] * 10;
i += 1;
}
table
}
#[cold]
#[allow(dead_code)]
fn pow10_compute_fallback_i256(exp: u8) -> I256 {
let mut result = I256::from_i128(1);
let ten = I256::from_i128(10);
for _ in 0..exp { result = result * ten; }
result
}
#[cold]
#[cfg(table_format = "q128_128")]
fn pow10_compute_fallback_i512(exp: u8) -> I512 {
let mut result = I512::from_i128(1);
let ten = I512::from_i128(10);
for _ in 0..exp { result = result * ten; }
result
}
#[cold]
#[cfg(table_format = "q256_256")]
fn pow10_compute_fallback_i1024(exp: u8) -> I1024 {
let mut result = I1024::from_i128(1);
let ten = I1024::from_i128(10);
for _ in 0..exp { result = result * ten; }
result
}
#[inline]
pub(super) fn symbolic_to_compute_storage(num: i128, den: i128) -> Result<ComputeStorage, OverflowDetected> {
#[cfg(table_format = "q256_256")]
{
let n = I1024::from_i512(I512::from_i256(I256::from_i128(num))) << 512;
let d = I1024::from_i512(I512::from_i256(I256::from_i128(den)));
Ok(n / d)
}
#[cfg(table_format = "q128_128")]
{
let n = I512::from_i256(I256::from_i128(num)) << 256;
let d = I512::from_i256(I256::from_i128(den));
Ok(n / d)
}
#[cfg(table_format = "q64_64")]
{
let n = I256::from_i128(num) << 128;
let d = I256::from_i128(den);
Ok(n / d)
}
#[cfg(table_format = "q32_32")]
{
let n = I256::from_i128(num) << 64;
let d = I256::from_i128(den);
Ok((n / d).as_i128())
}
#[cfg(table_format = "q16_16")]
{
let n = (num as i128) << frac_config::COMPUTE_FRAC_BITS;
let d = den as i128;
Ok((n / d) as i64)
}
}
pub(super) fn symbolic_wide_to_compute_storage(
rational: &crate::fixed_point::domains::symbolic::rational::RationalNumber,
) -> Result<ComputeStorage, OverflowDetected> {
let parts = rational.extract_native();
#[cfg(table_format = "q128_128")]
{
if let Some((num_i256, den_i256)) = parts.try_as_i256_pair() {
let n = I512::from_i256(num_i256) << 256;
let d = I512::from_i256(den_i256);
return Ok(n / d);
}
if let Some((num_i512, den_i512)) = parts.try_as_i512_pair() {
let n = I1024::from_i512(num_i512) << 256;
let d = I1024::from_i512(den_i512);
return Ok((n / d).as_i512());
}
}
#[cfg(table_format = "q256_256")]
{
if let Some((num_i512, den_i512)) = parts.try_as_i512_pair() {
let n = I1024::from_i512(num_i512) << 512;
let d = I1024::from_i512(den_i512);
return Ok(n / d);
}
}
#[cfg(table_format = "q64_64")]
{
if let Some((num_i256, den_i256)) = parts.try_as_i256_pair() {
let n = I256::from_i128(num_i256.as_i128()) << 128;
let d = I256::from_i128(den_i256.as_i128());
return Ok(n / d);
}
if let Some((num_i512, den_i512)) = parts.try_as_i512_pair() {
let n = I1024::from_i512(num_i512) << 128;
let d = I1024::from_i512(den_i512);
return Ok((n / d).as_i256());
}
}
#[cfg(table_format = "q32_32")]
{
if let Some((num_i256, den_i256)) = parts.try_as_i256_pair() {
let n = I256::from_i128(num_i256.as_i128()) << 64;
let d = I256::from_i128(den_i256.as_i128());
return Ok((n / d).as_i128());
}
if let Some((num_i512, den_i512)) = parts.try_as_i512_pair() {
let n = I1024::from_i512(num_i512) << 64;
let d = I1024::from_i512(den_i512);
return Ok((n / d).as_i512().as_i256().as_i128());
}
}
#[cfg(table_format = "q16_16")]
{
if let Some((num_i256, den_i256)) = parts.try_as_i256_pair() {
let n = I256::from_i128(num_i256.as_i128()) << (frac_config::COMPUTE_FRAC_BITS as usize);
let d = I256::from_i128(den_i256.as_i128());
return Ok((n / d).as_i128() as i64);
}
if let Some((num_i512, den_i512)) = parts.try_as_i512_pair() {
let n = I1024::from_i512(num_i512) << (frac_config::COMPUTE_FRAC_BITS as usize);
let d = I1024::from_i512(den_i512);
return Ok((n / d).as_i512().as_i256().as_i128() as i64);
}
}
Err(OverflowDetected::TierOverflow)
}
#[inline]
pub(crate) fn compute_add(a: ComputeStorage, b: ComputeStorage) -> ComputeStorage {
a + b
}
#[inline]
pub(crate) fn compute_subtract(a: ComputeStorage, b: ComputeStorage) -> ComputeStorage {
a - b
}
#[inline]
pub(crate) fn compute_negate(a: ComputeStorage) -> ComputeStorage {
-a
}
#[inline]
pub(crate) fn compute_multiply(a: ComputeStorage, b: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::multiply_i1024_q512_512;
multiply_i1024_q512_512(a, b)
}
#[cfg(table_format = "q128_128")]
{
let a_wide = I1024::from_i512(a);
let b_wide = I1024::from_i512(b);
let product = a_wide * b_wide;
let round_bit = (product & (I1024::from_i128(1) << 255)) != I1024::zero();
let mut result = (product >> 256).as_i512();
if round_bit {
result = result + I512::from_i128(1);
}
result
}
#[cfg(table_format = "q64_64")]
{
let a_wide = I512::from_i256(a);
let b_wide = I512::from_i256(b);
let product = a_wide * b_wide;
let round_bit = (product & (I512::from_i128(1) << 127)) != I512::zero();
let mut result = (product >> 128).as_i256();
if round_bit {
result = result + I256::from_i128(1);
}
result
}
#[cfg(table_format = "q32_32")]
{
let a_wide = I256::from_i128(a);
let b_wide = I256::from_i128(b);
let product = a_wide * b_wide;
let round_bit = (product & (I256::from_i128(1) << 63)) != I256::zero();
let mut result = (product >> 64).as_i128();
if round_bit {
result += 1;
}
result
}
#[cfg(table_format = "q16_16")]
{
let product = (a as i128) * (b as i128);
let round_bit = (product & (1i128 << frac_config::COMPUTE_ROUND_BIT)) != 0;
let mut result = (product >> frac_config::COMPUTE_FRAC_BITS) as i64;
if round_bit {
result += 1;
}
result
}
}
#[inline]
pub(crate) fn compute_divide(a: ComputeStorage, b: ComputeStorage) -> Result<ComputeStorage, OverflowDetected> {
#[cfg(table_format = "q256_256")]
{
if b == I1024::zero() { return Err(OverflowDetected::DivisionByZero); }
let a_wide = I2048::from_i1024(a) << 512;
let b_wide = I2048::from_i1024(b);
use crate::fixed_point::domains::binary_fixed::i2048::i2048_div;
Ok(i2048_div(a_wide, b_wide).as_i1024())
}
#[cfg(table_format = "q128_128")]
{
if b == I512::zero() { return Err(OverflowDetected::DivisionByZero); }
let a_wide = I1024::from_i512(a) << 256;
let b_wide = I1024::from_i512(b);
Ok((a_wide / b_wide).as_i512())
}
#[cfg(table_format = "q64_64")]
{
if b == I256::zero() { return Err(OverflowDetected::DivisionByZero); }
let a_wide = I512::from_i256(a) << 128;
let b_wide = I512::from_i256(b);
Ok((a_wide / b_wide).as_i256())
}
#[cfg(table_format = "q32_32")]
{
if b == 0i128 { return Err(OverflowDetected::DivisionByZero); }
let a_wide = I256::from_i128(a) << 64;
let b_wide = I256::from_i128(b);
Ok((a_wide / b_wide).as_i128())
}
#[cfg(table_format = "q16_16")]
{
if b == 0i64 { return Err(OverflowDetected::DivisionByZero); }
let a_wide = (a as i128) << frac_config::COMPUTE_FRAC_BITS;
let b_wide = b as i128;
Ok((a_wide / b_wide) as i64)
}
}
#[inline]
pub(crate) fn compute_halve(a: ComputeStorage) -> ComputeStorage {
a >> 1
}
#[allow(dead_code)]
#[inline]
pub(crate) fn make_compute_int(n: i64) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{ I1024::from_i128(n as i128) << 512 }
#[cfg(table_format = "q128_128")]
{ I512::from_i128(n as i128) << 256 }
#[cfg(table_format = "q64_64")]
{ I256::from_i128(n as i128) << 128 }
#[cfg(table_format = "q32_32")]
{ (n as i128) << 64 }
#[cfg(table_format = "q16_16")]
{ n << frac_config::COMPUTE_FRAC_BITS }
}
#[inline]
pub(crate) fn compute_is_zero(a: &ComputeStorage) -> bool {
#[cfg(table_format = "q256_256")]
{ *a == I1024::zero() }
#[cfg(table_format = "q128_128")]
{ *a == I512::zero() }
#[cfg(table_format = "q64_64")]
{ *a == I256::zero() }
#[cfg(table_format = "q32_32")]
{ *a == 0i128 }
#[cfg(table_format = "q16_16")]
{ *a == 0i64 }
}
#[inline]
pub(crate) fn compute_is_negative(a: &ComputeStorage) -> bool {
#[cfg(table_format = "q256_256")]
{ (a.words[15] & 0x8000_0000_0000_0000) != 0 }
#[cfg(table_format = "q128_128")]
{ *a < I512::zero() }
#[cfg(table_format = "q64_64")]
{ *a < I256::zero() }
#[cfg(table_format = "q32_32")]
{ *a < 0i128 }
#[cfg(table_format = "q16_16")]
{ *a < 0i64 }
}
#[inline]
pub(super) fn sin_at_compute_tier(x: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{ sin_compute_tier_i1024(x) }
#[cfg(table_format = "q128_128")]
{ sin_compute_tier_i512(x) }
#[cfg(table_format = "q64_64")]
{ sin_compute_tier_i256(x) }
#[cfg(table_format = "q32_32")]
{
sin_binary_i128(x)
}
#[cfg(table_format = "q16_16")]
{
sin_compute_tier_i64(x)
}
}
#[inline]
pub(super) fn cos_at_compute_tier(x: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{ cos_compute_tier_i1024(x) }
#[cfg(table_format = "q128_128")]
{ cos_compute_tier_i512(x) }
#[cfg(table_format = "q64_64")]
{ cos_compute_tier_i256(x) }
#[cfg(table_format = "q32_32")]
{
cos_binary_i128(x)
}
#[cfg(table_format = "q16_16")]
{
cos_compute_tier_i64(x)
}
}
#[inline]
pub(crate) fn sinhcosh_at_compute_tier(x: ComputeStorage) -> (ComputeStorage, ComputeStorage) {
let ep = exp_at_compute_tier(x);
let en = exp_at_compute_tier(compute_negate(x));
let sinh_c = compute_halve(compute_subtract(ep, en));
let cosh_c = compute_halve(compute_add(ep, en));
(sinh_c, cosh_c)
}
#[inline]
pub(crate) fn sincos_at_compute_tier(x: ComputeStorage) -> (ComputeStorage, ComputeStorage) {
#[cfg(table_format = "q256_256")]
{ sincos_compute_tier_i1024(x) }
#[cfg(table_format = "q128_128")]
{ sincos_compute_tier_i512(x) }
#[cfg(table_format = "q64_64")]
{ sincos_compute_tier_i256(x) }
#[cfg(table_format = "q32_32")]
{
(sin_binary_i128(x), cos_binary_i128(x))
}
#[cfg(table_format = "q16_16")]
{
sincos_compute_tier_i64(x)
}
}
#[inline]
pub(super) fn atan_at_compute_tier(x: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{ atan_compute_tier_i1024(x) }
#[cfg(table_format = "q128_128")]
{ atan_compute_tier_i512(x) }
#[cfg(table_format = "q64_64")]
{ atan_compute_tier_i256(x) }
#[cfg(table_format = "q32_32")]
{
atan_binary_i128(x)
}
#[cfg(table_format = "q16_16")]
{
atan_compute_tier_i64(x)
}
}
#[inline]
pub(super) fn atan2_at_compute_tier(y: ComputeStorage, x: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{ atan2_compute_tier_i1024(y, x) }
#[cfg(table_format = "q128_128")]
{ atan2_compute_tier_i512(y, x) }
#[cfg(table_format = "q64_64")]
{ atan2_compute_tier_i256(y, x) }
#[cfg(table_format = "q32_32")]
{
atan2_binary_i128(y, x)
}
#[cfg(table_format = "q16_16")]
{
atan2_compute_tier_i64(y, x)
}
}
#[inline]
pub(crate) fn exp_at_compute_tier(x: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::exp_binary_i1024;
exp_binary_i1024(x)
}
#[cfg(table_format = "q128_128")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::exp_binary_i512;
exp_binary_i512(x)
}
#[cfg(table_format = "q64_64")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::exp_binary_i256;
exp_binary_i256(x)
}
#[cfg(table_format = "q32_32")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::exp_binary_i128;
exp_binary_i128(x)
}
#[cfg(table_format = "q16_16")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::exp_binary_i64;
exp_binary_i64(x)
}
}
#[inline]
pub(crate) fn sqrt_at_compute_tier(x: ComputeStorage) -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{ sqrt_binary_i1024(x) }
#[cfg(table_format = "q128_128")]
{
sqrt_binary_i512(x)
}
#[cfg(table_format = "q64_64")]
{
sqrt_binary_i256(x)
}
#[cfg(table_format = "q32_32")]
{
sqrt_binary_i128(x)
}
#[cfg(table_format = "q16_16")]
{
sqrt_binary_i64(x)
}
}
#[inline]
pub(super) fn pi_half_at_compute_tier() -> ComputeStorage {
#[cfg(table_format = "q256_256")]
{
pi_half_i1024()
}
#[cfg(table_format = "q128_128")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::PI_HALF_Q256;
I512::from_words(PI_HALF_Q256)
}
#[cfg(table_format = "q64_64")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::PI_HALF_Q128;
I256::from_words(PI_HALF_Q128)
}
#[cfg(table_format = "q32_32")]
{
pi_half_i128()
}
#[cfg(table_format = "q16_16")]
{
use crate::fixed_point::domains::binary_fixed::transcendental::sin_cos_tier_n_plus_1::PI_HALF_Q64;
(PI_HALF_Q64 >> frac_config::NATIVE_UPSHIFT) as i64
}
}