text stringlengths 1 2.05k |
|---|
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::fp16x16::core::ONE;
fn msb(whole: u32) -> (u32, u32) {
if whole < 256 {
if whole < 2 {
return (0, 1);
}
if whole < 4 {
return (1, 2);
}
if whole < 8 {
return (2, 4);
}
if w... |
f exp == 14 {
return 16384;
}
if exp == 15 {
return 32768;
}
if exp == 16 {
return 65536;
}
}
65536
}
fn sin(a: u32) -> (u32, u32, u32) {
let slot = a / 402;
if slot < 128 {
if slot < 64 {
if slot < 32 {
... |
;
}
} 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 {
... |
return (55895, 49361, 49624);
}
if slot == 140 {
return (56297, 49624, 49886);
}
if slot == 141 {
return (56699, 49886, 50146);
}
if slot == 142 {
... |
ot == 157 {
return (63133, 53812, 54040);
}
if slot == 158 {
return (63536, 54040, 54267);
}
if slot == 159 {
return (63938, 54267, 54491);
}
... |
, 57607);
}
if slot == 175 {
return (70372, 57607, 57798);
}
} else {
if slot == 176 {
return (70774, 57798, 57986);
}
if slot == 177 {
... |
224 {
if slot < 208 {
if slot == 192 {
return (77208, 60547, 60700);
}
if slot == 193 {
return (77610, 60700, 60851);
}
if slot == 194 {
... |
turn (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 slot =... |
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;
}
if x ... |
n 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 {
... |
{
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 <= ... |
408;
}
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;
}
... |
<= 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::fp16x16::math::lut;
use orion::numbers::fixed_point::implementations::fp16x16::core::{
HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16Mul, FP16x16Div,
FP16x16IntoFelt252, FixedTrait
};
const TWO_PI: u32 = 411775;
const... |
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: FP16x16) -> FP16x16 {
... |
edTrait::new(partial_rem - start, false) / FixedTrait::new(402, false);
let res = partial_step * (FixedTrait::new(high, false) - FixedTrait::new(low, false))
+ FixedTrait::<FP16x16>::new(low, false);
FixedTrait::new(res.mag, a.sign ^ partial_sign && res.mag != 0)
}
fn tan(a: FP16x16) -> FP16x16 {
... |
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 math;
mod helpers;
|
use core::debug::PrintTrait;
use orion::numbers::{fixed_point::core::FixedTrait, FP16x16};
use orion::numbers::fixed_point::implementations::fp16x16wide::math::{
core as core_math, trig, hyp, erf
};
use orion::numbers::fixed_point::utils; |
struct FP16x16W {
mag: u64,
sign: bool
}
const TWO: u64 = 131072;
const ONE: u64 = 65536;
const HALF: u64 = 32768;
const MAX: u64 = 2147483648;
impl FP16x16WImpl of FixedTrait<FP16x16W, u64> {
fn ZERO() -> FP16x16W {
FP16x16W { mag: 0, sign: false }
}
fn HALF() -> FP16x16W {
... |
FP16x16W {
core_math::floor(self)
}
fn exp(self: FP16x16W) -> FP16x16W {
core_math::exp(self)
}
fn exp2(self: FP16x16W) -> FP16x16W {
core_math::exp2(self)
}
fn ln(self: FP16x16W) -> FP16x16W {
core_math::ln(self)
}
fn log... |
}
}
impl FP16x16WPrint of PrintTrait<FP16x16W> { |
fn print(self: FP16x16W) {
self.sign.print();
self.mag.print();
}
}
impl FP16x16WIntoFelt252 of Into<FP16x16W, felt252> {
fn into(self: FP16x16W) -> felt252 {
let mag_felt = self.mag.into();
if self.sign {
mag_felt * -1
} else {
mag_felt * 1
... |
}
}
impl FP16x16WTryIntoU8 of TryInto<FP16x16W, u8> {
fn try_into(self: FP16x16W) -> Option<u8> {
if self.sign {
Option::None(())
} else {
(self.mag / ONE).try_into()
}
}
}
impl FP16x16WPartialEq of PartialEq<FP16x16W> {
fn eq(lhs: @FP16x16... |
fn add_eq(ref self: FP16x16W, other: FP16x16W) {
self = Add::add(self, other);
}
}
impl FP16x16WSub of Sub<FP16x16W> {
fn sub(lhs: FP16x16W, rhs: FP16x16W) -> FP16x16W {
core_math::sub(lhs, rhs)
}
}
impl FP16x16WSubEq of SubEq<FP16x16W> { |
fn sub_eq(ref self: FP16x16W, other: FP16x16W) {
self = Sub::sub(self, other);
}
}
impl FP16x16WMul of Mul<FP16x16W> {
fn mul(lhs: FP16x16W, rhs: FP16x16W) -> FP16x16W {
core_math::mul(lhs, rhs)
}
}
impl FP16x16WMulEq of MulEq<FP16x16W> { |
fn mul_eq(ref self: FP16x16W, other: FP16x16W) {
self = Mul::mul(self, other);
}
}
impl FP16x16WDiv of Div<FP16x16W> {
fn div(lhs: FP16x16W, rhs: FP16x16W) -> FP16x16W {
core_math::div(lhs, rhs)
}
}
impl FP16x16WDivEq of DivEq<FP16x16W> { |
fn div_eq(ref self: FP16x16W, other: FP16x16W) {
self = Div::div(self, other);
}
}
impl FP16x16WPartialOrd of PartialOrd<FP16x16W> {
fn ge(lhs: FP16x16W, rhs: FP16x16W) -> bool {
core_math::ge(lhs, rhs)
}
fn gt(lhs: FP16x16W, rhs: FP16x16W) -> bool {
core_math::gt(lhs... |
use core::debug::PrintTrait;
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{
HALF, ONE, TWO, FP16x16W, FP16x16WImpl, FP16x16WSub, FP16x16WDiv, FixedTrait, FP16x16WPrint
};
const DEFAULT_PRECISION: u64 = 7; // 1e-4
// To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`.
// To use `... |
mod core;
mod comp;
mod lut;
mod trig;
mod hyp;
mod erf;
|
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{
FP16x16W, FixedTrait, FP16x16WImpl, FP16x16WPartialOrd, FP16x16WPartialEq
};
fn max(a: FP16x16W, b: FP16x16W) -> FP16x16W {
if a >= b {
a
} else {
b
}
}
fn min(a: FP16x16W, b: FP16x16W) -> FP16x16W {
if a <= b {... |
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::fp16x16wide::core::{
HALF, ONE, MAX, FP16x16W, FP16x16WImpl, FP16x16WAdd, FP16x16WAddEq, FP16x16WSub, FP16x16WMul,
FP16x16WMulEq, FP16x16WTryIntoU128, FP16x16WPartialEq, FP16x16WPartialOrd, FP16x16WSubEq,
FP16x16WNeg, FP16x16WDiv, FP16x16... |
10, false)) * frac;
let r5 = (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)) * fr... |
ue)) * norm;
let r5 = (r6 + FixedTrait::new(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)) * ... |
zero(ONE));
if (HALF <= rem) {
FixedTrait::new_unscaled(div + 1, a.sign)
} else {
FixedTrait::new_unscaled(div, a.sign)
}
}
fn sqrt(a: FP16x16W) -> FP16x16W {
assert(a.sign == false, 'must be positive');
let root = integer::u64_sqrt(a.mag.into() * ONE.into());
FixedTrait::n... |
fn test_into() {
let a = FixedTrait::<FP16x16W>::new_unscaled(5, false);
assert(a.mag == 5 * ONE, 'invalid result');
} |
fn test_try_into_u128() {
let a = FixedTrait::<FP16x16W>::new_unscaled(5, false);
assert(a.try_into().unwrap() == 5_u128, 'invalid result');
let b = FixedTrait::<FP16x16W>::new(5 * ONE, false);
assert(b.try_into().unwrap() == 5_u128, 'invalid result');
... |
fn test_negative_try_into_u128() {
let a = FixedTrait::<FP16x16W>::new_unscaled(1, true);
let _a: u128 = a.try_into().unwrap();
} |
fn test_acos() {
let a = FixedTrait::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::new_unscaled(3, false), 'invalid result');
} |
fn test_mul_pos() {
let a = FP16x16W { mag: 190054, sign: false };
let b = FP16x16W { 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::<FP16x16W>::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::<FP16x16W>::new_unscaled(10, true), 'invalid result');
} |
fn test_div() {
let a = FixedTrait::new_unscaled(10, false);
let b = FixedTrait::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::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::<FP16x16W>::new(HALF_PI, false);
assert(a.cos().into() == 0, 'invalid half pi');
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.