text stringlengths 1 2.05k |
|---|
fn div_eq(ref self: i32, other: i32) {
self = Div::div(self, other);
}
}
impl I32IntoU32 of Into<i32, u32> {
fn into(self: i32) -> u32 {
let number_sign: bool = self < 0;
let mut self_positive: i32 = self;
if number_sign {
self_positive = self_positive * -1_i32
... |
])
}
fn acosh(self: i64) -> i64 {
panic(array!['not supported!'])
}
fn asinh(self: i64) -> i64 {
panic(array!['not supported!'])
}
fn atanh(self: i64) -> i64 {
panic(array!['not supported!'])
}
fn cosh(self: i64) -> i64 {
panic(array!['not supported!']... |
== 0 {
false
} else {
true
}
}
fn where(self: i64, x: i64, y: i64) -> i64 {
if self == 0 {
y
} else {
x
}
}
fn NaN() -> i64 {
panic(array!['not supported!'])
}
fn is_nan(self: i64) -> bool {
... |
fn div_eq(ref self: i64, other: i64) {
self = Div::div(self, other);
}
}
impl I128Number of NumberTrait<i128, i128> {
fn new(mag: i128, sign: bool) -> i128 {
if sign {
return -mag;
}
mag
}
fn new_unscaled(mag: i128, sign: bool) -> i128 {
mag
}
... |
self: i128) -> i128 {
panic(array!['not supported!'])
}
fn tanh(self: i128) -> i128 {
panic(array!['not supported!'])
}
fn zero() -> i128 {
0
}
fn is_zero(self: i128) -> bool {
self == 0
}
fn half() -> i128 {
panic(array!['not supported!'])
... |
supported!'])
}
fn is_nan(self: i128) -> bool {
panic(array!['not supported!'])
}
fn INF() -> i128 {
170141183460469231731687303715884105727
}
fn is_inf(self: i128) -> bool {
self == 170141183460469231731687303715884105727
|| self == -1701411834604692317316... |
fn div_eq(ref self: i128, other: i128) {
self = Div::div(self, other);
}
}
impl u32Number of NumberTrait<u32, u32> {
fn new(mag: u32, sign: bool) -> u32 {
mag
}
fn new_unscaled(mag: u32, sign: bool) -> u32 {
mag
}
fn from_felt(val: felt252) -> u32 {
panic(array... |
panic(array!['not supported!'])
}
fn zero() -> u32 {
0
}
fn is_zero(self: u32) -> bool {
self == 0
}
fn half() -> u32 {
panic(array!['not supported!'])
}
fn one() -> u32 {
1
}
fn neg_one() -> u32 {
panic(array!['not supported'])
}
... |
fn bitwise_and(lhs: u32, rhs: u32) -> u32 {
lhs & rhs
}
fn bitwise_xor(lhs: u32, rhs: u32) -> u32 {
lhs ^ rhs
}
fn bitwise_or(lhs: u32, rhs: u32) -> u32 {
lhs | rhs
}
fn add(lhs: u32, rhs: u32) -> u32 {
lhs + rhs
}
fn sub(lhs: u32, rhs: u32) -> u32 {
... |
4) -> complex64 {
Complex64Impl::cos(self)
}
fn sin(self: complex64) -> complex64 {
Complex64Impl::sin(self)
}
fn tan(self: complex64) -> complex64 {
Complex64Impl::tan(self)
}
fn acosh(self: complex64) -> complex64 {
Complex64Impl::acosh(self)
}
fn as... |
g(self: complex64) -> bool {
panic(array!['not supported!'])
}
fn xor(lhs: complex64, rhs: complex64) -> bool {
panic(array!['not supported!'])
}
fn or(lhs: complex64, rhs: complex64) -> bool {
panic(array!['not supported!'])
}
fn sign(self: complex64) -> complex64 {
... |
mod complex_trait;
mod complex64;
|
use core::debug::PrintTrait;
use orion::numbers::complex_number::complex_trait::ComplexTrait;
use orion::numbers::{FP64x64, FP64x64Impl, FP32x32, FP32x32Impl, FixedTrait}; |
struct complex64 {
real: FP64x64,
img: FP64x64,
}
const PI: u128 = 57952155664616982739;
const HALF_PI: u128 = 28976077832308491370;
const TWO: u128 = 36893488147419103232;
const E: u128 = 50143449208471493718;
const HALF: u128 = 9223372036854775808;
impl Complex64Impl of ComplexTrait<complex64, FP64x64> {
... |
();
complex64 { real, img }
}
fn log2(self: complex64) -> complex64 {
let ln_2 = FP64x64Impl::new(12786309186476892720, false);
let ln = self.ln();
complex64 { real: (ln.real / ln_2), img: (ln.img / ln_2) }
}
fn log10(self: complex64) -> complex64 {
let ln_10 ... |
x64Impl::new(TWO, false);
let a = self.real;
let b = self.img;
let den = FP64x64Impl::cosh(two * b) + FP64x64Impl::cos(two * a);
complex64 { real: FP64x64Impl::sin(two * a) / den, img: FP64x64Impl::sinh(two * b) / den }
}
fn acos(self: complex64) -> complex64 {
let... |
P64x64Impl::ZERO());
let two = Complex64Impl::new(FP64x64Impl::new(TWO, false), FP64x64Impl::ZERO());
let asinh = Complex64Impl::ln(self + Complex64Impl::sqrt(one + (self.pow(two))));
asinh
}
fn atanh(self: complex64) -> complex64 {
let two = Complex64Impl::new(FP64x64Impl... |
64) -> FP64x64 {
let two = FP64x64Impl::new(TWO, false);
if (y != FP64x64Impl::ZERO() || x > FP64x64Impl::ZERO()) {
return two * (y / (x + (x.pow(two) + y.pow(two)).sqrt())).atan();
} else if x < FP64x64Impl::ZERO() {
return FP64x64Impl::new(PI, false);
} else {
panic(array!['und... |
fn print(self: complex64) {
self.real.print();
'+'.print();
self.img.print();
'i'.print();
}
}
impl Complex64Add of Add<complex64> {
fn add(lhs: complex64, rhs: complex64) -> complex64 {
complex64_add(lhs, rhs)
}
}
impl Complex64AddEq of AddEq<complex64> { |
fn add_eq(ref self: complex64, other: complex64) {
self = Add::add(self, other);
}
}
impl Complex64Sub of Sub<complex64> {
fn sub(lhs: complex64, rhs: complex64) -> complex64 {
complex64_sub(lhs, rhs)
}
}
impl Complex64SubEq of SubEq<complex64> { |
fn sub_eq(ref self: complex64, other: complex64) {
self = Sub::sub(self, other);
}
}
impl Complex64Mul of Mul<complex64> {
fn mul(lhs: complex64, rhs: complex64) -> complex64 {
complex64_mul(lhs, rhs)
}
}
impl Complex64MulEq of MulEq<complex64> { |
fn mul_eq(ref self: complex64, other: complex64) {
self = Mul::mul(self, other);
}
}
impl Complex64Div of Div<complex64> {
fn div(lhs: complex64, rhs: complex64) -> complex64 {
complex64_div(lhs, rhs)
}
}
impl Complex64DivEq of DivEq<complex64> { |
fn div_eq(ref self: complex64, other: complex64) {
self = Div::div(self, other);
}
}
impl Complex64PartialEq of PartialEq<complex64> {
fn eq(lhs: @complex64, rhs: @complex64) -> bool {
complex64_eq(*lhs, *rhs)
}
fn ne(lhs: @complex64, rhs: @complex64) -> bool {
complex64_ne(*l... |
trait ComplexTrait<T, F> {
fn new(real: F, img: F) -> T;
... |
fn log2(self: T) -> T;
fn log10(self: T) -> T;
... |
acosh(self: T) -> T;
fn asinh(self: T) -> T;
... |
//! Fixed-Point implemented from https://github.com/influenceth/cubit and adjusted to Q8.23
mod core;
mod implementations;
mod utils;
|
trait FixedTrait<T, MAG> {
fn new(mag: MAG, sign: bool) -> T;
... |
log10(self: T) -> T;
fn pow(self: T, b: T) -> T;
... |
fn cos_fast(self: T) -> T;
fn sin(self: T) -> T;
... |
fn erf(self: T) -> T;
fn ZERO() -> T;
fn HALF() -> T;
fn ONE() -> T;
fn MAX() -> T;
fn NaN() -> T;
fn is_nan(self: T) -> bool;
fn INF() -> T;
fn POS_INF() -> T;
fn NEG_INF() -> T;
fn is_inf(self: T) -> bool;
fn is_pos_inf(self: T) -> bool;
fn is_neg_inf(self: T) -> bool;... |
mod fp8x23;
mod fp16x16;
mod fp64x64;
mod fp32x32;
mod fp16x16wide;
mod fp8x23wide;
|
mod core;
mod math;
mod helpers;
|
use core::debug::PrintTrait;
use orion::numbers::fixed_point::core::FixedTrait;
use orion::numbers::fixed_point::implementations::fp16x16::math::{
core as core_math, trig, hyp, erf
};
use orion::numbers::fixed_point::utils; |
struct FP16x16 {
mag: u32,
sign: bool
}
const TWO: u32 = 131072;
const ONE: u32 = 65536;
const HALF: u32 = 32768;
const MAX: u32 = 2147483648;
impl FP16x16Impl of FixedTrait<FP16x16, u32> {
fn ZERO() -> FP16x16 {
FP16x16 { mag: 0, sign: false }
}
fn HALF() -> FP16x16 {
FP16x1... |
}
fn exp(self: FP16x16) -> FP16x16 {
core_math::exp(self)
}
fn exp2(self: FP16x16) -> FP16x16 {
core_math::exp2(self)
}
fn ln(self: FP16x16) -> FP16x16 {
core_math::ln(self)
}
fn log2(self: FP16x16) -> FP16x16 {
core_math::log... |
fn print(self: FP16x16) {
self.sign.print();
self.mag.print();
}
}
impl FP16x16IntoFelt252 of Into<FP16x16, felt252> {
fn into(self: FP16x16) -> felt252 {
let mag_felt = self.mag.into();
if self.sign {
mag_felt * -1
} else {
mag_felt * 1
... |
dd of Add<FP16x16> {
fn add(lhs: FP16x16, rhs: FP16x16) -> FP16x16 {
core_math::add(lhs, rhs)
}
}
impl FP16x16AddEq of AddEq<FP16x16> { |
fn add_eq(ref self: FP16x16, other: FP16x16) {
self = Add::add(self, other);
}
}
impl FP16x16Sub of Sub<FP16x16> {
fn sub(lhs: FP16x16, rhs: FP16x16) -> FP16x16 {
core_math::sub(lhs, rhs)
}
}
impl FP16x16SubEq of SubEq<FP16x16> { |
fn sub_eq(ref self: FP16x16, other: FP16x16) {
self = Sub::sub(self, other);
}
}
impl FP16x16Mul of Mul<FP16x16> {
fn mul(lhs: FP16x16, rhs: FP16x16) -> FP16x16 {
core_math::mul(lhs, rhs)
}
}
impl FP16x16MulEq of MulEq<FP16x16> { |
fn mul_eq(ref self: FP16x16, other: FP16x16) {
self = Mul::mul(self, other);
}
}
impl FP16x16Div of Div<FP16x16> {
fn div(lhs: FP16x16, rhs: FP16x16) -> FP16x16 {
core_math::div(lhs, rhs)
}
}
impl FP16x16DivEq of DivEq<FP16x16> { |
fn div_eq(ref self: FP16x16, other: FP16x16) {
self = Div::div(self, other);
}
}
impl FP16x16PartialOrd of PartialOrd<FP16x16> {
fn ge(lhs: FP16x16, rhs: FP16x16) -> bool {
core_math::ge(lhs, rhs)
}
fn gt(lhs: FP16x16, rhs: FP16x16) -> bool {
core_math::gt(lhs, rhs)
... |
use core::debug::PrintTrait;
use orion::numbers::fixed_point::implementations::fp16x16::core::{
HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Sub, FP16x16Div, FixedTrait, FP16x16Print
};
const DEFAULT_PRECISION: u32 = 7; // 1e-4
// To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`.
// To use `custom_pr... |
mod core;
mod comp;
mod lut;
mod trig;
mod hyp;
mod erf;
|
use orion::numbers::fixed_point::implementations::fp16x16::core::{
FP16x16, FixedTrait, FP16x16Impl, FP16x16PartialOrd, FP16x16PartialEq
};
fn max(a: FP16x16, b: FP16x16) -> FP16x16 {
if a >= b {
a
} else {
b
}
}
fn min(a: FP16x16, b: FP16x16) -> FP16x16 {
if a <= b {
a
... |
fn test_max() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(0, false);
let c = FixedTrait::new_unscaled(1, true);
assert(max(a, a) == a, 'max(a, a)');
assert(max(a, b) == a, 'max(a, b)');
assert(max(a, c) == a, 'max(a, c)');
asse... |
fn test_min() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(0, false);
let c = FixedTrait::new_unscaled(1, true);
assert(min(a, a) == a, 'min(a, a)');
assert(min(a, b) == b, 'min(a, b)');
assert(min(a, c) == c, 'min(a, c)');
asse... |
fn test_bitwise_and() {
let a = FixedTrait::new(225280, false);
let b = FixedTrait::new(4160843776, true);
let c = FixedTrait::new(94208, false);
assert(bitwise_and(a, b) == c, 'bitwise_and(a,b)')
} |
fn test_bitwise_xor() {
let a = FixedTrait::new(225280, false);
let b = FixedTrait::new(4160843776, true);
let c = FixedTrait::new(4160880640, true);
assert(bitwise_xor(a, b) == c, 'bitwise_xor(a,b)')
} |
fn test_bitwise_or() {
let a = FixedTrait::new(225280, false);
let b = FixedTrait::new(4160843776, true);
let c = FixedTrait::new(4160974848, true);
assert(bitwise_or(a, b) == c, 'bitwise_or(a,b)')
}
} |
use core::integer;
use orion::numbers::fixed_point::implementations::fp16x16::core::{
HALF, ONE, MAX, FP16x16, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul,
FP16x16MulEq, FP16x16TryIntoU128, FP16x16PartialEq, FP16x16PartialOrd, FP16x16SubEq, FP16x16Neg,
FP16x16Div, FP16x16IntoFelt252, Fixe... |
r6 + FixedTrait::new(87, false)) * frac;
let r4 = (r5 + FixedTrait::new(630, false)) * frac;
let r3 = (r4 + FixedTrait::new(3638, false)) * frac;
let r2 = (r3 + FixedTrait::new(15743, false)) * frac;
let r1 = (r2 + FixedTrait::new(45426, false)) * frac;
res_u = res_u * (r1 + Fixe... |
(172935, false)) * norm;
let r4 = (r5 + FixedTrait::new(394096, true)) * norm;
let r3 = (r4 + FixedTrait::new(608566, false)) * norm;
let r2 = (r3 + FixedTrait::new(655828, true)) * norm;
let r1 = (r2 + FixedTrait::new(534433, false)) * norm;
r1 + FixedTrait::new(224487, true) +... |
+ 1, a.sign)
} else {
FixedTrait::new_unscaled(div, a.sign)
}
}
fn sqrt(a: FP16x16) -> FP16x16 {
assert(a.sign == false, 'must be positive');
let root = integer::u64_sqrt(a.mag.into() * ONE.into());
FixedTrait::new(root.into(), false)
}
fn sub(a: FP16x16, b: FP16x16) -> FP16x16 {
a... |
fn test_into() {
let a = FixedTrait::<FP16x16>::new_unscaled(5, false);
assert(a.mag == 5 * ONE, 'invalid result');
} |
fn test_try_into_u128() {
let a = FixedTrait::<FP16x16>::new_unscaled(5, false);
assert(a.try_into().unwrap() == 5_u128, 'invalid result');
let b = FixedTrait::<FP16x16>::new(5 * ONE, false);
assert(b.try_into().unwrap() == 5_u128, 'invalid result');
... |
fn test_negative_try_into_u128() {
let a = FixedTrait::<FP16x16>::new_unscaled(1, true);
let _a: u128 = a.try_into().unwrap();
} |
fn test_acos() {
let a = FixedTrait::<FP16x16>::ONE();
assert(a.acos().into() == 0, 'invalid one');
} |
fn test_asin() {
let a = FixedTrait::ONE();
assert_precise(a.asin(), HALF_PI.into(), 'invalid one', Option::None(()));
} |
fn test_atan() {
let a = FixedTrait::new(2 * ONE, false);
assert_relative(a.atan(), 72558, 'invalid two', Option::None(()));
} |
fn test_ceil() {
let a = FixedTrait::new(190054, false);
assert(ceil(a).mag == 3 * ONE, 'invalid pos decimal');
} |
fn test_floor() {
let a = FixedTrait::new(190054, false);
assert(floor(a).mag == 2 * ONE, 'invalid pos decimal');
} |
fn test_round() {
let a = FixedTrait::new(190054, false);
assert(round(a).mag == 3 * ONE, 'invalid pos decimal');
} |
fn test_sqrt_fail() {
let a = FixedTrait::new_unscaled(25, true);
sqrt(a);
} |
fn test_sqrt() {
let mut a = FixedTrait::new_unscaled(0, false);
assert(sqrt(a).mag == 0, 'invalid zero root');
a = FixedTrait::new_unscaled(25, false);
assert(sqrt(a).mag == 5 * ONE, 'invalid pos root');
} |
fn test_msb() {
let a = FixedTrait::<FP16x16>::new_unscaled(100, false);
let (msb, div) = lut::msb(a.mag / ONE);
assert(msb == 6, 'invalid msb');
assert(div == 64, 'invalid msb ceil');
} |
fn test_pow() {
let a = FixedTrait::new_unscaled(3, false);
let b = FixedTrait::new_unscaled(4, false);
assert(pow(a, b).mag == 81 * ONE, 'invalid pos base power');
} |
fn test_pow_frac() {
let a = FixedTrait::new_unscaled(3, false);
let b = FixedTrait::new(32768, false);
assert_relative(
pow(a, b), 113512, 'invalid pos base power', Option::None(())
);
} |
fn test_exp() {
let a = FixedTrait::new_unscaled(2, false);
assert_relative(exp(a), 484249, 'invalid exp of 2', Option::None(()));
} |
fn test_exp2() {
let a = FixedTrait::new_unscaled(5, false);
assert(exp2(a).mag == 2097152, 'invalid exp2 of 2');
} |
fn test_exp2_int() {
assert(exp2_int(5).into() == 2097152, 'invalid exp2 of 2');
} |
fn test_ln() {
let mut a = FixedTrait::new_unscaled(1, false);
assert(ln(a).mag == 0, 'invalid ln of 1');
a = FixedTrait::new(178145, false);
assert_relative(ln(a), ONE.into(), 'invalid ln of 2.7...', Option::None(()));
} |
fn test_log2() {
let mut a = FixedTrait::new_unscaled(32, false);
assert(log2(a) == FixedTrait::new_unscaled(5, false), 'invalid log2 32');
a = FixedTrait::new_unscaled(10, false);
assert_relative(log2(a), 217706, 'invalid log2 10', Option::None(()));
} |
fn test_log10() {
let a = FixedTrait::new_unscaled(100, false);
assert_relative(log10(a), 2 * ONE.into(), 'invalid log10', Option::None(()));
} |
fn test_eq() {
let a = FixedTrait::new_unscaled(42, false);
let b = FixedTrait::new_unscaled(42, false);
let c = eq(@a, @b);
assert(c, 'invalid result');
} |
fn test_ne() {
let a = FixedTrait::new_unscaled(42, false);
let b = FixedTrait::new_unscaled(42, false);
let c = ne(@a, @b);
assert(!c, 'invalid result');
} |
fn test_add() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(2, false);
assert(add(a, b) == FixedTrait::new_unscaled(3, false), 'invalid result');
} |
fn test_add_eq() {
let mut a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(2, false);
a += b;
assert(a == FixedTrait::<FP16x16>::new_unscaled(3, false), 'invalid result');
} |
fn test_sub() {
let a = FixedTrait::new_unscaled(5, false);
let b = FixedTrait::new_unscaled(2, false);
let c = a - b;
assert(c == FixedTrait::<FP16x16>::new_unscaled(3, false), 'false result invalid');
} |
fn test_sub_eq() {
let mut a = FixedTrait::new_unscaled(5, false);
let b = FixedTrait::new_unscaled(2, false);
a -= b;
assert(a == FixedTrait::<FP16x16>::new_unscaled(3, false), 'invalid result');
} |
fn test_mul_pos() {
let a = FP16x16 { mag: 190054, sign: false };
let b = FP16x16 { mag: 190054, sign: false };
let c = a * b;
assert(c.mag == 551155, 'invalid result');
} |
fn test_mul_neg() {
let a = FixedTrait::new_unscaled(5, false);
let b = FixedTrait::new_unscaled(2, true);
let c = a * b;
assert(c == FixedTrait::<FP16x16>::new_unscaled(10, true), 'invalid result');
} |
fn test_mul_eq() {
let mut a = FixedTrait::new_unscaled(5, false);
let b = FixedTrait::new_unscaled(2, true);
a *= b;
assert(a == FixedTrait::<FP16x16>::new_unscaled(10, true), 'invalid result');
} |
fn test_div() {
let a = FixedTrait::new_unscaled(10, false);
let b = FixedTrait::<FP16x16>::new(190054, false);
let c = a / b;
assert(c.mag == 225986, 'invalid pos decimal');
} |
fn test_le() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(0, false);
let c = FixedTrait::<FP16x16>::new_unscaled(1, true);
assert(a <= a, 'a <= a');
assert(!(a <= b), 'a <= b');
assert(!(a <= c), 'a <= c');
assert(b <= a, 'b <= ... |
fn test_lt() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(0, false);
let c = FixedTrait::<FP16x16>::new_unscaled(1, true);
assert(!(a < a), 'a < a');
assert(!(a < b), 'a < b');
assert(!(a < c), 'a < c');
assert(b < a, 'b < a');
... |
fn test_ge() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(0, false);
let c = FixedTrait::<FP16x16>::new_unscaled(1, true);
assert(a >= a, 'a >= a');
assert(a >= b, 'a >= b');
assert(a >= c, 'a >= c');
assert(!(b >= a), 'b >= a')... |
fn test_gt() {
let a = FixedTrait::new_unscaled(1, false);
let b = FixedTrait::new_unscaled(0, false);
let c = FixedTrait::<FP16x16>::new_unscaled(1, true);
assert(!(a > a), 'a > a');
assert(a > b, 'a > b');
assert(a > c, 'a > c');
assert(!(b > a), 'b > a');
... |
fn test_cos() {
let a = FixedTrait::<FP16x16>::new(HALF_PI, false);
assert(a.cos().into() == 0, 'invalid half pi');
} |
fn test_sin() {
let a = FixedTrait::new(HALF_PI, false);
assert_precise(a.sin(), ONE.into(), 'invalid half pi', Option::None(()));
} |
fn test_tan() {
let a = FixedTrait::<FP16x16>::new(HALF_PI / 2, false);
assert(a.tan().mag == 65536, 'invalid quarter pi');
} |
fn test_sign() {
let a = FixedTrait::<FP16x16>::new(0, false);
assert(a.sign().mag == 0 && !a.sign().sign, 'invalid sign (0, true)');
let a = FixedTrait::<FP16x16>::new(HALF, true);
assert(a.sign().mag == ONE && a.sign().sign, 'invalid sign (HALF, true)');
let a = FixedTrait::<... |
fn test_sign_fail() {
let a = FixedTrait::<FP16x16>::new(HALF, true);
assert(a.sign().mag != ONE && !a.sign().sign, 'invalid sign (HALF, true)');
}
} |
use orion::numbers::fixed_point::implementations::fp16x16::core::{ONE, FP16x16, FixedTrait};
use orion::numbers::fixed_point::implementations::fp16x16::math::lut::erf_lut;
const ERF_COMPUTATIONAL_ACCURACY: u32 = 100;
const ROUND_CHECK_NUMBER: u32 = 10;
// Values > MAX_ERF_NUMBER return 1
const MAX_ERF_NUMBER: u32 = 22... |
use orion::numbers::fixed_point::implementations::fp16x16::core::{
HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul,
FP16x16MulEq, FP16x16TryIntoU128, FP16x16PartialEq, FP16x16PartialOrd, FP16x16SubEq, FP16x16Neg,
FP16x16Div, FP16x16IntoFelt252, FixedTrait
};
fn cosh(... |
fn test_cosh() {
let a = FixedTrait::new(TWO, false);
assert_precise(cosh(a), 246550, 'invalid two', Option::None(()));
let a = FixedTrait::ONE();
assert_precise(cosh(a), 101127, 'invalid one', Option::None(()));
let a = FixedTrait::ZERO();
assert_precise(cosh(a), ONE... |
fn test_sinh() {
let a = FixedTrait::new(TWO, false);
assert_precise(sinh(a), 237681, 'invalid two', Option::None(()));
let a = FixedTrait::ONE();
assert_precise(sinh(a), 77018, 'invalid one', Option::None(()));
let a = FixedTrait::ZERO();
assert(sinh(a).into() == 0, ... |
fn test_tanh() {
let a = FixedTrait::new(TWO, false);
assert_precise(tanh(a), 63179, 'invalid two', Option::None(()));
let a = FixedTrait::ONE();
assert_precise(tanh(a), 49912, 'invalid one', Option::None(()));
let a = FixedTrait::ZERO();
assert(tanh(a).into() == 0, '... |
fn test_acosh() {
let a = FixedTrait::new(246559, false);
assert_precise(acosh(a), 131072, 'invalid two', Option::None(()));
let a = FixedTrait::new(101127, false);
assert_precise(acosh(a), ONE.into(), 'invalid one', Option::None(()));
let a = FixedTrait::ONE();
asse... |
fn test_asinh() {
let a = FixedTrait::new(237690, false);
assert_precise(asinh(a), 131072, 'invalid two', Option::None(()));
let a = FixedTrait::new(77018, false);
assert_precise(asinh(a), ONE.into(), 'invalid one', Option::None(()));
let a = FixedTrait::ZERO();
asser... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.