Expand description
The amplitude module contains structs and methods for defining and manipulating Amplitudes
and Models
To create a new Amplitude in Rust, we simply need to implement the Node trait on a
struct. You can then provide a convenience method for creating a new implementation of your
Amplitude.
Amplitudes are typically defined first, and then Models are built by adding, multiplying
and taking the real/imaginary part of Amplitudes. Models can be built using the
provided Model::new constructor or with the model! macro. The terms
provided to either of these will be treated as separate coherent sums. The Model will
implicitly take their absolute square and then add those sums incoherently.
We can then use Manager-like structs to handle computataion
over Datasets.
§Example:
An example (with no particular physical meaning) is given as follows:
use rustitude_core::prelude::*;
fn main() {
let a = scalar("a"); // a(value) = value
let b = scalar("b"); // b(value) = value
let c = cscalar("c"); // c(real, imag) = real + i * imag
let d = pcscalar("d"); // d(mag, phi) = mag * e^{i * phi}
let abc = a + b + &c; // references avoid losing ownership
let x = abc * &d + c.real();
let model = model!(x, d);
// |(a.value + b.value + c.real + i * c.imag) * (d.mag * e^{i * d.phi}) + c.real|^2 + |d.mag * e^{i * d.phi}|^2
}With Rust’s ownership rules, if we want to use amplitudes in multiple places, we need to either
reference them or clone them (a.clone(), for instance). References typically look nicer and
are more readable, but a clone will happen regardless (although it isn’t expensive, only one
copy of each amplitude will ever hold any data).
Structs§
- Amplitude
- A struct which stores a named
Node. - Complex
Scalar - A
Nodefor computing a single complex value from two input parameters. - Imag
- An
AmpLikerepresenting the imaginary part of theAmpLikeit contains. - Model
- A model contains an API to interact with a group of coherent sums by managing their amplitudes
and parameters. Models are typically passed to
Manager-like struct. - NormSqr
- Struct to hold a coherent sum of
AmpLikes - Parameter
- A single parameter within an
Amplitude. - Piecewise
- A generic struct which can be used to create any kind of piecewise function.
- Polar
Complex Scalar - A
Nodefor computing a single complex value from two input parameters in polar form. - Product
- An
AmpLikerepresenting the product of theAmpLikes it contains. - Real
- An
AmpLikerepresenting the real part of theAmpLikeit contains. - Scalar
- A
Nodefor computing a single scalar value from an input parameter. - Sum
- An
AmpLikerepresenting the sum of theAmpLikes it contains.
Traits§
- AmpLike
- This trait is used to implement operations which can be performed on
Amplitudes (and other operations themselves). Currently, there are only a limited number of defined operations, namelyReal,Imag, andProduct. Others may be added in the future, but they should probably only be added through this crate and not externally, since they require several operator overloads to be implemented for nice syntax. - AsTree
- This trait defines some simple methods for pretty-printing tree-like structures.
- Node
- A trait which contains all the required methods for a functioning
Amplitude.
Functions§
- cscalar
- Creates a named
ComplexScalar. - pcscalar
- Creates a named
PolarComplexScalar. - piecewise_
m - Creates a named
Piecewiseamplitude with the resonance mass as the binning variable. - scalar
- Creates a named
Scalar.