From d8061f1ed080730fbb540b23a7e3164fdc0efe7e Mon Sep 17 00:00:00 2001 From: lcnbr Date: Mon, 5 Aug 2024 14:08:30 +0200 Subject: [PATCH] fix(symbolica): :ambulance: update symbolica --- Cargo.lock | 67 +++++++++++++++++++++--------------------------- Cargo.toml | 4 +-- src/integrate.rs | 10 ++++---- src/linalg.rs | 2 +- src/momentum.rs | 4 +-- src/utils.rs | 60 +++++++++++++++++++++++++------------------ 6 files changed, 73 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0022751..6b7e17ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,7 +28,7 @@ dependencies = [ "once_cell", "serde", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -1165,9 +1165,9 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "inferno" -version = "0.11.20" +version = "0.11.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c77a3ae7d4761b9c64d2c030f70746ceb8cfba32dce0325a56792e0a4816c31" +checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" dependencies = [ "ahash", "indexmap", @@ -1773,11 +1773,11 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -2033,9 +2033,9 @@ checksum = "a743269eaa4c6f18021903a3627f6031b4ae3e2dddda3c5ab8d7a8c7e723d103" [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2062,9 +2062,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rgb" -version = "0.8.45" +version = "0.8.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade4539f42266ded9e755c605bdddf546242b2c961b03b06a7375260788a0523" +checksum = "e12bc8d2f72df26a5d3178022df33720fbede0d31d82c7291662eff89836994d" dependencies = [ "bytemuck", ] @@ -2285,7 +2285,7 @@ dependencies = [ [[package]] name = "spenso" version = "0.2.0" -source = "git+https://github.com/alphal00p/spenso?branch=master#3eefaadfe977ab6bbd77ff9bd10df5c76972cd14" +source = "git+https://github.com/alphal00p/spenso?branch=master#5f7f2b0450d560babfb55d5a17155f0b77335948" dependencies = [ "ahash", "ambassador", @@ -2395,6 +2395,7 @@ dependencies = [ "dyn-clone", "libloading", "once_cell", + "pyo3-build-config 0.22.2", "rand", "rand_xoshiro", "rayon", @@ -2465,12 +2466,13 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -2778,11 +2780,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2818,6 +2820,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -2966,34 +2977,14 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", + "byteorder", + "zerocopy-derive", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8ffaabce..8ab55955 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,7 +132,5 @@ similar.opt-level = 3 [patch.crates-io] symbolica = { path = "./python/gammaloop/dependencies/symbolica" } -spenso = { git = "https://github.com/alphal00p/spenso", branch = "master", features = [ - "shadowing", -] } +spenso = { git = "https://github.com/alphal00p/spenso", branch = "master"} # spenso = { path = "../spenso" } diff --git a/src/integrate.rs b/src/integrate.rs index 8c7df277..26f576b8 100644 --- a/src/integrate.rs +++ b/src/integrate.rs @@ -9,7 +9,7 @@ use itertools::Itertools; use serde::Deserialize; use serde::Serialize; use symbolica::domains::float::ConstructibleFloat; -use symbolica::domains::float::NumericalFloatComparison; +use symbolica::domains::float::SingleFloat; use symbolica::domains::float::Real; use symbolica::numerical_integration::{Grid, MonteCarloRng, Sample, StatisticsAccumulator}; @@ -253,7 +253,7 @@ where .integral .max_eval_positive .abs() - .max(&integration_state.integral.max_eval_negative.abs()); + .max(integration_state.integral.max_eval_negative.abs()); user_data.integrand[..cores] .par_iter_mut() @@ -344,7 +344,7 @@ where err_perc: format!( "{:.3e}%", (integration_state.integral.err - / (integration_state.integral.avg.abs()).max(&F(1.0e-99))) + / (integration_state.integral.avg.abs()).max(F(1.0e-99))) .abs() * F(100.) ), @@ -373,7 +373,7 @@ where err: format!("{:.8e}", b.accumulator.err), err_perc: format!( "{:.3e}%", - (b.accumulator.err / (b.accumulator.avg.abs()).max(&F(1.0e-99))).abs() + (b.accumulator.err / (b.accumulator.avg.abs()).max(F(1.0e-99))).abs() * F(100.) ), pdf: format!("{:.8e}", b.pdf), @@ -1155,7 +1155,7 @@ pub fn print_integral_result( let mwi = itg .max_eval_negative .abs() - .max(&itg.max_eval_positive.abs()) + .max(itg.max_eval_positive.abs()) / (itg.avg.abs() * (F::::new_from_usize(itg.processed_samples))); if mwi > F(1.) { format!(" mwi: {:<10.4e}", mwi.0).red() diff --git a/src/linalg.rs b/src/linalg.rs index 621b5206..86a9644c 100644 --- a/src/linalg.rs +++ b/src/linalg.rs @@ -1,7 +1,7 @@ use color_eyre::Report; use smallvec::SmallVec; use std::ops::{Add, Index, IndexMut, Mul, Sub}; -use symbolica::domains::float::{NumericalFloatComparison, NumericalFloatLike, Real}; +use symbolica::domains::float::{SingleFloat, NumericalFloatLike, Real}; use crate::utils::{FloatLike, F}; diff --git a/src/momentum.rs b/src/momentum.rs index fbd13db0..cffc2e44 100644 --- a/src/momentum.rs +++ b/src/momentum.rs @@ -20,7 +20,7 @@ use symbolica::{ atom::{Atom, Symbol}, coefficient::Coefficient, domains::{ - float::{NumericalFloatComparison, NumericalFloatLike, Real}, + float::{NumericalFloatLike, Real, RealNumberLike, SingleFloat}, integer::IntegerRing, rational::RationalField, }, @@ -1157,7 +1157,7 @@ impl FourMomentum { pub fn boost(&self, boost_vector: &FourMomentum) -> FourMomentum where - T: Real + NumericalFloatComparison, + T: Real + SingleFloat+PartialOrd, { let b2 = boost_vector.spatial.norm_squared(); let one = b2.one(); diff --git a/src/utils.rs b/src/utils.rs index 561a3847..a638eae3 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -15,7 +15,7 @@ use rug::Float; use serde::{Deserialize, Serialize}; use spenso::{contraction::{RefOne, RefZero},upgrading_arithmetic:: TrySmallestUpgrade,complex::{R,Complex}}; use symbolica::domains::float::{ - ConstructibleFloat, NumericalFloatComparison, NumericalFloatLike, + ConstructibleFloat, RealNumberLike, NumericalFloatLike, SingleFloat, }; use symbolica::evaluate::CompiledEvaluatorFloat; @@ -421,7 +421,7 @@ impl NumericalFloatLike for VarFloat{ } -impl NumericalFloatComparison for VarFloat { +impl SingleFloat for VarFloat { fn is_finite(&self) -> bool { self.float.is_finite() } @@ -434,14 +434,9 @@ impl NumericalFloatComparison for VarFloat { self.float == 0. } - fn max(&self, other: &Self) -> Self { - if self.float > other.float { - self.clone() - } else { - other.clone() - } - } +} +impl RealNumberLike for VarFloat{ fn to_f64(&self) -> f64 { self.float.to_f64() } @@ -634,7 +629,8 @@ pub trait PrecisionUpgradable { pub trait FloatLike: Real +R - + NumericalFloatComparison + + PartialOrd + + RealNumberLike + for<'a> RefAdd<&'a Self, Output = Self> // + for<'a> RefMutAdd<&'a Self, Output = Self> + RefAdd @@ -729,6 +725,26 @@ pub struct F(pub T); impl R for F {} +impl RealNumberLike for F{ + delegate!{ + to self.0{ + fn to_usize_clamped(&self)->usize; + fn to_f64(&self)->f64; + } + } + +} + +impl SingleFloat for F{ + delegate!{ + to self.0{ + fn is_zero(&self)->bool; + fn is_one(&self)->bool; + fn is_finite(&self)->bool; + } + } +} + impl PrecisionUpgradable for F where T::Higher: FloatLike, T::Lower: FloatLike{ type Higher = F; type Lower = F; @@ -837,21 +853,7 @@ impl ConstructibleFloat for F { } } -impl NumericalFloatComparison for F { - fn max(&self, other: &Self) -> Self { - F(self.0.max(&other.0)) - } - delegate! { - #[into] - to self.0{ - fn is_zero(&self) -> bool; - fn is_one(&self) -> bool; - fn is_finite(&self) -> bool; - fn to_usize_clamped(&self) -> usize; - fn to_f64(&self) -> f64; - } - } -} + impl Real for F { fn atan2(&self, x: &Self) -> Self { @@ -893,6 +895,14 @@ use delegate::delegate; impl F { + pub fn max(self,other:F)->F{ + if self < other { + other + } else { + self + } + } + pub fn negate(&mut self) { self.0 = -self.0.clone(); }