Skip to content

Commit

Permalink
Expand products raised to negative powers
Browse files Browse the repository at this point in the history
- Rename `representations` to `atom`
  • Loading branch information
benruijl committed Apr 15, 2024
1 parent d06075c commit 30fcc97
Show file tree
Hide file tree
Showing 51 changed files with 103 additions and 88 deletions.
2 changes: 1 addition & 1 deletion examples/builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::{Atom, FunctionBuilder},
fun,
representations::{Atom, FunctionBuilder},
state::State,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/coefficient_ring.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/collect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::{Atom, FunctionBuilder},
fun,
representations::{Atom, FunctionBuilder},
state::State,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/derivative.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use symbolica::{representations::Atom, state::State};
use symbolica::{atom::Atom, state::State};

fn main() {
let x = State::get_symbol("x");
Expand Down
2 changes: 1 addition & 1 deletion examples/evaluate.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
2 changes: 1 addition & 1 deletion examples/expansion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use symbolica::representations::Atom;
use symbolica::atom::Atom;

fn main() {
let input = Atom::parse("(1+x)^3").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/factorization.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/fibonacci.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::{Atom, AtomView},
id::{Match, Pattern, PatternRestriction},
representations::{Atom, AtomView},
state::{RecycledAtom, State},
};

Expand Down
2 changes: 1 addition & 1 deletion examples/groebner_basis.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use symbolica::{
atom::Atom,
domains::finite_field::Zp,
poly::{groebner::GroebnerBasis, polynomial::MultivariatePolynomial, GrevLexOrder},
representations::Atom,
state::State,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/optimize.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use symbolica::{
atom::Atom,
domains::rational::Q,
poly::evaluate::{BorrowedHornerScheme, InstructionSetPrinter},
representations::Atom,
};

use symbolica::poly::polynomial::MultivariatePolynomial;
Expand Down
2 changes: 1 addition & 1 deletion examples/optimize_multiple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use symbolica::{
atom::Atom,
domains::rational::{Rational, Q},
poly::evaluate::{HornerScheme, InstructionSetPrinter},
representations::Atom,
};

use symbolica::poly::polynomial::MultivariatePolynomial;
Expand Down
2 changes: 1 addition & 1 deletion examples/partition.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/pattern_match.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::Atom,
id::{Condition, Match, MatchSettings},
representations::Atom,
state::State,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/pattern_restrictions.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/polynomial_gcd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::Atom,
domains::{integer::Z, rational::Q},
representations::Atom,
};
use tracing_subscriber::{fmt, prelude::*, util::SubscriberInitExt, EnvFilter};

Expand Down
2 changes: 1 addition & 1 deletion examples/rational_polynomial.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::Atom,
domains::{integer::Z, rational_polynomial::RationalPolynomial},
representations::Atom,
};

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/replace_all.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/replace_once.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::Atom,
id::{Condition, MatchSettings},
representations::Atom,
};

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/solve_linear_system.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/streaming.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/taylor_series.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use symbolica::{representations::Atom, state::State};
use symbolica::{atom::Atom, state::State};

fn main() {
let x = State::get_symbol("x");
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_replace.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use symbolica::{
atom::Atom,
id::{Condition, Match, MatchSettings, PatternAtomTreeIterator},
representations::Atom,
state::State,
};

Expand Down
5 changes: 4 additions & 1 deletion examples/tree_walk.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/api/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/representations.rs → src/atom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod coefficient;
pub mod default;
pub mod representation;

use crate::{
coefficient::Coefficient,
Expand All @@ -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.
Expand Down Expand Up @@ -564,7 +564,7 @@ impl Atom {
/// For example:
/// ```
/// # use symbolica::{
/// # representations::{Atom, AsAtomView, FunctionBuilder},
/// # atom::{Atom, AsAtomView, FunctionBuilder},
/// # state::{FunctionAttribute, State},
/// # };
/// # fn main() {
Expand Down Expand Up @@ -1040,8 +1040,8 @@ impl<T: Into<Coefficient>> std::ops::Div<T> for Atom {
#[cfg(test)]
mod test {
use crate::{
atom::{Atom, FunctionBuilder},
fun,
representations::{Atom, FunctionBuilder},
state::State,
};

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/coefficient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use rug::{
use smallvec::{smallvec, SmallVec};

use crate::{
atom::{Atom, AtomView},
domains::{
finite_field::{
FiniteField, FiniteFieldCore, FiniteFieldElement, FiniteFieldWorkspace, ToFiniteField,
Expand All @@ -23,7 +24,6 @@ use crate::{
EuclideanDomain, Field, Ring,
},
poly::{polynomial::MultivariatePolynomial, Variable, INLINED_EXPONENTS},
representations::{Atom, AtomView},
state::{FiniteFieldIndex, State, Workspace},
};

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/collect.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down Expand Up @@ -400,8 +400,8 @@ impl<'a> AtomView<'a> {
#[cfg(test)]
mod test {
use crate::{
atom::{Atom, FunctionBuilder},
fun,
representations::{Atom, FunctionBuilder},
state::State,
};

Expand Down
4 changes: 2 additions & 2 deletions src/derivative.rs
Original file line number Diff line number Diff line change
@@ -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},
};

Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/domains/algebraic_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ impl<R: Field + PolynomialGCD<u8>> Field for AlgebraicNumberRing<R> {

#[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> {
Expand Down
14 changes: 7 additions & 7 deletions src/domains/rational_polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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>(
Expand Down Expand Up @@ -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>(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)",
)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 30fcc97

Please sign in to comment.