xerus
a general purpose tensor library
xerus::ALSVariant Class Reference

Wrapper class for all ALS variants (dmrg etc.) More...

#include <als.h>

Classes

struct  ALSAlgorithmicData
 

Public Types

enum  Direction { Increasing, Decreasing }
 
using LocalSolver = std::function< void(const TensorNetwork &, std::vector< Tensor > &, const TensorNetwork &, const ALSAlgorithmicData &)>
 the algorithm that is used to solve the local problems More...
 

Public Member Functions

 ALSVariant (uint _sites, size_t _numHalfSweeps, LocalSolver _localSolver, bool _assumeSPD, bool _useResidual=false)
 fully defining constructor. alternatively ALSVariants can be created by copying a predefined variant and modifying it More...
 
double operator() (const TTOperator &_A, TTTensor &_x, const TTTensor &_b, value_t _convergenceEpsilon, PerformanceData &_perfData=NoPerfData) const
 
double operator() (const TTOperator &_A, TTTensor &_x, const TTTensor &_b, size_t _numHalfSweeps, PerformanceData &_perfData=NoPerfData) const
 
double operator() (const TTOperator &_A, TTTensor &_x, const TTTensor &_b, PerformanceData &_perfData=NoPerfData) const
 
double operator() (TTTensor &_x, const TTTensor &_b, value_t _convergenceEpsilon, PerformanceData &_perfData=NoPerfData) const
 
double operator() (TTTensor &_x, const TTTensor &_b, size_t _numHalfSweeps, PerformanceData &_perfData=NoPerfData) const
 
double operator() (TTTensor &_x, const TTTensor &_b, PerformanceData &_perfData=NoPerfData) const
 

Static Public Member Functions

static void ASD_solver (const TensorNetwork &_A, std::vector< Tensor > &_x, const TensorNetwork &_b, const ALSAlgorithmicData &_data)
 
static void lapack_solver (const TensorNetwork &_A, std::vector< Tensor > &_x, const TensorNetwork &_b, const ALSAlgorithmicData &_data)
 local solver that calls the corresponding lapack routines (LU solver) More...
 

Public Attributes

bool assumeSPD
 if true the operator A will be assumed to be symmetric positive definite More...
 
value_t convergenceEpsilon
 default value for the change in the energy functional at which the ALS assumes it is converged More...
 
const size_t FLAG_FINISHED_FULLSWEEP = 3
 
const size_t FLAG_FINISHED_HALFSWEEP = 1
 
LocalSolver localSolver
 
size_t numHalfSweeps
 maximum number of sweeps to perform. set to 0 for infinite More...
 
bool preserveCorePosition
 if true the core will be moved to its original position at the end More...
 
uint sites
 the number of sites that are simultaneously optimized More...
 
bool useResidualForEndCriterion
 calculates the residual to decide if the ALS converged. recommended if _perfdata is given. implied if assumeSPD = false More...
 

Protected Member Functions

bool check_for_end_of_sweep (ALSAlgorithmicData &_data, size_t _numHalfSweeps, value_t _convergenceEpsilon, PerformanceData &_perfData) const
 
TensorNetwork construct_local_operator (ALSAlgorithmicData &_data) const
 
TensorNetwork construct_local_RHS (ALSAlgorithmicData &_data) const
 
double solve (const TTOperator *_Ap, TTTensor &_x, const TTTensor &_b, size_t _numHalfSweeps, value_t _convergenceEpsilon, PerformanceData &_perfData=NoPerfData) const
 

Detailed Description

Wrapper class for all ALS variants (dmrg etc.)

By creating a new object of this class and modifying the member variables, the behaviour of the solver can be modified. The local solver will be ignored for all calls to the x=b variants (ie. without operator A)

Definition at line 37 of file als.h.

Member Typedef Documentation

◆ LocalSolver

using xerus::ALSVariant::LocalSolver = std::function<void(const TensorNetwork &, std::vector<Tensor> &, const TensorNetwork &, const ALSAlgorithmicData &)>

the algorithm that is used to solve the local problems

Definition at line 123 of file als.h.

Member Enumeration Documentation

◆ Direction

Enumerator
Increasing 
Decreasing 

Definition at line 39 of file als.h.

Constructor & Destructor Documentation

◆ ALSVariant()

xerus::ALSVariant::ALSVariant ( uint  _sites,
size_t  _numHalfSweeps,
LocalSolver  _localSolver,
bool  _assumeSPD,
bool  _useResidual = false 
)
inline

fully defining constructor. alternatively ALSVariants can be created by copying a predefined variant and modifying it

Definition at line 134 of file als.h.

Member Function Documentation

◆ ASD_solver()

void xerus::ALSVariant::ASD_solver ( const TensorNetwork _A,
std::vector< Tensor > &  _x,
const TensorNetwork _b,
const ALSAlgorithmicData _data 
)
static

Definition at line 73 of file als.cpp.

◆ check_for_end_of_sweep()

bool xerus::ALSVariant::check_for_end_of_sweep ( ALSAlgorithmicData _data,
size_t  _numHalfSweeps,
value_t  _convergenceEpsilon,
PerformanceData _perfData 
) const
protected

Definition at line 426 of file als.cpp.

◆ construct_local_operator()

TensorNetwork xerus::ALSVariant::construct_local_operator ( ALSVariant::ALSAlgorithmicData _data) const
protected

Definition at line 383 of file als.cpp.

◆ construct_local_RHS()

TensorNetwork xerus::ALSVariant::construct_local_RHS ( ALSVariant::ALSAlgorithmicData _data) const
protected

Definition at line 404 of file als.cpp.

◆ lapack_solver()

