diff --git a/examples/builder.rs b/examples/builder.rs index 82a5c153..a43663cb 100644 --- a/examples/builder.rs +++ b/examples/builder.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::{Atom, FunctionBuilder}, fun, - representations::{Atom, FunctionBuilder}, state::State, }; diff --git a/examples/coefficient_ring.rs b/examples/coefficient_ring.rs index 3f0ae6e3..146598e6 100644 --- a/examples/coefficient_ring.rs +++ b/examples/coefficient_ring.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use symbolica::{representations::Atom, state::State}; +use symbolica::{atom::Atom, state::State}; fn main() { let expr = Atom::parse("x*z+x*(y+2)^-1*(y+z+1)").unwrap(); diff --git a/examples/collect.rs b/examples/collect.rs index 5964a001..245603fb 100644 --- a/examples/collect.rs +++ b/examples/collect.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::{Atom, FunctionBuilder}, fun, - representations::{Atom, FunctionBuilder}, state::State, }; diff --git a/examples/derivative.rs b/examples/derivative.rs index 27ff5005..1a41f2a2 100644 --- a/examples/derivative.rs +++ b/examples/derivative.rs @@ -1,4 +1,4 @@ -use symbolica::{representations::Atom, state::State}; +use symbolica::{atom::Atom, state::State}; fn main() { let x = State::get_symbol("x"); diff --git a/examples/evaluate.rs b/examples/evaluate.rs index af57cbd5..a83cfdee 100644 --- a/examples/evaluate.rs +++ b/examples/evaluate.rs @@ -1,6 +1,6 @@ use ahash::HashMap; use symbolica::evaluate::EvaluationFn; -use symbolica::{representations::Atom, state::State}; +use symbolica::{atom::Atom, state::State}; fn main() { let x = State::get_symbol("x"); diff --git a/examples/expansion.rs b/examples/expansion.rs index baf746d3..45f2f543 100644 --- a/examples/expansion.rs +++ b/examples/expansion.rs @@ -1,4 +1,4 @@ -use symbolica::representations::Atom; +use symbolica::atom::Atom; fn main() { let input = Atom::parse("(1+x)^3").unwrap(); diff --git a/examples/factorization.rs b/examples/factorization.rs index 400f9d65..19641ccb 100644 --- a/examples/factorization.rs +++ b/examples/factorization.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use symbolica::{ + atom::Atom, domains::{finite_field::Zp, integer::Z}, poly::{factor::Factorize, polynomial::MultivariatePolynomial, Variable}, - representations::Atom, state::State, }; diff --git a/examples/fibonacci.rs b/examples/fibonacci.rs index 0c9e4f89..06efadfe 100644 --- a/examples/fibonacci.rs +++ b/examples/fibonacci.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::{Atom, AtomView}, id::{Match, Pattern, PatternRestriction}, - representations::{Atom, AtomView}, state::{RecycledAtom, State}, }; diff --git a/examples/groebner_basis.rs b/examples/groebner_basis.rs index 7cacfccc..cd87f8a3 100644 --- a/examples/groebner_basis.rs +++ b/examples/groebner_basis.rs @@ -1,7 +1,7 @@ use symbolica::{ + atom::Atom, domains::finite_field::Zp, poly::{groebner::GroebnerBasis, polynomial::MultivariatePolynomial, GrevLexOrder}, - representations::Atom, state::State, }; diff --git a/examples/optimize.rs b/examples/optimize.rs index 9a3519ff..de4996b4 100644 --- a/examples/optimize.rs +++ b/examples/optimize.rs @@ -1,7 +1,7 @@ use symbolica::{ + atom::Atom, domains::rational::Q, poly::evaluate::{BorrowedHornerScheme, InstructionSetPrinter}, - representations::Atom, }; use symbolica::poly::polynomial::MultivariatePolynomial; diff --git a/examples/optimize_multiple.rs b/examples/optimize_multiple.rs index 0fc5be66..a0b063c6 100644 --- a/examples/optimize_multiple.rs +++ b/examples/optimize_multiple.rs @@ -1,7 +1,7 @@ use symbolica::{ + atom::Atom, domains::rational::{Rational, Q}, poly::evaluate::{HornerScheme, InstructionSetPrinter}, - representations::Atom, }; use symbolica::poly::polynomial::MultivariatePolynomial; diff --git a/examples/partition.rs b/examples/partition.rs index d8ef27aa..251e2c65 100644 --- a/examples/partition.rs +++ b/examples/partition.rs @@ -1,4 +1,4 @@ -use symbolica::{id::Pattern, representations::Atom, state::State, transformer::Transformer}; +use symbolica::{atom::Atom, id::Pattern, state::State, transformer::Transformer}; fn main() { let input = Atom::parse("f(1,3,2,3,1)").unwrap(); diff --git a/examples/pattern_match.rs b/examples/pattern_match.rs index 9e153298..98af7a05 100644 --- a/examples/pattern_match.rs +++ b/examples/pattern_match.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::Atom, id::{Condition, Match, MatchSettings}, - representations::Atom, state::State, }; diff --git a/examples/pattern_restrictions.rs b/examples/pattern_restrictions.rs index 38c1d9db..7112dc84 100644 --- a/examples/pattern_restrictions.rs +++ b/examples/pattern_restrictions.rs @@ -1,8 +1,8 @@ use symbolica::{ + atom::{Atom, AtomView}, coefficient::CoefficientView, domains::finite_field, id::{Condition, Match, MatchSettings, PatternRestriction}, - representations::{Atom, AtomView}, state::State, }; fn main() { diff --git a/examples/polynomial_gcd.rs b/examples/polynomial_gcd.rs index 7711255d..8604d091 100644 --- a/examples/polynomial_gcd.rs +++ b/examples/polynomial_gcd.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::Atom, domains::{integer::Z, rational::Q}, - representations::Atom, }; use tracing_subscriber::{fmt, prelude::*, util::SubscriberInitExt, EnvFilter}; diff --git a/examples/rational_polynomial.rs b/examples/rational_polynomial.rs index eaa3bade..5cad80c4 100644 --- a/examples/rational_polynomial.rs +++ b/examples/rational_polynomial.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::Atom, domains::{integer::Z, rational_polynomial::RationalPolynomial}, - representations::Atom, }; fn main() { diff --git a/examples/replace_all.rs b/examples/replace_all.rs index 270145af..b3c8f903 100644 --- a/examples/replace_all.rs +++ b/examples/replace_all.rs @@ -1,4 +1,4 @@ -use symbolica::{id::Pattern, representations::Atom}; +use symbolica::{atom::Atom, id::Pattern}; fn main() { let expr = Atom::parse(" f(1,2,x) + f(1,2,3)").unwrap(); diff --git a/examples/replace_once.rs b/examples/replace_once.rs index d2221b92..5bf8c860 100644 --- a/examples/replace_once.rs +++ b/examples/replace_once.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::Atom, id::{Condition, MatchSettings}, - representations::Atom, }; fn main() { diff --git a/examples/solve_linear_system.rs b/examples/solve_linear_system.rs index 74baf491..7b752c5b 100644 --- a/examples/solve_linear_system.rs +++ b/examples/solve_linear_system.rs @@ -1,13 +1,13 @@ use std::sync::Arc; use symbolica::{ + atom::{Atom, AtomView}, domains::{ integer::Z, rational::Q, rational_polynomial::{RationalPolynomial, RationalPolynomialField}, }, poly::Variable, - representations::{Atom, AtomView}, state::State, tensors::matrix::Matrix, }; diff --git a/examples/streaming.rs b/examples/streaming.rs index 9aeeeb42..51266960 100644 --- a/examples/streaming.rs +++ b/examples/streaming.rs @@ -1,4 +1,4 @@ -use symbolica::{id::Pattern, representations::Atom, streaming::TermStreamer}; +use symbolica::{atom::Atom, id::Pattern, streaming::TermStreamer}; fn main() { let input = Atom::parse("x+ f(x) + 2*f(y) + 7*f(z)").unwrap(); diff --git a/examples/taylor_series.rs b/examples/taylor_series.rs index 7cf7d9e5..a0c3ffe5 100644 --- a/examples/taylor_series.rs +++ b/examples/taylor_series.rs @@ -1,4 +1,4 @@ -use symbolica::{representations::Atom, state::State}; +use symbolica::{atom::Atom, state::State}; fn main() { let x = State::get_symbol("x"); diff --git a/examples/tree_replace.rs b/examples/tree_replace.rs index f827a2b0..270bc34a 100644 --- a/examples/tree_replace.rs +++ b/examples/tree_replace.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::Atom, id::{Condition, Match, MatchSettings, PatternAtomTreeIterator}, - representations::Atom, state::State, }; diff --git a/examples/tree_walk.rs b/examples/tree_walk.rs index ac20c84a..35c63cae 100644 --- a/examples/tree_walk.rs +++ b/examples/tree_walk.rs @@ -1,4 +1,7 @@ -use symbolica::{id::{AtomTreeIterator, MatchSettings}, representations::Atom}; +use symbolica::{ + atom::Atom, + id::{AtomTreeIterator, MatchSettings}, +}; fn main() { let expr: Atom = Atom::parse("f(z)*f(f(x),z)*f(y)").unwrap(); diff --git a/src/api/python.rs b/src/api/python.rs index 1c9fa33f..1f067137 100644 --- a/src/api/python.rs +++ b/src/api/python.rs @@ -20,6 +20,7 @@ use smallvec::SmallVec; use smartstring::{LazyCompact, SmartString}; use crate::{ + atom::{Atom, AtomView, ListIterator, Symbol}, domains::{ finite_field::{ToFiniteField, Zp}, float::Complex, @@ -50,7 +51,6 @@ use crate::{ printer::{ AtomPrinter, MatrixPrinter, PolynomialPrinter, PrintOptions, RationalPolynomialPrinter, }, - representations::{Atom, AtomView, ListIterator, Symbol}, state::{FunctionAttribute, RecycledAtom, State, Workspace}, streaming::TermStreamer, tensors::matrix::Matrix, diff --git a/src/representations.rs b/src/atom.rs similarity index 99% rename from src/representations.rs rename to src/atom.rs index 450e4621..fc487e4e 100644 --- a/src/representations.rs +++ b/src/atom.rs @@ -1,5 +1,5 @@ mod coefficient; -pub mod default; +pub mod representation; use crate::{ coefficient::Coefficient, @@ -9,11 +9,11 @@ use crate::{ }; use std::{cmp::Ordering, hash::Hash, ops::DerefMut}; -pub use self::default::{ +pub use self::representation::{ Add, AddView, Fun, ListIterator, ListSlice, Mul, MulView, Num, NumView, Pow, PowView, Var, VarView, }; -use self::default::{FunView, RawAtom}; +use self::representation::{FunView, RawAtom}; /// A symbol, for example the name of a variable or the name of a function, /// together with its properties. @@ -564,7 +564,7 @@ impl Atom { /// For example: /// ``` /// # use symbolica::{ -/// # representations::{Atom, AsAtomView, FunctionBuilder}, +/// # atom::{Atom, AsAtomView, FunctionBuilder}, /// # state::{FunctionAttribute, State}, /// # }; /// # fn main() { @@ -1040,8 +1040,8 @@ impl> std::ops::Div for Atom { #[cfg(test)] mod test { use crate::{ + atom::{Atom, FunctionBuilder}, fun, - representations::{Atom, FunctionBuilder}, state::State, }; diff --git a/src/representations/coefficient.rs b/src/atom/coefficient.rs similarity index 100% rename from src/representations/coefficient.rs rename to src/atom/coefficient.rs diff --git a/src/representations/default.rs b/src/atom/representation.rs similarity index 100% rename from src/representations/default.rs rename to src/atom/representation.rs diff --git a/src/coefficient.rs b/src/coefficient.rs index 809e8f54..1c107c8a 100644 --- a/src/coefficient.rs +++ b/src/coefficient.rs @@ -13,6 +13,7 @@ use rug::{ use smallvec::{smallvec, SmallVec}; use crate::{ + atom::{Atom, AtomView}, domains::{ finite_field::{ FiniteField, FiniteFieldCore, FiniteFieldElement, FiniteFieldWorkspace, ToFiniteField, @@ -23,7 +24,6 @@ use crate::{ EuclideanDomain, Field, Ring, }, poly::{polynomial::MultivariatePolynomial, Variable, INLINED_EXPONENTS}, - representations::{Atom, AtomView}, state::{FiniteFieldIndex, State, Workspace}, }; @@ -892,7 +892,7 @@ impl<'a> AtomView<'a> { mod test { use std::sync::Arc; - use crate::{domains::rational::Rational, representations::Atom, state::State}; + use crate::{atom::Atom, domains::rational::Rational, state::State}; #[test] fn coefficient_ring() { diff --git a/src/collect.rs b/src/collect.rs index bef4d5e6..a555c4d7 100644 --- a/src/collect.rs +++ b/src/collect.rs @@ -1,8 +1,8 @@ use ahash::HashMap; use crate::{ + atom::{Add, AsAtomView, Atom, AtomView, Symbol}, domains::{integer::Z, rational::Q}, - representations::{Add, AsAtomView, Atom, AtomView, Symbol}, state::Workspace, }; @@ -400,8 +400,8 @@ impl<'a> AtomView<'a> { #[cfg(test)] mod test { use crate::{ + atom::{Atom, FunctionBuilder}, fun, - representations::{Atom, FunctionBuilder}, state::State, }; diff --git a/src/derivative.rs b/src/derivative.rs index 08e7d293..f63af539 100644 --- a/src/derivative.rs +++ b/src/derivative.rs @@ -1,9 +1,9 @@ use std::ops::DerefMut; use crate::{ + atom::{Atom, AtomView, Symbol}, coefficient::Coefficient, domains::integer::Integer, - representations::{Atom, AtomView, Symbol}, state::{State, Workspace}, }; @@ -453,7 +453,7 @@ impl<'a> AtomView<'a> { #[cfg(test)] mod test { - use crate::{representations::Atom, state::State}; + use crate::{atom::Atom, state::State}; #[test] fn derivative() { diff --git a/src/domains/algebraic_number.rs b/src/domains/algebraic_number.rs index 9a946705..68a5e2dd 100644 --- a/src/domains/algebraic_number.rs +++ b/src/domains/algebraic_number.rs @@ -278,9 +278,9 @@ impl> Field for AlgebraicNumberRing { #[cfg(test)] mod tests { + use crate::atom::Atom; use crate::domains::algebraic_number::AlgebraicNumberRing; use crate::domains::rational::Q; - use crate::representations::Atom; #[test] fn gcd_number_field() -> Result<(), String> { diff --git a/src/domains/rational_polynomial.rs b/src/domains/rational_polynomial.rs index e154aa74..854101d7 100644 --- a/src/domains/rational_polynomial.rs +++ b/src/domains/rational_polynomial.rs @@ -1112,7 +1112,7 @@ mod test { #[test] fn hermite_reduction() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse("1/(v1 + 1)^5") .unwrap() .to_rational_polynomial::<_, _, u8>(&Q, &Z, None); @@ -1130,7 +1130,7 @@ mod test { #[test] fn constant() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse("(v1^4+v2+v1*v2+2*v1)/(v2 + 1)") .unwrap() .to_rational_polynomial::<_, _, u8>( @@ -1160,7 +1160,7 @@ mod test { #[test] fn mixed_denominator() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse("(v1^4+v2+v1*v2+2*v1)/(v1)/(v2 + 1)") .unwrap() .to_rational_polynomial::<_, _, u8>( @@ -1197,7 +1197,7 @@ mod test { #[test] fn three_factors() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse("(36v1^2+1167v1+3549/2)/(v1^3+23/30v1^2-2/15v1-2/15)") .unwrap() @@ -1241,7 +1241,7 @@ mod test { #[test] fn multiple_residues() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse( "(7v1^13+10v1^8+4v1^7-7v1^6-4v1^3-4v1^2+3v1+3)/(v1^14-2v1^8-2v1^7-2v1^4-4v1^3-v1^2+2v1+1)", ) @@ -1278,7 +1278,7 @@ mod test { #[test] fn multi_factor() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse("1/(v1^3+v1)") .unwrap() .to_rational_polynomial::<_, _, u8>(&Q, &Z, None); @@ -1313,7 +1313,7 @@ mod test { #[test] fn multiple_variables() { - use crate::representations::Atom; + use crate::atom::Atom; let p: RationalPolynomial<_, _> = Atom::parse("(v1^4+v2+v1*v2+2*v1)/((v1-v2)(v1-2)(v1-4))") .unwrap() .to_rational_polynomial::<_, _, u8>(&Q, &Z, None); diff --git a/src/evaluate.rs b/src/evaluate.rs index f7c05038..49456c7d 100644 --- a/src/evaluate.rs +++ b/src/evaluate.rs @@ -1,9 +1,9 @@ use ahash::HashMap; use crate::{ + atom::{Atom, AtomView, Symbol}, coefficient::CoefficientView, domains::{float::Real, rational::Rational}, - representations::{Atom, AtomView, Symbol}, state::State, }; @@ -151,7 +151,7 @@ impl<'a> AtomView<'a> { mod test { use ahash::HashMap; - use crate::{evaluate::EvaluationFn, representations::Atom, state::State}; + use crate::{atom::Atom, evaluate::EvaluationFn, state::State}; #[test] fn evaluate() { diff --git a/src/expand.rs b/src/expand.rs index aabf9905..d7a043d4 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -3,10 +3,10 @@ use std::ops::DerefMut; use smallvec::SmallVec; use crate::{ + atom::{Atom, AtomView}, coefficient::CoefficientView, combinatorics::CombinationWithReplacementIterator, domains::integer::Integer, - representations::{Atom, AtomView}, state::{RecycledAtom, Workspace}, }; @@ -150,7 +150,11 @@ impl<'a> AtomView<'a> { let mul = mul_h.to_mul(); let mut exp_h = workspace.new_atom(); - exp_h.to_num((num as i64).into()); + if negative { + exp_h.to_num((-(num as i64)).into()); + } else { + exp_h.to_num((num as i64).into()); + } for arg in m.iter() { let mut pow_h = workspace.new_atom(); @@ -158,16 +162,8 @@ impl<'a> AtomView<'a> { mul.extend(pow_h.as_view()); } - if negative { - let mut num_h = workspace.new_atom(); - num_h.to_num((-1).into()); + mul_h.as_view().normalize(workspace, out); - let mut pow_h = workspace.new_atom(); - pow_h.to_pow(mul_h.as_view(), num_h.as_view()); - pow_h.as_view().normalize(workspace, out); - } else { - mul_h.as_view().normalize(workspace, out); - } true } else { let mut pow_h = workspace.new_atom(); @@ -276,7 +272,7 @@ impl<'a> AtomView<'a> { #[cfg(test)] mod test { - use crate::representations::Atom; + use crate::atom::Atom; #[test] fn exponent() { @@ -302,7 +298,7 @@ mod test { #[test] fn mul_pow_neg() { let exp = Atom::parse("(v1*v2*2)^-3").unwrap().expand(); - let res = Atom::parse("(8*v1^3*v2^3)^-1").unwrap(); + let res = Atom::parse("8^-1*v1^-3*v2^-3").unwrap(); assert_eq!(exp, res); } } diff --git a/src/id.rs b/src/id.rs index 11c4e8da..4c74eb38 100644 --- a/src/id.rs +++ b/src/id.rs @@ -2,7 +2,7 @@ use ahash::HashSet; use dyn_clone::DynClone; use crate::{ - representations::{default::ListSlice, Atom, AtomView, Num, SliceType, Symbol}, + atom::{representation::ListSlice, Atom, AtomView, Num, SliceType, Symbol}, state::{State, Workspace}, transformer::{Transformer, TransformerError}, }; @@ -2438,3 +2438,21 @@ impl<'a: 'b, 'b> ReplaceIterator<'a, 'b> { } } } + +#[cfg(test)] +mod test { + use crate::atom::Atom; + + use super::Pattern; + + #[test] + fn overlap() { + let a = Atom::parse("(x*(y+y^2+1)+y^2 + y)").unwrap(); + let p = Pattern::parse("y+y^x_").unwrap(); + let rhs = Pattern::parse("y*(1+y^(x_-1))").unwrap(); + + let r = p.replace_all(a.as_view(), &rhs, None, None); + let res = Atom::parse("x*(y+y^2+1)+y*(y+1)").unwrap(); + assert_eq!(r, res); + } +} diff --git a/src/lib.rs b/src/lib.rs index 2969d74e..84dbddce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ //! For example: //! //! ``` -//! use symbolica::{representations::Atom, state::State}; +//! use symbolica::{atom::Atom, state::State}; //! //! fn main() { //! let input = Atom::parse("x^2*log(2*x + y) + exp(3*x)").unwrap(); @@ -34,6 +34,7 @@ use once_cell::sync::OnceCell; use tinyjson::JsonValue; pub mod api; +pub mod atom; pub mod coefficient; pub mod collect; pub mod combinatorics; @@ -47,7 +48,6 @@ pub mod numerical_integration; pub mod parser; pub mod poly; pub mod printer; -pub mod representations; pub mod solve; pub mod state; pub mod streaming; diff --git a/src/normalize.rs b/src/normalize.rs index 571e0a12..7e62a931 100644 --- a/src/normalize.rs +++ b/src/normalize.rs @@ -3,10 +3,10 @@ use std::{cmp::Ordering, ops::DerefMut}; use smallvec::SmallVec; use crate::{ + atom::{Atom, AtomView, Fun, Symbol}, coefficient::{Coefficient, CoefficientView}, domains::{integer::Z, rational::Q}, poly::Variable, - representations::{Atom, AtomView, Fun, Symbol}, state::{RecycledAtom, State, Workspace}, }; @@ -1133,7 +1133,7 @@ impl<'a> AtomView<'a> { #[cfg(test)] mod test { - use crate::{representations::Atom, state::State}; + use crate::{atom::Atom, state::State}; #[test] fn linear_symmetric() { diff --git a/src/parser.rs b/src/parser.rs index a3dcb223..2465edfa 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -7,10 +7,10 @@ use smallvec::SmallVec; use smartstring::{LazyCompact, SmartString}; use crate::{ + atom::Atom, coefficient::ConvertToRing, domains::{integer::Integer, Ring}, poly::{polynomial::MultivariatePolynomial, Exponent, Variable}, - representations::Atom, state::{State, Workspace}, }; @@ -1165,7 +1165,7 @@ impl Token { mod test { use std::sync::Arc; - use crate::{domains::integer::Z, parser::Token, representations::Atom, state::State}; + use crate::{atom::Atom, domains::integer::Z, parser::Token, state::State}; #[test] fn pow() { diff --git a/src/poly.rs b/src/poly.rs index 10c5d08f..5ac36c93 100644 --- a/src/poly.rs +++ b/src/poly.rs @@ -18,6 +18,7 @@ use ahash::HashMap; use smallvec::{smallvec, SmallVec}; use smartstring::{LazyCompact, SmartString}; +use crate::atom::{Atom, AtomView, Symbol}; use crate::coefficient::{Coefficient, CoefficientView, ConvertToRing}; use crate::domains::factorized_rational_polynomial::{ FactorizedRationalPolynomial, FromNumeratorAndFactorizedDenominator, @@ -26,7 +27,6 @@ use crate::domains::integer::Integer; use crate::domains::rational_polynomial::{FromNumeratorAndDenominator, RationalPolynomial}; use crate::domains::{EuclideanDomain, Ring}; use crate::parser::{Operator, Token}; -use crate::representations::{Atom, AtomView, Symbol}; use crate::state::{State, Workspace}; use crate::utils; diff --git a/src/poly/evaluate.rs b/src/poly/evaluate.rs index 03982604..24edb0c7 100644 --- a/src/poly/evaluate.rs +++ b/src/poly/evaluate.rs @@ -7,19 +7,19 @@ use ahash::{AHasher, HashMap, HashSet, HashSetExt}; use rand::{thread_rng, Rng}; use crate::{ + atom::Symbol, coefficient::CoefficientView, domains::{ float::NumericalFloatLike, rational::{Rational, RationalField, Q}, EuclideanDomain, }, - representations::Symbol, state::Workspace, }; use crate::{ + atom::{Atom, AtomView}, domains::{float::Real, Ring}, evaluate::EvaluationFn, - representations::{Atom, AtomView}, state::State, }; @@ -1893,12 +1893,12 @@ auto 𝑖 = 1i;\n", #[cfg(test)] mod test { use crate::{ + atom::Atom, domains::{float::Complex, rational::Q}, poly::{ evaluate::{BorrowedHornerScheme, InstructionSetPrinter}, polynomial::MultivariatePolynomial, }, - representations::Atom, }; use wide::f64x4; diff --git a/src/poly/factor.rs b/src/poly/factor.rs index 4b5ede98..2dc0689b 100644 --- a/src/poly/factor.rs +++ b/src/poly/factor.rs @@ -3098,9 +3098,9 @@ impl MultivariatePolynomial, E, LexOrder> { #[cfg(test)] mod test { use crate::{ + atom::Atom, domains::{finite_field::Zp, integer::Z}, poly::factor::Factorize, - representations::Atom, }; #[test] diff --git a/src/poly/groebner.rs b/src/poly/groebner.rs index b2cf42a7..47129c0e 100644 --- a/src/poly/groebner.rs +++ b/src/poly/groebner.rs @@ -929,9 +929,9 @@ echelonize_impl!(RationalField); #[cfg(test)] mod test { use crate::{ + atom::Atom, domains::finite_field::Zp, poly::{groebner::GroebnerBasis, polynomial::MultivariatePolynomial, GrevLexOrder}, - representations::Atom, }; #[test] diff --git a/src/poly/resultant.rs b/src/poly/resultant.rs index 2f0bf93f..a923df86 100644 --- a/src/poly/resultant.rs +++ b/src/poly/resultant.rs @@ -100,10 +100,10 @@ impl UnivariatePolynomial { #[cfg(test)] mod test { + use crate::atom::Atom; use crate::domains::integer::Z; use crate::domains::rational::Q; use crate::poly::polynomial::MultivariatePolynomial; - use crate::representations::Atom; #[test] fn resultant() { diff --git a/src/poly/univariate.rs b/src/poly/univariate.rs index 1232a8c3..4b8cb57d 100644 --- a/src/poly/univariate.rs +++ b/src/poly/univariate.rs @@ -1046,8 +1046,8 @@ impl UnivariatePolynomial> { #[test] fn derivative_integrate() { + use crate::atom::Atom; use crate::domains::rational::Q; - use crate::representations::Atom; let a = Atom::parse("x^2+5x+x^7+3") .unwrap() .to_polynomial::<_, u8>(&Q, None) @@ -1060,8 +1060,8 @@ fn derivative_integrate() { #[test] fn test_uni() { + use crate::atom::Atom; use crate::domains::integer::Z; - use crate::representations::Atom; let a = Atom::parse("x^2+5x+x^7+3") .unwrap() .to_polynomial::<_, u8>(&Z, None) diff --git a/src/printer.rs b/src/printer.rs index 65e7ebeb..6f0dbf9f 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -3,15 +3,15 @@ use std::fmt::{self, Display, Write}; use colored::Colorize; use crate::{ + atom::{ + representation::FunView, AddView, AtomView, MulView, NumView, PowView, Symbol, VarView, + }, coefficient::CoefficientView, domains::{ factorized_rational_polynomial::FactorizedRationalPolynomial, finite_field::FiniteFieldCore, rational_polynomial::RationalPolynomial, Ring, RingPrinter, }, poly::{polynomial::MultivariatePolynomial, Exponent, MonomialOrder}, - representations::{ - default::FunView, AddView, AtomView, MulView, NumView, PowView, Symbol, VarView, - }, state::State, tensors::matrix::Matrix, }; @@ -1303,9 +1303,9 @@ mod test { use colored::control::ShouldColorize; use crate::{ + atom::Atom, domains::{finite_field::Zp, integer::Z}, printer::{AtomPrinter, PolynomialPrinter, PrintOptions}, - representations::Atom, }; #[test] diff --git a/src/solve.rs b/src/solve.rs index b201fd4a..f51ba065 100644 --- a/src/solve.rs +++ b/src/solve.rs @@ -1,13 +1,13 @@ use std::{ops::Neg, sync::Arc}; use crate::{ + atom::{Atom, AtomView, Symbol}, domains::{ integer::{IntegerRing, Z}, rational::Q, rational_polynomial::{RationalPolynomial, RationalPolynomialField}, }, poly::{Exponent, Variable}, - representations::{Atom, AtomView, Symbol}, tensors::matrix::Matrix, }; @@ -93,13 +93,13 @@ mod test { use std::sync::Arc; use crate::{ + atom::{Atom, AtomView}, domains::{ integer::Z, rational::Q, rational_polynomial::{RationalPolynomial, RationalPolynomialField}, }, poly::Variable, - representations::{Atom, AtomView}, state::State, tensors::matrix::Matrix, }; diff --git a/src/state.rs b/src/state.rs index 17838abe..07de69a4 100644 --- a/src/state.rs +++ b/src/state.rs @@ -16,9 +16,9 @@ use smartstring::alias::String; use crate::domains::finite_field::Zp64; use crate::{ + atom::{Atom, Symbol}, coefficient::Coefficient, domains::finite_field::FiniteFieldCore, - representations::{Atom, Symbol}, LicenseManager, LICENSE_MANAGER, }; diff --git a/src/streaming.rs b/src/streaming.rs index ce9751e2..123cc5c5 100644 --- a/src/streaming.rs +++ b/src/streaming.rs @@ -3,7 +3,7 @@ use std::sync::Mutex; use rayon::prelude::*; use crate::{ - representations::{Atom, AtomView}, + atom::{Atom, AtomView}, state::{RecycledAtom, Workspace}, }; @@ -181,7 +181,7 @@ where #[cfg(test)] mod test { - use crate::{id::Pattern, representations::Atom, streaming::TermStreamer}; + use crate::{atom::Atom, id::Pattern, streaming::TermStreamer}; #[test] fn main() { diff --git a/src/transformer.rs b/src/transformer.rs index 58ccd5f0..8999d794 100644 --- a/src/transformer.rs +++ b/src/transformer.rs @@ -1,11 +1,11 @@ use std::time::Instant; use crate::{ + atom::{Atom, AtomView, Symbol}, coefficient::{Coefficient, CoefficientView}, combinatorics::{partitions, unique_permutations}, id::{Condition, MatchSettings, Pattern, WildcardAndRestriction}, printer::{AtomPrinter, PrintOptions}, - representations::{Atom, AtomView, Symbol}, state::{State, Workspace}, }; use ahash::HashMap; diff --git a/tests/pattern_matching.rs b/tests/pattern_matching.rs index 6b7796f9..36ff491e 100644 --- a/tests/pattern_matching.rs +++ b/tests/pattern_matching.rs @@ -1,6 +1,6 @@ use symbolica::{ + atom::{Atom, AtomView}, id::{Condition, Match, MatchSettings, Pattern, PatternRestriction}, - representations::{Atom, AtomView}, state::{RecycledAtom, State}, }; diff --git a/tests/rational_polynomial.rs b/tests/rational_polynomial.rs index 22396262..ceddb17d 100644 --- a/tests/rational_polynomial.rs +++ b/tests/rational_polynomial.rs @@ -1,8 +1,6 @@ use std::sync::Arc; -use symbolica::{ - domains::integer::Z, parser::Token, poly::Variable, representations::Atom, state::State, -}; +use symbolica::{atom::Atom, domains::integer::Z, parser::Token, poly::Variable, state::State}; #[test] fn large_gcd_single_scale() {