Skip to content

Commit

Permalink
fix(symbolica): 🚑 update symbolica
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnbr committed Aug 5, 2024
1 parent 01f341b commit d8061f1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 74 deletions.
67 changes: 29 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
10 changes: 5 additions & 5 deletions src/integrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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.)
),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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::<f64>::new_from_usize(itg.processed_samples)));
if mwi > F(1.) {
format!(" mwi: {:<10.4e}", mwi.0).red()
Expand Down
2 changes: 1 addition & 1 deletion src/linalg.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
4 changes: 2 additions & 2 deletions src/momentum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -1157,7 +1157,7 @@ impl<T> FourMomentum<T, T> {

pub fn boost(&self, boost_vector: &FourMomentum<T>) -> FourMomentum<T>
where
T: Real + NumericalFloatComparison,
T: Real + SingleFloat+PartialOrd,
{
let b2 = boost_vector.spatial.norm_squared();
let one = b2.one();
Expand Down
60 changes: 35 additions & 25 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -421,7 +421,7 @@ impl<const N:u32> NumericalFloatLike for VarFloat<N>{

}

impl<const N:u32> NumericalFloatComparison for VarFloat<N> {
impl<const N:u32> SingleFloat for VarFloat<N> {
fn is_finite(&self) -> bool {
self.float.is_finite()
}
Expand All @@ -434,14 +434,9 @@ impl<const N:u32> NumericalFloatComparison for VarFloat<N> {
self.float == 0.
}

fn max(&self, other: &Self) -> Self {
if self.float > other.float {
self.clone()
} else {
other.clone()
}
}

}
impl<const N:u32> RealNumberLike for VarFloat<N>{
fn to_f64(&self) -> f64 {
self.float.to_f64()
}
Expand Down Expand Up @@ -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<Self, Output = Self>
Expand Down Expand Up @@ -729,6 +725,26 @@ pub struct F<T: FloatLike>(pub T);

impl<T:FloatLike> R for F<T> {}

impl<T:FloatLike> RealNumberLike for F<T>{
delegate!{
to self.0{
fn to_usize_clamped(&self)->usize;
fn to_f64(&self)->f64;
}
}

}

impl<T:FloatLike> SingleFloat for F<T>{
delegate!{
to self.0{
fn is_zero(&self)->bool;
fn is_one(&self)->bool;
fn is_finite(&self)->bool;
}
}
}

impl<T: FloatLike> PrecisionUpgradable for F<T> where T::Higher: FloatLike, T::Lower: FloatLike{
type Higher = F<T::Higher>;
type Lower = F<T::Lower>;
Expand Down Expand Up @@ -837,21 +853,7 @@ impl<T: FloatLike + ConstructibleFloat> ConstructibleFloat for F<T> {
}
}

impl<T: FloatLike> NumericalFloatComparison for F<T> {
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<T: FloatLike> Real for F<T> {
fn atan2(&self, x: &Self) -> Self {
Expand Down Expand Up @@ -893,6 +895,14 @@ use delegate::delegate;

impl<T: FloatLike> F<T> {

pub fn max(self,other:F<T>)->F<T>{
if self < other {
other
} else {
self
}
}

pub fn negate(&mut self) {
self.0 = -self.0.clone();
}
Expand Down

0 comments on commit d8061f1

Please sign in to comment.