pub struct SiteTensorTrain<T: TTScalar> { /* private fields */ }Expand description
Site Tensor Train with center canonical form
A tensor train where:
- Tensors at indices < center are left-orthogonal
- Tensors at indices > center are right-orthogonal
- The tensor at the center index is the “center” tensor
§Examples
use tensor4all_simplett::{TensorTrain, AbstractTensorTrain, SiteTensorTrain};
// Build a constant tensor train and convert to center-canonical form.
let tt = TensorTrain::<f64>::constant(&[2, 3, 4], 1.0);
let stt = SiteTensorTrain::from_tensor_train(&tt, 1).unwrap();
// The center is at site 1.
assert_eq!(stt.center(), 1);
assert_eq!(stt.len(), 3);
// Converting back preserves tensor train values.
let tt2 = stt.to_tensor_train();
let val = tt2.evaluate(&[0, 1, 2]).unwrap();
assert!((val - 1.0).abs() < 1e-12);Implementations§
Source§impl<T: TTScalar + Scalar + Default> SiteTensorTrain<T>
impl<T: TTScalar + Scalar + Default> SiteTensorTrain<T>
Sourcepub fn new(tensors: Vec<Tensor3<T>>, center: usize) -> Result<Self>
pub fn new(tensors: Vec<Tensor3<T>>, center: usize) -> Result<Self>
Create a new SiteTensorTrain from tensors with specified center
Sourcepub fn from_tensor_train(tt: &TensorTrain<T>, center: usize) -> Result<Self>
pub fn from_tensor_train(tt: &TensorTrain<T>, center: usize) -> Result<Self>
Create from TensorTrain with specified center
Sourcepub fn site_tensors_mut(&mut self) -> &mut [Tensor3<T>] ⓘ
pub fn site_tensors_mut(&mut self) -> &mut [Tensor3<T>] ⓘ
Get mutable access to site tensors
Sourcepub fn move_center_right(&mut self) -> Result<()>
pub fn move_center_right(&mut self) -> Result<()>
Move the center one position to the right
Sourcepub fn move_center_left(&mut self) -> Result<()>
pub fn move_center_left(&mut self) -> Result<()>
Move the center one position to the left
Sourcepub fn set_center(&mut self, new_center: usize) -> Result<()>
pub fn set_center(&mut self, new_center: usize) -> Result<()>
Move the center to a specific position
Sourcepub fn to_tensor_train(&self) -> TensorTrain<T>
pub fn to_tensor_train(&self) -> TensorTrain<T>
Convert to a regular TensorTrain
Sourcepub fn set_site_tensor(&mut self, i: usize, tensor: Tensor3<T>)
pub fn set_site_tensor(&mut self, i: usize, tensor: Tensor3<T>)
Set the tensor at a specific site
Note: This may invalidate the canonical form. Use with caution.
Trait Implementations§
Source§impl<T: TTScalar + Scalar + Default> AbstractTensorTrain<T> for SiteTensorTrain<T>
impl<T: TTScalar + Scalar + Default> AbstractTensorTrain<T> for SiteTensorTrain<T>
Source§impl<T: Clone + TTScalar> Clone for SiteTensorTrain<T>
impl<T: Clone + TTScalar> Clone for SiteTensorTrain<T>
Source§fn clone(&self) -> SiteTensorTrain<T>
fn clone(&self) -> SiteTensorTrain<T>
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 moreAuto Trait Implementations§
impl<T> Freeze for SiteTensorTrain<T>
impl<T> RefUnwindSafe for SiteTensorTrain<T>where
T: RefUnwindSafe,
impl<T> Send for SiteTensorTrain<T>
impl<T> Sync for SiteTensorTrain<T>
impl<T> Unpin for SiteTensorTrain<T>where
T: Unpin,
impl<T> UnsafeUnpin for SiteTensorTrain<T>
impl<T> UnwindSafe for SiteTensorTrain<T>where
T: UnwindSafe,
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<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>
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