pub struct PairwiseContractionOptions {
pub lhs_conj: bool,
pub rhs_conj: bool,
}Expand description
Options for pairwise tensor contraction.
The conjugation flags are semantically equivalent to contracting
lhs.conj() or rhs.conj(), but allow implementations to pass conjugation
to the backend without materializing a conjugated tensor.
§Examples
use num_complex::Complex64;
use tensor4all_core::{
contract_pair, contract_pair_with_operand_options, DynIndex,
PairwiseContractionOptions, TensorDynLen,
};
let i = DynIndex::new_dyn(2);
let lhs = TensorDynLen::from_dense(
vec![i.clone()],
vec![Complex64::new(1.0, 2.0), Complex64::new(3.0, -1.0)],
).unwrap();
let rhs = TensorDynLen::from_dense(
vec![i],
vec![Complex64::new(2.0, 0.5), Complex64::new(-1.0, 4.0)],
).unwrap();
let options = PairwiseContractionOptions::new().with_lhs_conj(true);
let flagged = contract_pair_with_operand_options(&lhs, &rhs, options).unwrap();
let materialized = contract_pair(&lhs.conj(), &rhs).unwrap();
assert!((flagged.sum().unwrap() - materialized.sum().unwrap()).abs() < 1e-12);Fields§
§lhs_conj: boolWhether to conjugate the left operand before contraction.
rhs_conj: boolWhether to conjugate the right operand before contraction.
Implementations§
Source§impl PairwiseContractionOptions
impl PairwiseContractionOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Create pairwise contraction options with no operand conjugation.
§Examples
use tensor4all_core::PairwiseContractionOptions;
let options = PairwiseContractionOptions::new();
assert!(!options.lhs_conj);
assert!(!options.rhs_conj);Sourcepub fn with_lhs_conj(self, lhs_conj: bool) -> Self
pub fn with_lhs_conj(self, lhs_conj: bool) -> Self
Set whether the left operand is conjugated during contraction.
§Examples
use tensor4all_core::PairwiseContractionOptions;
let options = PairwiseContractionOptions::new().with_lhs_conj(true);
assert!(options.lhs_conj);
assert!(!options.rhs_conj);Sourcepub fn with_rhs_conj(self, rhs_conj: bool) -> Self
pub fn with_rhs_conj(self, rhs_conj: bool) -> Self
Set whether the right operand is conjugated during contraction.
§Examples
use tensor4all_core::PairwiseContractionOptions;
let options = PairwiseContractionOptions::new().with_rhs_conj(true);
assert!(!options.lhs_conj);
assert!(options.rhs_conj);Trait Implementations§
Source§impl Clone for PairwiseContractionOptions
impl Clone for PairwiseContractionOptions
Source§fn clone(&self) -> PairwiseContractionOptions
fn clone(&self) -> PairwiseContractionOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PairwiseContractionOptions
impl Debug for PairwiseContractionOptions
Source§impl Default for PairwiseContractionOptions
impl Default for PairwiseContractionOptions
Source§fn default() -> PairwiseContractionOptions
fn default() -> PairwiseContractionOptions
Returns the “default value” for a type. Read more
impl Copy for PairwiseContractionOptions
impl Eq for PairwiseContractionOptions
impl StructuralPartialEq for PairwiseContractionOptions
Auto Trait Implementations§
impl Freeze for PairwiseContractionOptions
impl RefUnwindSafe for PairwiseContractionOptions
impl Send for PairwiseContractionOptions
impl Sync for PairwiseContractionOptions
impl Unpin for PairwiseContractionOptions
impl UnsafeUnpin for PairwiseContractionOptions
impl UnwindSafe for PairwiseContractionOptions
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>,
Casts
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
Mutably borrows from an owned value. Read more
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
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>
Converts
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>
Converts
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