text stringlengths 1 2.05k |
|---|
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::<FP16x16W>::new(HALF_PI / 2, false);
assert(a.tan().mag == 65536, 'invalid quarter pi');
} |
fn test_sign() {
let a = FixedTrait::<FP16x16W>::new(0, false);
assert(a.sign().mag == 0 && !a.sign().sign, 'invalid sign (0, true)');
let a = FixedTrait::<FP16x16W>::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::<FP16x16W>::new(HALF, true);
assert(a.sign().mag != ONE && !a.sign().sign, 'invalid sign (HALF, true)');
}
} |
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ONE, FP16x16W, FixedTrait};
use orion::numbers::fixed_point::implementations::fp16x16wide::math::lut::erf_lut;
const ERF_COMPUTATIONAL_ACCURACY: u64 = 100;
const ROUND_CHECK_NUMBER: u64 = 10;
// Values > MAX_ERF_NUMBER return 1
const MAX_ERF_NUMBER:... |
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{
HALF, ONE, TWO, FP16x16W, FP16x16WImpl, FP16x16WAdd, FP16x16WAddEq, FP16x16WSub, FP16x16WMul,
FP16x16WMulEq, FP16x16WTryIntoU128, FP16x16WPartialEq, FP16x16WPartialOrd, FP16x16WSubEq,
FP16x16WNeg, FP16x16WDiv, FP16x16WIntoFelt252, FixedT... |
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... |
fn test_atanh() {
let a = FixedTrait::new(58982, false);
assert_precise(atanh(a), 96483, 'invalid 0.9', Option::None(()));
let a = FixedTrait::new(HALF, false);
assert_precise(atanh(a), 35999, 'invalid half', Option::None(()));
let a = FixedTrait::ZERO();
assert(ata... |
use orion::numbers::fixed_point::implementations::fp8x23wide::core::ONE;
fn msb(whole: u64) -> (u64, u64) {
if whole < 256 {
if whole < 2 {
return (0, 1);
}
if whole < 4 {
return (1, 2);
}
if whole < 8 {
return (2, 4);
}
i... |
if exp == 14 {
return 16384;
}
if exp == 15 {
return 32768;
}
if exp == 16 {
return 65536;
}
}
65536
}
fn sin(a: u64) -> (u64, u64, u64) {
let slot = a / 402;
if slot < 128 {
if slot < 64 {
if slot < 32 {
... |
24);
}
} else {
if slot == 16 {
return (6434, 6424, 6824);
}
if slot == 17 {
return (6836, 6824, 7224);
}
if slot == 18 {
... |
return (13270, 13180, 13573);
}
if slot == 34 {
return (13672, 13573, 13966);
}
if slot == 35 {
return (14074, 13966, 14359);
}
if slot == 36 {
... |
return (20508, 20175, 20557);
}
if slot == 52 {
return (20910, 20557, 20939);
}
if slot == 53 {
return (21313, 20939, 21320);
}
if slot == 54 {
... |
}
if slot == 69 {
return (27747, 26925, 27291);
}
if slot == 70 {
return (28149, 27291, 27656);
}
if slot == 71 {
return (28551, 27656, 28020);
... |
}
if slot == 87 {
return (34985, 33347, 33692);
}
if slot == 88 {
return (35387, 33692, 34037);
}
if slot == 89 {
return (35789, 34037, 34380);
... |
return (41821, 39040, 39362);
}
if slot == 105 {
return (42223, 39362, 39683);
}
if slot == 106 {
return (42625, 39683, 40002);
}
if slot == 107 {
... |
return (49059, 44604, 44898);
}
if slot == 123 {
return (49461, 44898, 45190);
}
if slot == 124 {
return (49863, 45190, 45480);
}
if slot == 125 {
... |
9 {
return (55895, 49361, 49624);
}
if slot == 140 {
return (56297, 49624, 49886);
}
if slot == 141 {
return (56699, 49886, 50146);
}
... |
slot == 157 {
return (63133, 53812, 54040);
}
if slot == 158 {
return (63536, 54040, 54267);
}
if slot == 159 {
return (63938, 54267, 54491);
}
... |
414, 57607);
}
if slot == 175 {
return (70372, 57607, 57798);
}
} else {
if slot == 176 {
return (70774, 57798, 57986);
}
if slot == 177... |
t < 224 {
if slot < 208 {
if slot == 192 {
return (77208, 60547, 60700);
}
if slot == 193 {
return (77610, 60700, 60851);
}
if slot == 194 {
... |
return (84044, 62830, 62943);
}
if slot == 210 {
return (84446, 62943, 63054);
}
if slot == 211 {
return (84848, 63054, 63162);
}
if slot == 212 {
... |
if slot == 227 {
return (91282, 64501, 64571);
}
if slot == 228 {
return (91684, 64571, 64639);
}
if slot == 229 {
return (92086, 64639, 64704);
}
... |
}
if slot == 245 {
return (98520, 65387, 65413);
}
if slot == 246 {
return (98922, 65413, 65436);
}
if slot == 247 {
return (99325, 65436, 65457);
... |
;
}
if slot == 13 {
return (5964, 5947, 6402);
}
if slot == 14 {
return (6423, 6402, 6856);
}
if slot == 15 {
return (6881, 6856, 7310);
}
if slot == 16 {
return (7340, 7310, 7762);
}
if slot == 17 {
return (7799, 7762, 8214);
}
if ... |
{
return (20644, 19999, 20416);
}
if slot == 46 {
return (21103, 20416, 20830);
}
if slot == 47 {
return (21561, 20830, 21243);
}
if slot == 48 {
return (22020, 21243, 21655);
}
if slot == 49 {
return (22479, 21655, 22064);
}
if slot == 50 ... |
{
return (35324, 32398, 32753);
}
if slot == 78 {
return (35783, 32753, 33105);
}
if slot == 79 {
return (36241, 33105, 33455);
}
if slot == 80 {
return (36700, 33455, 33804);
}
if slot == 81 {
return (37159, 33804, 34150);
}
if slot == 82 ... |
}
if x <= 12451 {
if x <= 6553 {
return 7370;
}
if x <= 7208 {
return 8101;
}
if x <= 7864 {
return 8831;
}
if x <= 8519 {
return 9559;
}
if x <= 9175 {
return 10285;
}
... |
turn 29325;
}
if x <= 28180 {
return 29942;
}
if x <= 28835 {
return 30554;
}
if x <= 29491 {
return 31161;
}
if x <= 30146 {
return 31762;
}
if x <= 30801 {
return 32358;
... |
return 46606;
}
if x <= 49807 {
return 47024;
}
if x <= 50462 {
return 47436;
}
if x <= 51118 {
return 47841;
}
if x <= 51773 {
return 48241;
}
}
if x <= 58327 {
if x <= 52428 {
... |
778 {
return 57234;
}
if x <= 71434 {
return 57462;
}
}
if x <= 77987 {
if x <= 72089 {
return 57685;
}
if x <= 72744 {
return 57903;
}
if x <= 73400 {
return 58116;
}
if x... |
62408;
}
if x <= 92405 {
return 62511;
}
if x <= 93061 {
return 62611;
}
if x <= 93716 {
return 62708;
}
if x <= 94371 {
return 62802;
}
if x <= 95027 {
return 62894;
}
... |
f x <= 113377 {
return 64590;
}
if x <= 114032 {
return 64627;
}
if x <= 114688 {
return 64662;
}
if x <= 115343 {
return 64696;
}
if x <= 115998 {
return 64729;
}
if x <= 116654 {... |
return 65509;
}
if x <= 170393 {
return 65520;
}
if x <= 176947 {
return 65527;
}
if x <= 183500 {
return 65531;
}
if x <= 190054 {
return 65533;
}
if x <= 196608 {
return 65534;
... |
use core::integer;
use orion::numbers::fixed_point::implementations::fp16x16wide::math::lut;
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{
HALF, ONE, TWO, FP16x16W, FP16x16WImpl, FP16x16WAdd, FP16x16WSub, FP16x16WMul, FP16x16WDiv,
FP16x16WIntoFelt252, FixedTrait
};
const TWO_PI: u64 ... |
(21852, true)) * at;
let r2 = r3 * at;
let mut res = (r2 + FixedTrait::new(65536, false)) * at;
if (shift) {
res = res + FixedTrait::new(34315, false);
}
if (invert) {
res = res - FixedTrait::new(HALF_PI, false);
}
FixedTrait::new(res.mag, a.sign)
}
fn atan_fast(a: ... |
ial_rem);
let partial_step = FixedTrait::new(partial_rem - start, false) / FixedTrait::new(402, false);
let res = partial_step * (FixedTrait::new(high, false) - FixedTrait::new(low, false))
+ FixedTrait::<FP16x16W>::new(low, false);
FixedTrait::new(res.mag, a.sign ^ partial_sign && res.mag != 0)
}
... |
fn test_acos() {
let error = Option::Some(84);
let a = FixedTrait::ONE();
assert(acos(a).into() == 0, 'invalid one');
let a = FixedTrait::new(ONE / 2, false);
assert_relative(acos(a), 68629, 'invalid half', error);
let a = FixedTrait::ZERO();
assert_relative(... |
fn test_acos_fast() {
let error = Option::Some(84);
let a = FixedTrait::ONE();
assert(acos_fast(a).into() == 0, 'invalid one');
let a = FixedTrait::new(ONE / 2, false);
assert_relative(acos_fast(a), 68629, 'invalid half', error);
let a = FixedTrait::ZERO();
a... |
fn test_acos_fail() {
let a = FixedTrait::new(2 * ONE, true);
acos(a);
} |
fn test_atan_fast() {
let error = Option::Some(84);
let a = FixedTrait::new(2 * ONE, false);
assert_relative(atan_fast(a), 72558, 'invalid two', error);
let a = FixedTrait::ONE();
assert_relative(atan_fast(a), 51472, 'invalid one', error);
let a = FixedTrait::new(ONE ... |
fn test_atan() {
let a = FixedTrait::new(2 * ONE, false);
assert_relative(atan(a), 72558, 'invalid two', Option::None(()));
let a = FixedTrait::ONE();
assert_relative(atan(a), 51472, 'invalid one', Option::None(()));
let a = FixedTrait::new(ONE / 2, false);
assert_relat... |
fn test_asin() {
let error = Option::Some(84);
let a = FixedTrait::ONE();
assert_relative(asin(a), HALF_PI.into(), 'invalid one', Option::None(()));
let a = FixedTrait::new(ONE / 2, false);
assert_relative(asin(a), 34315, 'invalid half', error);
let a = FixedTrait::Z... |
fn test_asin_fail() {
let a = FixedTrait::new(2 * ONE, false);
asin(a);
} |
fn test_cos() {
let a = FixedTrait::new(HALF_PI, false);
assert(cos(a).into() == 0, 'invalid half pi');
let a = FixedTrait::new(HALF_PI / 2, false);
assert_relative(cos(a), 46341, 'invalid quarter pi', Option::None(()));
let a = FixedTrait::new(PI, false);
assert_relat... |
fn test_cos_fast() {
let error = Option::Some(84);
let a = FixedTrait::new(HALF_PI, false);
assert(cos_fast(a).into() == 0, 'invalid half pi');
let a = FixedTrait::new(HALF_PI / 2, false);
assert_precise(cos_fast(a), 46341, 'invalid quarter pi', error);
let a = Fixed... |
fn test_sin() {
let a = FixedTrait::new(HALF_PI, false);
assert_precise(sin(a), ONE.into(), 'invalid half pi', Option::None(()));
let a = FixedTrait::new(HALF_PI / 2, false);
assert_precise(sin(a), 46341, 'invalid quarter pi', Option::None(()));
let a = FixedTrait::new(PI, fal... |
fn test_sin_fast() {
let error = Option::Some(84);
let a = FixedTrait::new(HALF_PI, false);
assert_precise(sin_fast(a), ONE.into(), 'invalid half pi', error);
let a = FixedTrait::new(HALF_PI / 2, false);
assert_precise(sin_fast(a), 46341, 'invalid quarter pi', error);
... |
fn test_tan() {
let a = FixedTrait::new(HALF_PI / 2, false);
assert_precise(tan(a), ONE.into(), 'invalid quarter pi', Option::None(()));
let a = FixedTrait::new(PI, false);
assert_precise(tan(a), 0, 'invalid pi', Option::None(()));
let a = FixedTrait::new_unscaled(17, false);
... |
mod core;
mod comp;
mod erf;
mod lut;
|
use orion::numbers::{FP32x32, FP32x32Impl, FixedTrait};
fn xor(a: FP32x32, b: FP32x32) -> bool {
if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) {
true
} else {
false
}
}
fn or(a: FP32x32, b: FP32x32) -> bool {
let zero = FixedTrait::new(0, false);
... |
use core::debug::PrintTrait;
use cubit::f64 as fp32x32;
use cubit::f64::Fixed as FP32x32;
use cubit::f64::{ONE, HALF};
use cubit::f64::types::fixed;
use orion::numbers::fixed_point::core::{FixedTrait};
use orion::numbers::fixed_point::implementations::fp32x32::erf;
use orion::numbers::fixed_point::utils;
const MAX: ... |
) -> FP32x32 {
fp32x32::trig::cos_fast(self)
}
fn cos_fast(self: FP32x32) -> FP32x32 {
fp32x32::trig::cos_fast(self)
}
fn cosh(self: FP32x32) -> FP32x32 {
fp32x32::hyp::cosh(self)
}
fn floor(self: FP32x32) -> FP32x32 {
fp32x32::ops::floor(self)
}
... |
inf(self: FP32x32) -> bool {
self.mag == 4294967295
}
fn is_pos_inf(self: FP32x32) -> bool {
self.is_inf() && !self.sign
}
fn is_neg_inf(self: FP32x32) -> bool {
self.is_inf() && self.sign
}
fn erf(self: FP32x32) -> FP32x32 {
erf::erf(self)
}
}
impl FP32x3... |
fn print(self: FP32x32) {
self.sign.print();
self.mag.print();
}
}
impl FP32x32IntoFelt252 of Into<FP32x32, felt252> {
fn into(self: FP32x32) -> felt252 {
let mag_felt = self.mag.into();
if self.sign {
mag_felt * -1
} else {
mag_felt * 1
... |
fn add_eq(ref self: FP32x32, other: FP32x32) {
self = fp32x32::ops::add(self, other);
}
}
impl FP32x32Sub of Sub<FP32x32> {
fn sub(lhs: FP32x32, rhs: FP32x32) -> FP32x32 {
fp32x32::ops::sub(lhs, rhs)
}
}
impl FP32x32SubEq of SubEq<FP32x32> { |
fn sub_eq(ref self: FP32x32, other: FP32x32) {
self = fp32x32::ops::sub(self, other);
}
}
impl FP32x32Mul of Mul<FP32x32> {
fn mul(lhs: FP32x32, rhs: FP32x32) -> FP32x32 {
fp32x32::ops::mul(lhs, rhs)
}
}
impl FP32x32MulEq of MulEq<FP32x32> { |
fn mul_eq(ref self: FP32x32, other: FP32x32) {
self = fp32x32::ops::mul(self, other);
}
}
impl FP32x32Div of Div<FP32x32> {
fn div(lhs: FP32x32, rhs: FP32x32) -> FP32x32 {
fp32x32::ops::div(lhs, rhs)
}
}
impl FP32x32DivEq of DivEq<FP32x32> { |
fn div_eq(ref self: FP32x32, other: FP32x32) {
self = fp32x32::ops::div(self, other);
}
}
impl FP32x32PartialOrd of PartialOrd<FP32x32> {
fn ge(lhs: FP32x32, rhs: FP32x32) -> bool {
fp32x32::ops::ge(lhs, rhs)
}
fn gt(lhs: FP32x32, rhs: FP32x32) -> bool {
fp32x32::ops:... |
use cubit::f64::ONE;
use orion::numbers::{FP32x32, FixedTrait};
use orion::numbers::fixed_point::implementations::fp32x32::lut::erf_lut;
const ERF_COMPUTATIONAL_ACCURACY: u64 = 100;
const ROUND_CHECK_NUMBER: u64 = 10;
// Values > MAX_ERF_NUMBER return 1
const MAX_ERF_NUMBER: u64 = 15032385536;
// Values <= ERF_TRUNCA... |
use orion::numbers::fixed_point::implementations::fp32x32::core::ONE;
fn erf_lut(x: u64) -> u64 {
if x <= 386547056 {
if x <= 0 {
return 0;
}
if x <= 42949672 {
return 48461900;
}
if x <= 85899345 {
return 96914110;
}
... |
return 1277401521;
}
if x <= 1202590842 {
return 1322334823;
}
if x <= 1245540515 {
return 1367017205;
}
}
if x <= 1675037245 {
if x <= 1288490188 {
return 1411441184;
}
if x <= 1331439861 {
return 14... |
return 2419455435;
}
if x <= 2405181685 {
return 2455071011;
}
if x <= 2448131358 {
return 2490289925;
}
if x <= 2491081031 {
return 2525109629;
}
if x <= 2534030704 {
return 2559527765;
}
}
i... |
55 {
return 3262129696;
}
if x <= 3607772528 {
return 3286262922;
}
if x <= 3650722201 {
return 3309994103;
}
if x <= 3693671874 {
return 3333325270;
}
if x <= 3736621547 {
return 3356258580;
... |
7413698 {
return 3794745393;
}
if x <= 4810363371 {
return 3808724986;
}
if x <= 4853313044 {
return 3822394923;
}
if x <= 4896262717 {
return 3835759389;
}
if x <= 4939212390 {
return 3848822598;... |
rn 4083110714;
}
}
if x <= 6399501271 {
if x <= 6012954214 {
return 4090033445;
}
if x <= 6055903887 {
return 4096765032;
}
if x <= 6098853560 {
return 4103309442;
}
if x <= 6141803233 {
return 410967... |
return 4216843737;
}
if x <= 7215545057 {
return 4219774388;
}
if x <= 7258494730 {
return 4222608207;
}
}
if x <= 7687991459 {
if x <= 7301444403 {
return 4225347845;
}
if x <= 7344394076 {
return 42... |
return 4269967724;
}
if x <= 8418135900 {
return 4271028331;
}
if x <= 8461085573 {
return 4272048167;
}
if x <= 8504035246 {
return 4273028604;
}
if x <= 8546984919 {
return 4273970975;
}
}
i... |
mod core;
mod comp;
mod erf;
mod lut;
|
use orion::numbers::{FP64x64, FixedTrait};
use orion::numbers::FP64x64Impl;
fn xor(a: FP64x64, b: FP64x64) -> bool {
if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) {
true
} else {
false
}
}
fn or(a: FP64x64, b: FP64x64) -> bool {
let zero = FixedTrait... |
use core::debug::PrintTrait;
use cubit::f128 as fp64x64;
use cubit::f128::types::Fixed as FP64x64;
use cubit::f128::ONE_u128 as ONE;
use cubit::f128::ops::MAX_u128 as MAX;
use orion::numbers::fixed_point::implementations::fp64x64::erf;
use orion::numbers::fixed_point::core::{FixedTrait};
use orion::numbers::fixed_poi... |
lf)
}
fn cos(self: FP64x64) -> FP64x64 {
fp64x64::trig::cos_fast(self)
}
fn cos_fast(self: FP64x64) -> FP64x64 {
fp64x64::trig::cos_fast(self)
}
fn cosh(self: FP64x64) -> FP64x64 {
fp64x64::hyp::cosh(self)
}
fn floor(self: FP64x64) -> FP64x64 {
fp64x64... |
295, sign: true }
}
fn is_inf(self: FP64x64) -> bool {
self.mag == 4294967295
}
fn is_pos_inf(self: FP64x64) -> bool {
self.is_inf() && !self.sign
}
fn is_neg_inf(self: FP64x64) -> bool {
self.is_inf() && self.sign
}
fn erf(self: FP64x64) -> FP64x64 {
... |
fn print(self: FP64x64) {
self.sign.print();
self.mag.print();
}
}
impl FP64x64IntoFelt252 of Into<FP64x64, felt252> {
fn into(self: FP64x64) -> felt252 {
let mag_felt = self.mag.into();
if self.sign {
mag_felt * -1
} else {
mag_felt * 1
... |
fn add_eq(ref self: FP64x64, other: FP64x64) {
self = fp64x64::ops::add(self, other);
}
}
impl FP64x64Sub of Sub<FP64x64> {
fn sub(lhs: FP64x64, rhs: FP64x64) -> FP64x64 {
fp64x64::ops::sub(lhs, rhs)
}
}
impl FP64x64SubEq of SubEq<FP64x64> { |
fn sub_eq(ref self: FP64x64, other: FP64x64) {
self = fp64x64::ops::sub(self, other);
}
}
impl FP64x64Mul of Mul<FP64x64> {
fn mul(lhs: FP64x64, rhs: FP64x64) -> FP64x64 {
fp64x64::ops::mul(lhs, rhs)
}
}
impl FP64x64MulEq of MulEq<FP64x64> { |
fn mul_eq(ref self: FP64x64, other: FP64x64) {
self = fp64x64::ops::mul(self, other);
}
}
impl FP64x64Div of Div<FP64x64> {
fn div(lhs: FP64x64, rhs: FP64x64) -> FP64x64 {
fp64x64::ops::div(lhs, rhs)
}
}
impl FP64x64DivEq of DivEq<FP64x64> { |
fn div_eq(ref self: FP64x64, other: FP64x64) {
self = fp64x64::ops::div(self, other);
}
}
impl FP64x64PartialOrd of PartialOrd<FP64x64> {
fn ge(lhs: FP64x64, rhs: FP64x64) -> bool {
fp64x64::ops::ge(lhs, rhs)
}
fn gt(lhs: FP64x64, rhs: FP64x64) -> bool {
fp64x64::ops:... |
use cubit::f128::ONE_u128 as ONE;
use orion::numbers::{FP64x64, FixedTrait};
use orion::numbers::fixed_point::implementations::fp64x64::lut::erf_lut;
const ERF_COMPUTATIONAL_ACCURACY: u128 = 100_u128;
const ROUND_CHECK_NUMBER: u128 = 10_u128;
// Values > MAX_ERF_NUMBER return 1
const MAX_ERF_NUMBER: u128 = 6456360425... |
use orion::numbers::fixed_point::implementations::fp64x64::core::ONE;
fn erf_lut(x: u128) -> u128 {
if x <= 1660206966633859584 {
if x <= 0 {
return 0;
}
if x <= 184467440737095520 {
return 208142279036071072;
}
if x <= 368934881474191040 {
... |
5479005696 {
return 4307719148851377152;
}
if x <= 4058283696216101376 {
return 4506464159522699776;
}
if x <= 4242751136953197056 {
return 4704336627690769408;
}
if x <= 4427218577690292224 {
return 4901300987890141184;
... |
8428071925038478336;
}
if x <= 8116567392432202752 {
return 8600335382268215296;
}
if x <= 8301034833169298432 {
return 8771089596636659712;
}
if x <= 8485502273906394112 {
return 8940313943304876032;
}
if x <= 866996971... |
0689545969664;
}
if x <= 12174851088648304640 {
return 11978885570285762560;
}
if x <= 12359318529385400320 {
return 12112643176041672704;
}
if x <= 12543785970122496000 {
return 12244620414653018112;
}
if x <= 127282534... |
return 14415020838763323392;
}
if x <= 16233134784864405504 {
return 14511819642834194432;
}
if x <= 16417602225601501184 {
return 14606929720482222080;
}
}
if x <= 18262276632972455936 {
if x <= 16602069666338596864 {
return 14... |
{
return 16174162424476436480;
}
}
if x <= 21951625447714365440 {
if x <= 20291418481080508416 {
return 16236917650814795776;
}
if x <= 20475885921817604096 {
return 16298307360687947776;
}
if x <= 20660353362554699776 {
... |
617280;
}
if x <= 24165234736559513600 {
return 17267316862634573824;
}
if x <= 24349702177296609280 {
return 17304247840201650176;
}
if x <= 24534169618033704960 {
return 17340216612984107008;
}
if x <= 2471863705877080... |
17864075935211624448;
}
if x <= 28223518432775614464 {
return 17884417384457840640;
}
if x <= 28407985873512710144 {
return 17904145822477408256;
}
if x <= 28592453314249805824 {
return 17923275896682506240;
}
if x <= 28... |
return 18190972496134107136;
}
if x <= 32281802128991715328 {
return 18200879803759552512;
}
if x <= 32466269569728811008 {
return 18210446359243550720;
}
if x <= 32650737010465906688 {
return 18219682035133120512;
}
if ... |
720512 {
return 18343927003671875584;
}
if x <= 36340085825207816192 {
return 18348307167957243904;
}
if x <= 36524553265944911872 {
return 18352518112116494336;
}
if x <= 36709020706682007552 {
return 18356565564120772608;
... |
mod core;
mod math;
mod helpers;
|
use core::debug::PrintTrait;
use orion::numbers::fixed_point::core::{FixedTrait};
use orion::numbers::fixed_point::implementations::fp8x23::math::{core as core_math, trig, hyp, erf};
use orion::numbers::fixed_point::utils; |
struct FP8x23 {
mag: u32,
sign: bool
}
const TWO: u32 = 16777216;
const ONE: u32 = 8388608;
const HALF: u32 = 4194304;
const MAX: u32 = 2147483648;
impl FP8x23Impl of FixedTrait<FP8x23, u32> {
fn ZERO() -> FP8x23 {
FP8x23 { mag: 0, sign: false }
}
fn HALF() -> FP8x23 {
FP8x2... |
8x23 {
core_math::exp(self)
}
fn exp2(self: FP8x23) -> FP8x23 {
core_math::exp2(self)
}
fn ln(self: FP8x23) -> FP8x23 {
core_math::ln(self)
}
fn log2(self: FP8x23) -> FP8x23 {
core_math::log2(self)
}
fn log10(self: FP... |
fn print(self: FP8x23) {
self.sign.print();
self.mag.print();
}
}
impl FP8x23IntoFelt252 of Into<FP8x23, felt252> {
fn into(self: FP8x23) -> felt252 {
let mag_felt = self.mag.into();
if self.sign {
mag_felt * -1
} else {
mag_felt * 1
}
... |
s: FP8x23, rhs: FP8x23) -> FP8x23 {
core_math::add(lhs, rhs)
}
}
impl FP8x23AddEq of AddEq<FP8x23> { |
fn add_eq(ref self: FP8x23, other: FP8x23) {
self = Add::add(self, other);
}
}
impl FP8x23Sub of Sub<FP8x23> {
fn sub(lhs: FP8x23, rhs: FP8x23) -> FP8x23 {
core_math::sub(lhs, rhs)
}
}
impl FP8x23SubEq of SubEq<FP8x23> { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.