From e3333245d96c4f81ea13c52e158027327164c76b Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Wed, 5 Jun 2024 12:23:12 +0200 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20Cairo=20version?= =?UTF-8?q?=20(nightly)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scarb.toml | 2 +- src/f128/math/comp.cairo | 2 +- src/f128/math/hyp.cairo | 2 +- src/f128/math/ops.cairo | 2 +- src/f128/math/trig.cairo | 2 +- src/f128/procgen/rand.cairo | 2 +- src/f128/procgen/simplex3.cairo | 2 +- src/f128/types/fixed.cairo | 18 +++++++++++++----- src/f128/types/vec2.cairo | 2 +- src/f128/types/vec3.cairo | 2 +- src/f128/types/vec4.cairo | 2 +- src/f64/math/comp.cairo | 2 +- src/f64/math/hyp.cairo | 2 +- src/f64/math/ops.cairo | 2 +- src/f64/math/trig.cairo | 2 +- src/f64/procgen/rand.cairo | 2 +- src/f64/procgen/simplex3.cairo | 2 +- src/f64/types/fixed.cairo | 14 +++++++++++--- src/f64/types/vec2.cairo | 2 +- src/f64/types/vec3.cairo | 2 +- src/f64/types/vec4.cairo | 2 +- src/math/trig.cairo | 2 +- src/types/vec2.cairo | 2 +- 23 files changed, 45 insertions(+), 29 deletions(-) diff --git a/Scarb.toml b/Scarb.toml index 8321422..c6a7620 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -1,7 +1,7 @@ [package] name = "cubit" version = "1.3.0" -cairo-version = ">=2.4.0" +cairo-version = ">=2.6.4" edition = "2023_10" description = "Math library in Cairo using a 64.64 fixed point representation" homepage = "https://github.com/influenceth/cubit" diff --git a/src/f128/math/comp.cairo b/src/f128/math/comp.cairo index f53dee3..6156206 100644 --- a/src/f128/math/comp.cairo +++ b/src/f128/math/comp.cairo @@ -16,7 +16,7 @@ fn min(a: Fixed, b: Fixed) -> Fixed { } } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/math/hyp.cairo b/src/f128/math/hyp.cairo index 8c919df..70a2fab 100644 --- a/src/f128/math/hyp.cairo +++ b/src/f128/math/hyp.cairo @@ -44,7 +44,7 @@ fn atanh(a: Fixed) -> Fixed { return ln_arg.ln() / FixedTrait::new_unscaled(2_u128, false); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/math/ops.cairo b/src/f128/math/ops.cairo index fd39913..dc9e238 100644 --- a/src/f128/math/ops.cairo +++ b/src/f128/math/ops.cairo @@ -304,7 +304,7 @@ fn _split_unsigned(a: Fixed) -> (u128, u128) { return integer::u128_safe_divmod(a.mag, integer::u128_as_non_zero(ONE_u128)); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/math/trig.cairo b/src/f128/math/trig.cairo index 6a20ae0..df30472 100644 --- a/src/f128/math/trig.cairo +++ b/src/f128/math/trig.cairo @@ -205,7 +205,7 @@ fn _sin_loop(a: Fixed, i: u128, acc: Fixed) -> Fixed { return _sin_loop(a, i - 1, new_acc); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/procgen/rand.cairo b/src/f128/procgen/rand.cairo index fb0a6bd..496a58e 100644 --- a/src/f128/procgen/rand.cairo +++ b/src/f128/procgen/rand.cairo @@ -46,7 +46,7 @@ fn _fixed_normal_between_loop( return _fixed_normal_between_loop(seed, low, high, acc + sample, iter - 1); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/procgen/simplex3.cairo b/src/f128/procgen/simplex3.cairo index c71febd..c36ff1e 100644 --- a/src/f128/procgen/simplex3.cairo +++ b/src/f128/procgen/simplex3.cairo @@ -144,7 +144,7 @@ fn noise_octaves(v: Vec3, mut octaves: u128, persistence: Fixed) -> Fixed { // TODO: get noise at percentile -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/types/fixed.cairo b/src/f128/types/fixed.cairo index e3f2bd7..983f9b8 100644 --- a/src/f128/types/fixed.cairo +++ b/src/f128/types/fixed.cairo @@ -92,16 +92,16 @@ impl FixedImpl of FixedTrait { } fn new_unscaled(mag: u128, sign: bool) -> Fixed { - return FixedTrait::new(mag * ONE_u128, sign); + return Self::new(mag * ONE_u128, sign); } fn from_felt(val: felt252) -> Fixed { let mag = core::integer::u128_try_from_felt252(utils::felt_abs(val)).unwrap(); - return FixedTrait::new(mag, utils::felt_sign(val)); + return Self::new(mag, utils::felt_sign(val)); } fn from_unscaled_felt(val: felt252) -> Fixed { - return FixedTrait::from_felt(val * ONE); + return Self::from_felt(val * ONE); } fn abs(self: Fixed) -> Fixed { @@ -424,12 +424,14 @@ impl FixedPartialEq of PartialEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedAdd of Add { fn add(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::add(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedAddEq of AddEq { #[inline(always)] fn add_eq(ref self: Fixed, other: Fixed) { @@ -437,12 +439,14 @@ impl FixedAddEq of AddEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedSub of Sub { fn sub(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::sub(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedSubEq of SubEq { #[inline(always)] fn sub_eq(ref self: Fixed, other: Fixed) { @@ -450,12 +454,14 @@ impl FixedSubEq of SubEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedMul of Mul { fn mul(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::mul(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedMulEq of MulEq { #[inline(always)] fn mul_eq(ref self: Fixed, other: Fixed) { @@ -463,12 +469,14 @@ impl FixedMulEq of MulEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedDiv of Div { fn div(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::div(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedDivEq of DivEq { #[inline(always)] fn div_eq(ref self: Fixed, other: Fixed) { @@ -551,7 +559,7 @@ impl FixedOne of core::num::traits::One { } #[inline(always)] fn is_one(self: @Fixed) -> bool { - *self == FixedOne::one() + *self == Self::one() } #[inline(always)] fn is_non_one(self: @Fixed) -> bool { @@ -560,7 +568,7 @@ impl FixedOne of core::num::traits::One { } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/types/vec2.cairo b/src/f128/types/vec2.cairo index c6892c2..a4a405c 100644 --- a/src/f128/types/vec2.cairo +++ b/src/f128/types/vec2.cairo @@ -135,7 +135,7 @@ fn sub(a: Vec2, b: Vec2) -> Vec2 { return Vec2 { x: a.x - b.x, y: a.y - b.y }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/types/vec3.cairo b/src/f128/types/vec3.cairo index 8b1e646..71d32f1 100644 --- a/src/f128/types/vec3.cairo +++ b/src/f128/types/vec3.cairo @@ -165,7 +165,7 @@ fn sub(a: Vec3, b: Vec3) -> Vec3 { return Vec3 { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f128/types/vec4.cairo b/src/f128/types/vec4.cairo index 2986a1e..304cd1a 100644 --- a/src/f128/types/vec4.cairo +++ b/src/f128/types/vec4.cairo @@ -167,7 +167,7 @@ fn sub(a: Vec4, b: Vec4) -> Vec4 { return Vec4 { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z, w: a.w - b.w }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/math/comp.cairo b/src/f64/math/comp.cairo index db7049c..8ba40d8 100644 --- a/src/f64/math/comp.cairo +++ b/src/f64/math/comp.cairo @@ -16,7 +16,7 @@ fn min(a: Fixed, b: Fixed) -> Fixed { } } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/math/hyp.cairo b/src/f64/math/hyp.cairo index 72c3b87..6d8c578 100644 --- a/src/f64/math/hyp.cairo +++ b/src/f64/math/hyp.cairo @@ -39,7 +39,7 @@ fn atanh(a: Fixed) -> Fixed { return ln_arg.ln() / FixedTrait::new(TWO, false); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/math/ops.cairo b/src/f64/math/ops.cairo index 48dce5d..ada3ca0 100644 --- a/src/f64/math/ops.cairo +++ b/src/f64/math/ops.cairo @@ -277,7 +277,7 @@ fn sub(a: Fixed, b: Fixed) -> Fixed { return add(a, -b); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/math/trig.cairo b/src/f64/math/trig.cairo index c2e28ba..2702165 100644 --- a/src/f64/math/trig.cairo +++ b/src/f64/math/trig.cairo @@ -199,7 +199,7 @@ fn _sin_loop(a: Fixed, i: u64, acc: Fixed) -> Fixed { return _sin_loop(a, i - 1, new_acc); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/procgen/rand.cairo b/src/f64/procgen/rand.cairo index baac913..ca7504b 100644 --- a/src/f64/procgen/rand.cairo +++ b/src/f64/procgen/rand.cairo @@ -47,7 +47,7 @@ fn _fixed_normal_between_loop( return _fixed_normal_between_loop(seed, low, high, acc + sample, iter - 1); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/procgen/simplex3.cairo b/src/f64/procgen/simplex3.cairo index 7319e5f..d0607bc 100644 --- a/src/f64/procgen/simplex3.cairo +++ b/src/f64/procgen/simplex3.cairo @@ -145,7 +145,7 @@ fn noise_octaves(v: Vec3, mut octaves: u64, persistence: Fixed) -> Fixed { // TODO: get noise at percentile -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/types/fixed.cairo b/src/f64/types/fixed.cairo index 5e4ef81..94b3bd6 100644 --- a/src/f64/types/fixed.cairo +++ b/src/f64/types/fixed.cairo @@ -93,11 +93,11 @@ impl FixedImpl of FixedTrait { fn from_felt(val: felt252) -> Fixed { let mag = core::integer::u64_try_from_felt252(utils::felt_abs(val)).unwrap(); - return FixedTrait::new(mag, utils::felt_sign(val)); + return Self::new(mag, utils::felt_sign(val)); } fn from_unscaled_felt(val: felt252) -> Fixed { - return FixedTrait::from_felt(val * ONE.into()); + return Self::from_felt(val * ONE.into()); } fn abs(self: Fixed) -> Fixed { @@ -423,12 +423,14 @@ impl FixedPartialEq of PartialEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedAdd of Add { fn add(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::add(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedAddEq of AddEq { #[inline(always)] fn add_eq(ref self: Fixed, other: Fixed) { @@ -436,12 +438,14 @@ impl FixedAddEq of AddEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedSub of Sub { fn sub(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::sub(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedSubEq of SubEq { #[inline(always)] fn sub_eq(ref self: Fixed, other: Fixed) { @@ -449,12 +453,14 @@ impl FixedSubEq of SubEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedMul of Mul { fn mul(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::mul(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedMulEq of MulEq { #[inline(always)] fn mul_eq(ref self: Fixed, other: Fixed) { @@ -462,12 +468,14 @@ impl FixedMulEq of MulEq { } } +#[feature("deprecated-op-assign-traits")] impl FixedDiv of Div { fn div(lhs: Fixed, rhs: Fixed) -> Fixed { return ops::div(lhs, rhs); } } +#[feature("deprecated-op-assign-traits")] impl FixedDivEq of DivEq { #[inline(always)] fn div_eq(ref self: Fixed, other: Fixed) { @@ -548,7 +556,7 @@ impl FixedOne of core::num::traits::One { } #[inline(always)] fn is_one(self: @Fixed) -> bool { - *self == FixedOne::one() + *self == Self::one() } #[inline(always)] fn is_non_one(self: @Fixed) -> bool { diff --git a/src/f64/types/vec2.cairo b/src/f64/types/vec2.cairo index 02fbfd2..ecf8228 100644 --- a/src/f64/types/vec2.cairo +++ b/src/f64/types/vec2.cairo @@ -135,7 +135,7 @@ fn sub(a: Vec2, b: Vec2) -> Vec2 { return Vec2 { x: a.x - b.x, y: a.y - b.y }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/types/vec3.cairo b/src/f64/types/vec3.cairo index ff4652e..a42e4fd 100644 --- a/src/f64/types/vec3.cairo +++ b/src/f64/types/vec3.cairo @@ -165,7 +165,7 @@ fn sub(a: Vec3, b: Vec3) -> Vec3 { return Vec3 { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/f64/types/vec4.cairo b/src/f64/types/vec4.cairo index f618027..2c7f7f9 100644 --- a/src/f64/types/vec4.cairo +++ b/src/f64/types/vec4.cairo @@ -167,7 +167,7 @@ fn sub(a: Vec4, b: Vec4) -> Vec4 { return Vec4 { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z, w: a.w - b.w }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/math/trig.cairo b/src/math/trig.cairo index 045b040..6ac764c 100644 --- a/src/math/trig.cairo +++ b/src/math/trig.cairo @@ -205,7 +205,7 @@ fn _sin_loop(a: Fixed, i: u128, acc: Fixed) -> Fixed { return _sin_loop(a, i - 1, new_acc); } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests { diff --git a/src/types/vec2.cairo b/src/types/vec2.cairo index 31eb72a..d96f4b1 100644 --- a/src/types/vec2.cairo +++ b/src/types/vec2.cairo @@ -135,7 +135,7 @@ fn sub(a: Vec2, b: Vec2) -> Vec2 { return Vec2 { x: a.x - b.x, y: a.y - b.y }; } -// Tests -------------------------------------------------------------------------------------------------------------- +// Tests #[cfg(test)] mod tests {