pub struct Resources {
pub active: Vec<bool>,
pub free_parameters: IndexSet<String>,
pub fixed_parameters: IndexSet<String>,
pub constants: Vec<f64>,
pub caches: Vec<Cache>,
/* private fields */
}Expand description
The main resource manager for cached values, amplitudes, parameters, and constants.
Fields§
§active: Vec<bool>A list indicating which amplitudes are active (using AmplitudeIDs as indices)
free_parameters: IndexSet<String>The set of all registered free parameter names across registered [Amplitude]s
fixed_parameters: IndexSet<String>The set of all registered fixed parameter names across registered [Amplitude]s
constants: Vec<f64>Values of all constants/fixed parameters across registered [Amplitude]s
caches: Vec<Cache>Implementations§
Source§impl Resources
impl Resources
Sourcepub fn with_transform(transform: ParameterTransform) -> Self
pub fn with_transform(transform: ParameterTransform) -> Self
Create a new Resources instance with a parameter transform applied.
Sourcepub fn free_parameter_names(&self) -> Vec<String>
pub fn free_parameter_names(&self) -> Vec<String>
The list of free parameter names.
Sourcepub fn fixed_parameter_names(&self) -> Vec<String>
pub fn fixed_parameter_names(&self) -> Vec<String>
The list of fixed parameter names.
Sourcepub fn parameter_names(&self) -> Vec<String>
pub fn parameter_names(&self) -> Vec<String>
All parameter names (free first, then fixed).
Sourcepub fn n_free_parameters(&self) -> usize
pub fn n_free_parameters(&self) -> usize
Number of free parameters.
Sourcepub fn n_fixed_parameters(&self) -> usize
pub fn n_fixed_parameters(&self) -> usize
Number of fixed parameters.
Sourcepub fn n_parameters(&self) -> usize
pub fn n_parameters(&self) -> usize
Total number of parameters.
Sourcepub fn activate_many<T: AsRef<str>>(&mut self, names: &[T])
pub fn activate_many<T: AsRef<str>>(&mut self, names: &[T])
Activate several Amplitudes by name.
Sourcepub fn activate_strict<T: AsRef<str>>(&mut self, name: T) -> LadduResult<()>
pub fn activate_strict<T: AsRef<str>>(&mut self, name: T) -> LadduResult<()>
Activate an Amplitude by name, returning an error if it is missing.
Sourcepub fn activate_many_strict<T: AsRef<str>>(
&mut self,
names: &[T],
) -> LadduResult<()>
pub fn activate_many_strict<T: AsRef<str>>( &mut self, names: &[T], ) -> LadduResult<()>
Activate several Amplitudes by name, returning an error if any are missing.
Sourcepub fn activate_all(&mut self)
pub fn activate_all(&mut self)
Activate all registered Amplitudes.
Sourcepub fn deactivate<T: AsRef<str>>(&mut self, name: T)
pub fn deactivate<T: AsRef<str>>(&mut self, name: T)
Deactivate an Amplitude by name.
Sourcepub fn deactivate_many<T: AsRef<str>>(&mut self, names: &[T])
pub fn deactivate_many<T: AsRef<str>>(&mut self, names: &[T])
Deactivate several Amplitudes by name.
Sourcepub fn deactivate_strict<T: AsRef<str>>(&mut self, name: T) -> LadduResult<()>
pub fn deactivate_strict<T: AsRef<str>>(&mut self, name: T) -> LadduResult<()>
Deactivate an Amplitude by name, returning an error if it is missing.
Sourcepub fn deactivate_many_strict<T: AsRef<str>>(
&mut self,
names: &[T],
) -> LadduResult<()>
pub fn deactivate_many_strict<T: AsRef<str>>( &mut self, names: &[T], ) -> LadduResult<()>
Deactivate several Amplitudes by name, returning an error if any are missing.
Sourcepub fn deactivate_all(&mut self)
pub fn deactivate_all(&mut self)
Deactivate all registered Amplitudes.
Sourcepub fn isolate<T: AsRef<str>>(&mut self, name: T)
pub fn isolate<T: AsRef<str>>(&mut self, name: T)
Isolate an Amplitude by name (deactivate the rest).
Sourcepub fn isolate_strict<T: AsRef<str>>(&mut self, name: T) -> LadduResult<()>
pub fn isolate_strict<T: AsRef<str>>(&mut self, name: T) -> LadduResult<()>
Isolate an Amplitude by name (deactivate the rest), returning an error if it is missing.
Sourcepub fn isolate_many<T: AsRef<str>>(&mut self, names: &[T])
pub fn isolate_many<T: AsRef<str>>(&mut self, names: &[T])
Isolate several Amplitudes by name (deactivate the rest).
Sourcepub fn isolate_many_strict<T: AsRef<str>>(
&mut self,
names: &[T],
) -> LadduResult<()>
pub fn isolate_many_strict<T: AsRef<str>>( &mut self, names: &[T], ) -> LadduResult<()>
Isolate several Amplitudes by name (deactivate the rest), returning an error if any are missing.
Sourcepub fn register_amplitude(&mut self, name: &str) -> LadduResult<AmplitudeID>
pub fn register_amplitude(&mut self, name: &str) -> LadduResult<AmplitudeID>
Register an Amplitude with the Resources manager.
This method should be called at the end of the
Amplitude::register method. The
Amplitude should probably obtain a name String in its
constructor.
§Errors
The Amplitude’s name must be unique and not already
registered, else this will return a RegistrationError.
Sourcepub fn amplitude_id(&self, name: &str) -> Option<AmplitudeID>
pub fn amplitude_id(&self, name: &str) -> Option<AmplitudeID>
Fetch the AmplitudeID for a previously registered amplitude by name.
Sourcepub fn register_parameter(
&mut self,
p: &ParameterLike,
) -> LadduResult<ParameterID>
pub fn register_parameter( &mut self, p: &ParameterLike, ) -> LadduResult<ParameterID>
Register a parameter. This method should be called within
Amplitude::register. The resulting
ParameterID should be stored to retrieve the value from the Parameters wrapper.
§Errors
Returns an error if the parameter is unnamed, if the name is reused with incompatible fixed/free status or fixed value, or if renaming causes a conflict.
Sourcepub fn register_scalar(&mut self, name: Option<&str>) -> ScalarID
pub fn register_scalar(&mut self, name: Option<&str>) -> ScalarID
Register a scalar with an optional name (names are unique to the Cache so two different
registrations of the same type which share a name will also share values and may overwrite
each other). This method should be called within the
Amplitude::register method, and the
resulting ScalarID should be stored to use later to retrieve the value from the Cache.
Sourcepub fn register_complex_scalar(&mut self, name: Option<&str>) -> ComplexScalarID
pub fn register_complex_scalar(&mut self, name: Option<&str>) -> ComplexScalarID
Register a complex scalar with an optional name (names are unique to the Cache so two different
registrations of the same type which share a name will also share values and may overwrite
each other). This method should be called within the
Amplitude::register method, and the
resulting ComplexScalarID should be stored to use later to retrieve the value from the Cache.
Sourcepub fn register_vector<const R: usize>(
&mut self,
name: Option<&str>,
) -> VectorID<R>
pub fn register_vector<const R: usize>( &mut self, name: Option<&str>, ) -> VectorID<R>
Register a vector with an optional name (names are unique to the Cache so two different
registrations of the same type which share a name will also share values and may overwrite
each other). This method should be called within the
Amplitude::register method, and the
resulting VectorID should be stored to use later to retrieve the value from the Cache.
Sourcepub fn register_complex_vector<const R: usize>(
&mut self,
name: Option<&str>,
) -> ComplexVectorID<R>
pub fn register_complex_vector<const R: usize>( &mut self, name: Option<&str>, ) -> ComplexVectorID<R>
Register a complex-valued vector with an optional name (names are unique to the Cache so two different
registrations of the same type which share a name will also share values and may overwrite
each other). This method should be called within the
Amplitude::register method, and the
resulting ComplexVectorID should be stored to use later to retrieve the value from the Cache.
Sourcepub fn register_matrix<const R: usize, const C: usize>(
&mut self,
name: Option<&str>,
) -> MatrixID<R, C>
pub fn register_matrix<const R: usize, const C: usize>( &mut self, name: Option<&str>, ) -> MatrixID<R, C>
Register a matrix with an optional name (names are unique to the Cache so two different
registrations of the same type which share a name will also share values and may overwrite
each other). This method should be called within the
Amplitude::register method, and the
resulting MatrixID should be stored to use later to retrieve the value from the Cache.
Sourcepub fn register_complex_matrix<const R: usize, const C: usize>(
&mut self,
name: Option<&str>,
) -> ComplexMatrixID<R, C>
pub fn register_complex_matrix<const R: usize, const C: usize>( &mut self, name: Option<&str>, ) -> ComplexMatrixID<R, C>
Register a complex-valued matrix with an optional name (names are unique to the Cache so two different
registrations of the same type which share a name will also share values and may overwrite
each other). This method should be called within the
Amplitude::register method, and the
resulting ComplexMatrixID should be stored to use later to retrieve the value from the Cache.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resources
impl<'de> Deserialize<'de> for Resources
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Resources
impl RefUnwindSafe for Resources
impl Send for Resources
impl Sync for Resources
impl Unpin for Resources
impl UnwindSafe for Resources
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.