mptensor  v0.3.0
Parallel Library for Tensor Network Methods
Randomized algorithm
template<template< typename > class Matrix, typename C >
int mptensor::rsvd (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank, const size_t oversamp)
 Singular value decomposition by randomized algorithm. More...
 
template<template< typename > class Matrix, typename C >
int mptensor::rsvd (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank)
 RSVD with oversamp = target_rank. More...
 
template<template< typename > class Matrix, typename C , typename Func1 , typename Func2 >
int mptensor::rsvd (Func1 &multiply_row, Func2 &multiply_col, const Shape &shape_row, const Shape &shape_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank, const size_t oversamp)
 Singular value decomposition by randomized algorithm. More...
 
template<template< typename > class Matrix, typename C , typename Func1 , typename Func2 >
int mptensor::rsvd (Func1 &multiply_row, Func2 &multiply_col, const Shape &shape_row, const Shape &shape_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank)
 RSVD with oversamp = target_rank. More...
 
void mptensor::set_seed (unsigned int seed)
 Set seed for random number generator. More...
 

Detailed Description

Function to decompose a tensor by randomized algorithms.

Function Documentation

◆ rsvd() [1/4]

template<template< typename > class Matrix, typename C >
int mptensor::rsvd ( const Tensor< Matrix, C > &  a,
const Axes axes_row,
const Axes axes_col,
Tensor< Matrix, C > &  u,
std::vector< double > &  s,
Tensor< Matrix, C > &  vt,
const size_t  target_rank 
)

RSVD with oversamp = target_rank.

◆ rsvd() [2/4]

template<template< typename > class Matrix, typename C >
int mptensor::rsvd ( const Tensor< Matrix, C > &  a,
const Axes axes_row,
const Axes axes_col,
Tensor< Matrix, C > &  u,
std::vector< double > &  s,
Tensor< Matrix, C > &  vt,
const size_t  target_rank,
const size_t  oversamp 
)

Singular value decomposition by randomized algorithm.

For example,

rsvd(A, Axes(0,3), Axes(1,2), U, S, VT, k, p)
int rsvd(const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank, const size_t oversamp)
Singular value decomposition by randomized algorithm.
Definition: rsvd_impl.hpp:82
Index Axes
Definition: tensor.hpp:45

calculates the following decomposition.

\[ A_{abcd} \simeq \sum_{i=0}^{k-1} U_{adi} S_i (V^\dagger)_{ibc}, \]

where \( k \) is the target rank.

Parameters
[in]aA tensor to be decomposed.
[in]axes_rowAxes for left singular vectors.
[in]axes_colAxes for right singular vectors.
[out]uTensor \( U \) corresponds to left signular vectors.
[out]sSingluar values.
[out]vtTensor \( V^\dagger \) corresponds to right singular vectors.
[in]target_rankThe number of singular values to be calculated
[in]oversampOversampling parameter for randomized algorithm
Returns
Information from linear-algebra library.

◆ rsvd() [3/4]

template<template< typename > class Matrix, typename C , typename Func1 , typename Func2 >
int mptensor::rsvd ( Func1 &  multiply_row,
Func2 &  multiply_col,
const Shape shape_row,
const Shape shape_col,
Tensor< Matrix, C > &  u,
std::vector< double > &  s,
Tensor< Matrix, C > &  vt,
const size_t  target_rank 
)

RSVD with oversamp = target_rank.

◆ rsvd() [4/4]

template<template< typename > class Matrix, typename C , typename Func1 , typename Func2 >
int mptensor::rsvd ( Func1 &  multiply_row,
Func2 &  multiply_col,
const Shape shape_row,
const Shape shape_col,
Tensor< Matrix, C > &  u,
std::vector< double > &  s,
Tensor< Matrix, C > &  vt,
const size_t  target_rank,
const size_t  oversamp 
)

Singular value decomposition by randomized algorithm.

Parameters
[in]multiply_rowA function object which takes a Tensor with Shape(shape_col+[target_rank+oversamp]) and returns a Tensor with Shape(shape_row+[target_rank+oversamp]).
[in]multiply_colA function object which takes a Tensor with Shape([target_rank+oversamp]+shape_row) and returns a Tensor with Shape([target_rank+oversamp]+shape_col).
[in]shape_rowShape of row indices.
[in]shape_colShape of column indices.
[out]uTensor \( U \) corresponds to left singular vectors. Its shape is Shape(shape_row+[target_rank]).
[out]sSingular values.
[out]vtTensor \( V^\dagger \) corresponds to right singular vectors. Its shape is Shape([target_rank]+shape_col).
[in]target_rankThe number of singular values to be calculated
[in]oversampOversampling parameter for randomized algorithm
Returns
Information from linear-algebra library.

◆ set_seed()

void mptensor::set_seed ( unsigned int  seed)
inline

Set seed for random number generator.

Parameters
[in]seedValue of seed.
Warning
Set different seed values for each MPI process.