pub struct ArcLinearOperator<T, V>{
pub mpo: Arc<TreeTN<T, V>>,
pub input_mapping: HashMap<V, IndexMapping<T::Index>>,
pub output_mapping: HashMap<V, IndexMapping<T::Index>>,
}Expand description
LinearOperator with Arc-based Copy-on-Write semantics.
This wrapper uses Arc for the internal MPO to enable cheap cloning
and efficient sharing. When mutation is needed, make_mut performs
a clone only if there are other references.
Fields§
§mpo: Arc<TreeTN<T, V>>The MPO with internal index IDs (wrapped in Arc for CoW)
input_mapping: HashMap<V, IndexMapping<T::Index>>Input index mapping: node -> (true s_in, internal s_in_tmp)
output_mapping: HashMap<V, IndexMapping<T::Index>>Output index mapping: node -> (true s_out, internal s_out_tmp)
Implementations§
Source§impl<T, V> ArcLinearOperator<T, V>
impl<T, V> ArcLinearOperator<T, V>
Sourcepub fn from_linear_operator(op: LinearOperator<T, V>) -> Self
pub fn from_linear_operator(op: LinearOperator<T, V>) -> Self
Create from an existing LinearOperator.
Sourcepub fn new(
mpo: TreeTN<T, V>,
input_mapping: HashMap<V, IndexMapping<T::Index>>,
output_mapping: HashMap<V, IndexMapping<T::Index>>,
) -> Self
pub fn new( mpo: TreeTN<T, V>, input_mapping: HashMap<V, IndexMapping<T::Index>>, output_mapping: HashMap<V, IndexMapping<T::Index>>, ) -> Self
Create a new ArcLinearOperator.
Sourcepub fn mpo_mut(&mut self) -> &mut TreeTN<T, V>
pub fn mpo_mut(&mut self) -> &mut TreeTN<T, V>
Get a mutable reference to the MPO, cloning if necessary.
This implements Copy-on-Write semantics: if this is the only reference, no copy is made. If there are other references, the MPO is cloned first.
Sourcepub fn into_linear_operator(self) -> LinearOperator<T, V>
pub fn into_linear_operator(self) -> LinearOperator<T, V>
Convert back to a LinearOperator (unwraps Arc if possible).
Sourcepub fn get_input_mapping(&self, node: &V) -> Option<&IndexMapping<T::Index>>
pub fn get_input_mapping(&self, node: &V) -> Option<&IndexMapping<T::Index>>
Get input mapping for a node.
Sourcepub fn get_output_mapping(&self, node: &V) -> Option<&IndexMapping<T::Index>>
pub fn get_output_mapping(&self, node: &V) -> Option<&IndexMapping<T::Index>>
Get output mapping for a node.
Sourcepub fn input_mappings(&self) -> &HashMap<V, IndexMapping<T::Index>>
pub fn input_mappings(&self) -> &HashMap<V, IndexMapping<T::Index>>
Get all input mappings.
Sourcepub fn output_mappings(&self) -> &HashMap<V, IndexMapping<T::Index>>
pub fn output_mappings(&self) -> &HashMap<V, IndexMapping<T::Index>>
Get all output mappings.
Sourcepub fn node_names(&self) -> HashSet<V>
pub fn node_names(&self) -> HashSet<V>
Get node names covered by this operator.
Trait Implementations§
Source§impl<T, V> Clone for ArcLinearOperator<T, V>
impl<T, V> Clone for ArcLinearOperator<T, V>
Source§fn clone(&self) -> ArcLinearOperator<T, V>
fn clone(&self) -> ArcLinearOperator<T, V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T, V> Freeze for ArcLinearOperator<T, V>
impl<T, V> RefUnwindSafe for ArcLinearOperator<T, V>where
V: RefUnwindSafe,
<T as TensorIndex>::Index: RefUnwindSafe,
<<T as TensorIndex>::Index as IndexLike>::Id: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, V> Send for ArcLinearOperator<T, V>
impl<T, V> Sync for ArcLinearOperator<T, V>
impl<T, V> Unpin for ArcLinearOperator<T, V>
impl<T, V> UnsafeUnpin for ArcLinearOperator<T, V>
impl<T, V> UnwindSafe for ArcLinearOperator<T, V>where
V: UnwindSafe + RefUnwindSafe,
<T as TensorIndex>::Index: UnwindSafe + RefUnwindSafe,
<<T as TensorIndex>::Index as IndexLike>::Id: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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