pub struct Resources {
pub active: Vec<bool>,
pub parameters: IndexSet<String>,
pub constants: Vec<Float>,
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 AmplitudeID
s as indices)
parameters: IndexSet<String>
The set of all registered parameter names across registered Amplitude
s
constants: Vec<Float>
Values of all constants across registered Amplitude
s
caches: Vec<Cache>
Implementations§
Source§impl Resources
impl Resources
Sourcepub fn activate<T: AsRef<str>>(&mut self, name: T) -> Result<(), LadduError>
pub fn activate<T: AsRef<str>>(&mut self, name: T) -> Result<(), LadduError>
Activate an Amplitude
by name.
Sourcepub fn activate_many<T: AsRef<str>>(
&mut self,
names: &[T],
) -> Result<(), LadduError>
pub fn activate_many<T: AsRef<str>>( &mut self, names: &[T], ) -> Result<(), LadduError>
Activate several Amplitude
s by name.
Sourcepub fn activate_all(&mut self)
pub fn activate_all(&mut self)
Activate all registered Amplitude
s.
Sourcepub fn deactivate<T: AsRef<str>>(&mut self, name: T) -> Result<(), LadduError>
pub fn deactivate<T: AsRef<str>>(&mut self, name: T) -> Result<(), LadduError>
Deactivate an Amplitude
by name.
Sourcepub fn deactivate_many<T: AsRef<str>>(
&mut self,
names: &[T],
) -> Result<(), LadduError>
pub fn deactivate_many<T: AsRef<str>>( &mut self, names: &[T], ) -> Result<(), LadduError>
Deactivate several Amplitude
s by name.
Sourcepub fn deactivate_all(&mut self)
pub fn deactivate_all(&mut self)
Deactivate all registered Amplitude
s.
Sourcepub fn isolate<T: AsRef<str>>(&mut self, name: T) -> Result<(), LadduError>
pub fn isolate<T: AsRef<str>>(&mut self, name: T) -> Result<(), LadduError>
Isolate an Amplitude
by name (deactivate the rest).
Sourcepub fn isolate_many<T: AsRef<str>>(
&mut self,
names: &[T],
) -> Result<(), LadduError>
pub fn isolate_many<T: AsRef<str>>( &mut self, names: &[T], ) -> Result<(), LadduError>
Isolate several Amplitude
s by name (deactivate the rest).
Sourcepub fn register_amplitude(
&mut self,
name: &str,
) -> Result<AmplitudeID, LadduError>
pub fn register_amplitude( &mut self, name: &str, ) -> Result<AmplitudeID, LadduError>
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 register_parameter(&mut self, pl: &ParameterLike) -> ParameterID
pub fn register_parameter(&mut self, pl: &ParameterLike) -> ParameterID
Register a free parameter (or constant) ParameterLike
. This method should be called
within the Amplitude::register
method, and the
resulting ParameterID
should be stored to use later to retrieve the value from the
Parameters
wrapper object.
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§
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> 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.