void xerus::ALSVariant::lapack_solver ( const TensorNetwork _A,
std::vector< Tensor > &  _x,
const TensorNetwork _b,
const ALSAlgorithmicData _data 
)
static

local solver that calls the corresponding lapack routines (LU solver)

Definition at line 43 of file als.cpp.

◆ operator()() [1/6]

double xerus::ALSVariant::operator() ( const TTOperator _A,
TTTensor _x,
const TTTensor _b,
value_t  _convergenceEpsilon,
PerformanceData _perfData = NoPerfData 
) const
inline

call to solve \( A\cdot x = b\) for \( x \) (in a least-squares sense)

Parameters
_Aoperator to solve for
[in,out]_xin: initial guess, out: solution as found by the algorithm
_bright-hand side of the equation to be solved
_convergenceEpsilonminimum change in residual / energy under which the algorithm terminates
_perfDatavector of performance data (residuals after every microiteration)
Returns
the residual \(|Ax-b|\) of the final _x

Definition at line 152 of file als.h.

◆ operator()() [2/6]

double xerus::ALSVariant::operator() ( const TTOperator _A,
TTTensor _x,
const TTTensor _b,
size_t  _numHalfSweeps,
PerformanceData _perfData = NoPerfData 
) const
inline

call to solve \( A\cdot x = b\) for \( x \) (in a least-squares sense)

Parameters
_Aoperator to solve for
[in,out]_xin: initial guess, out: solution as found by the algorithm
_bright-hand side of the equation to be solved
_numHalfSweepsmaximum number of half-sweeps to perform
_perfDatavector of performance data (residuals after every microiteration)
Returns
the residual \(|Ax-b|\) of the final _x

Definition at line 165 of file als.h.

◆ operator()() [3/6]

double xerus::ALSVariant::operator() ( const TTOperator _A,
TTTensor _x,
const TTTensor _b,
PerformanceData _perfData = NoPerfData 
) const
inline

call to solve \( A\cdot x = b\) for \( x \) (in a least-squares sense)

Parameters
_Aoperator to solve for
[in,out]_xin: initial guess, out: solution as found by the algorithm
_bright-hand side of the equation to be solved
_perfDatavector of performance data (residuals after every microiteration)
Returns
the residual \(|Ax-b|\) of the final _x

Definition at line 177 of file als.h.

◆ operator()() [4/6]

double xerus::ALSVariant::operator() ( TTTensor _x,
const TTTensor _b,
value_t  _convergenceEpsilon,
PerformanceData _perfData = NoPerfData 
) const
inline

call to minimze \( \|x - b\|^2 \) for \( x \)

Parameters
[in,out]_xin: initial guess, out: solution as found by the algorithm
_bright-hand side of the equation to be solved
_convergenceEpsilonminimum change in residual / energy under which the algorithm terminates
_perfDatavector of performance data (residuals after every microiteration)
Returns
the residual \(|x-b|\) of the final _x

Definition at line 189 of file als.h.

◆ operator()() [5/6]

double xerus::ALSVariant::operator() ( TTTensor _x,
const TTTensor _b,
size_t  _numHalfSweeps,
PerformanceData _perfData = NoPerfData 
) const
inline

call to minimze \( \|x - b\|^2 \) for \( x \)

Parameters
[in,out]_xin: initial guess, out: solution as found by the algorithm
_bright-hand side of the equation to be solved
_numHalfSweepsmaximum number of half-sweeps to perform
_perfDatavector of performance data (residuals after every microiteration)
Returns
the residual \(|x-b|\) of the final _x

Definition at line 201 of file als.h.

◆ operator()() [6/6]

double xerus::ALSVariant::operator() ( TTTensor _x,
const TTTensor _b,
PerformanceData _perfData = NoPerfData 
) const
inline

Definition at line 205 of file als.h.

◆ solve()

double xerus::ALSVariant::solve ( const TTOperator _Ap,
TTTensor _x,
const TTTensor _b,
size_t  _numHalfSweeps,
value_t  _convergenceEpsilon,
PerformanceData _perfData = NoPerfData 
) const
protected

Definition at line 483 of file als.cpp.

Member Data Documentation

◆ assumeSPD

bool xerus::ALSVariant::assumeSPD

if true the operator A will be assumed to be symmetric positive definite

Definition at line 118 of file als.h.

◆ convergenceEpsilon

value_t xerus::ALSVariant::convergenceEpsilon

default value for the change in the energy functional at which the ALS assumes it is converged

Definition at line 114 of file als.h.

◆ FLAG_FINISHED_FULLSWEEP

const size_t xerus::ALSVariant::FLAG_FINISHED_FULLSWEEP = 3

Definition at line 110 of file als.h.

◆ FLAG_FINISHED_HALFSWEEP

const size_t xerus::ALSVariant::FLAG_FINISHED_HALFSWEEP = 1

Definition at line 109 of file als.h.

◆ localSolver

LocalSolver xerus::ALSVariant::localSolver

Definition at line 124 of file als.h.

◆ numHalfSweeps

size_t xerus::ALSVariant::numHalfSweeps

maximum number of sweeps to perform. set to 0 for infinite

Definition at line 113 of file als.h.

◆ preserveCorePosition

bool xerus::ALSVariant::preserveCorePosition

if true the core will be moved to its original position at the end

Definition at line 117 of file als.h.

◆ sites

uint xerus::ALSVariant::sites

the number of sites that are simultaneously optimized

Definition at line 112 of file als.h.

◆ useResidualForEndCriterion

bool xerus::ALSVariant::useResidualForEndCriterion

calculates the residual to decide if the ALS converged. recommended if _perfdata is given. implied if assumeSPD = false

Definition at line 116 of file als.h.


The documentation for this class was generated from the following files: