pub struct ExpandOpts {
pub mul: bool,
pub multinomial: bool,
pub power_base: bool,
pub power_exp: bool,
pub log: bool,
pub trig: bool,
pub deep: bool,
pub force: bool,
}Expand description
Hints controlling Ex::expand_with.
Every rewrite is value-preserving. The hints that are only valid
under side conditions (power_base, power_exp, log) are guarded by
the assumption system unless force is set:
| Hint | Rewrite | Guard (unless force) |
|---|---|---|
mul | a·(b + c) → a·b + a·c | none |
multinomial | (a + b)^n → … for integer n ≥ 0 | none |
power_base | (x·y)^e → x^e·y^e | e ∈ ℤ, or every factor known non-negative |
power_exp | x^(a+b) → x^a·x^b | x = e, x > 0, all summands numeric same-sign, or all summands known integers |
log | ln(a·b) → ln a + ln b, ln(a^n) → n·ln a | arguments known positive (n real) |
trig | sin(a + b) → sin a cos b + cos a sin b, … | none |
deep | also expand inside function arguments | — |
§Examples
use symplex::prelude::*;
use symplex::macros::ExpandOpts;
let ctx = Context::new();
let (x, y) = (ctx.symbol("x"), ctx.symbol("y"));
let expr = (&x * &y).ln();
// Default: logs are not expanded.
assert_eq!(format!("{}", expr.expand_with(&ExpandOpts::default())), "ln(x*y)");
// With `log` + `force` the identity is applied unconditionally.
let opts = ExpandOpts::default().log(true).force(true);
assert_eq!(format!("{}", expr.expand_with(&opts)), "ln(x) + ln(y)");Fields§
§mul: boolDistribute products over sums (default true).
multinomial: boolExpand non-negative integer powers of sums (default true).
power_base: boolDistribute powers over products, (x·y)^e → x^e·y^e (default true, guarded).
power_exp: boolSplit sums in exponents, x^(a+b) → x^a·x^b (default true, guarded).
log: boolExpand logarithms of products / powers (default false, guarded).
trig: boolExpand trigonometric functions of sums and multiples (default false).
deep: boolRecurse into function arguments (default true). When false,
only the algebraic skeleton reachable through Add/Mul/Pow
from the root is expanded.
force: boolApply the guarded rewrites unconditionally (default false).
Implementations§
Source§impl ExpandOpts
impl ExpandOpts
Sourcepub fn multinomial(self, v: bool) -> Self
pub fn multinomial(self, v: bool) -> Self
Builder: set multinomial.
Sourcepub fn power_base(self, v: bool) -> Self
pub fn power_base(self, v: bool) -> Self
Builder: set power_base.
Trait Implementations§
Source§impl Clone for ExpandOpts
impl Clone for ExpandOpts
Source§fn clone(&self) -> ExpandOpts
fn clone(&self) -> ExpandOpts
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ExpandOpts
Source§impl Debug for ExpandOpts
impl Debug for ExpandOpts
Source§impl Default for ExpandOpts
impl Default for ExpandOpts
impl Eq for ExpandOpts
Source§impl PartialEq for ExpandOpts
impl PartialEq for ExpandOpts
impl StructuralPartialEq for ExpandOpts
Auto Trait Implementations§
impl Freeze for ExpandOpts
impl RefUnwindSafe for ExpandOpts
impl Send for ExpandOpts
impl Sync for ExpandOpts
impl Unpin for ExpandOpts
impl UnsafeUnpin for ExpandOpts
impl UnwindSafe for ExpandOpts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more