27 #include "../ttNetwork.h" 28 #include "../performanceData.h" 135 bool _useResidual=
false 137 : sites(_sites), numHalfSweeps(_numHalfSweeps), convergenceEpsilon(1e-6),
138 useResidualForEndCriterion(_useResidual), preserveCorePosition(true), assumeSPD(_assumeSPD), localSolver(_localSolver)
153 return solve(&_A, _x, _b, numHalfSweeps, _convergenceEpsilon, _perfData);
166 return solve(&_A, _x, _b, _numHalfSweeps, convergenceEpsilon, _perfData);
178 return solve(&_A, _x, _b, numHalfSweeps, convergenceEpsilon, _perfData);
190 return solve(
nullptr, _x, _b, numHalfSweeps, _convergenceEpsilon, _perfData);
202 return solve(
nullptr, _x, _b, _numHalfSweeps, convergenceEpsilon, _perfData);
206 return solve(
nullptr, _x, _b, numHalfSweeps, convergenceEpsilon, _perfData);
double operator()(TTTensor &_x, const TTTensor &_b, value_t _convergenceEpsilon, PerformanceData &_perfData=NoPerfData) const
TensorNetwork construct_local_operator(ALSAlgorithmicData &_data) const
value_t lastEnergy2
energy at the end of last full sweep
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)
const ALSVariant ASD
default variant of the alternating steepest descent for non-symmetric operators
const ALSVariant ASD_SPD
default variant of the alternating steepest descent for symmetric positive-definite operators ...
value_t normB
norm of the (global) right hand side
double operator()(const TTOperator &_A, TTTensor &_x, const TTTensor &_b, value_t _convergenceEpsilon, PerformanceData &_perfData=NoPerfData) const
value_t energy
current value of the energy residual
Very general class used to represent arbitary tensor networks.
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 ...
std::function< value_t()> energy_f
the energy functional used for this calculation
TensorNetwork localOperatorSlice(size_t _pos)
ContractedTNCache rhsCache
stacks for the right-hand-side (either xb or xAtb)
double operator()(const TTOperator &_A, TTTensor &_x, const TTTensor &_b, size_t _numHalfSweeps, PerformanceData &_perfData=NoPerfData) const
const size_t FLAG_FINISHED_HALFSWEEP
Specialized TensorNetwork class used to represent TTTensor and TToperators.
size_t halfSweepCount
current count of halfSweeps
The main namespace of xerus.
size_t corePosAtTheEnd
core position that should be restored at the end of the algorithm
void prepare_stacks()
prepares the initial stacks for the local operator and local right-hand-side
void move_to_next_index()
performs one step in direction, updating all stacks
void prepare_x_for_als()
Finds the range of notes that need to be optimized and orthogonalizes _x properly.
std::pair< size_t, size_t > optimizedRange
range of indices for the nodes of _x that need to be optimized
uint sites
the number of sites that are simultaneously optimized
std::function< value_t()> residual_f
the functional to calculate the current residual
Wrapper class for all ALS variants (dmrg etc.)
const TTTensor & b
global right-hand-side
bool preserveCorePosition
if true the core will be moved to its original position at the end
double operator()(const TTOperator &_A, TTTensor &_x, const TTTensor &_b, PerformanceData &_perfData=NoPerfData) const
TensorNetwork construct_local_RHS(ALSAlgorithmicData &_data) const
const TTOperator * A
global operator A
bool assumeSPD
if true the operator A will be assumed to be symmetric positive definite
size_t currIndex
position that is currently being optimized
double solve(const TTOperator *_Ap, TTTensor &_x, const TTTensor &_b, size_t _numHalfSweeps, value_t _convergenceEpsilon, PerformanceData &_perfData=NoPerfData) const
std::vector< size_t > targetRank
rank for the final x
value_t lastEnergy
energy at the end of last halfsweep
double operator()(TTTensor &_x, const TTTensor &_b, size_t _numHalfSweeps, PerformanceData &_perfData=NoPerfData) const
#define XERUS_REQUIRE(condition, message)
Checks whether condition is true. logs an error otherwise via XERUS_LOG(error, message).
PerformanceData NoPerfData
void choose_energy_functional()
chooses the fitting energy functional according to settings and whether an operator A was given ...
std::function< void(const TensorNetwork &, std::vector< Tensor > &, const TensorNetwork &, const ALSAlgorithmicData &)> LocalSolver
the algorithm that is used to solve the local problems
bool check_for_end_of_sweep(ALSAlgorithmicData &_data, size_t _numHalfSweeps, value_t _convergenceEpsilon, PerformanceData &_perfData) const
bool useResidualForEndCriterion
calculates the residual to decide if the ALS converged. recommended if _perfdata is given...
TTTensor & x
current iterate x
double value_t
The type of values to be used by xerus.
TensorNetwork localRhsSlice(size_t _pos)
static void ASD_solver(const TensorNetwork &_A, std::vector< Tensor > &_x, const TensorNetwork &_b, const ALSAlgorithmicData &_data)
const ALSVariant & ALS
the algorithm this data belongs to
const ALSVariant DMRG
default variant of the two-site DMRG algorithm for non-symmetric operators using the lapack solver ...
bool canonicalizeAtTheEnd
whether _x should be canonicalized at the end
const size_t FLAG_FINISHED_FULLSWEEP
size_t numHalfSweeps
maximum number of sweeps to perform. set to 0 for infinite
ALSAlgorithmicData(const ALSVariant &, const TTOperator *, TTTensor &, const TTTensor &)
double operator()(TTTensor &_x, const TTTensor &_b, PerformanceData &_perfData=NoPerfData) const
Direction direction
direction of current sweep
std::vector< Tensor > right
const ALSVariant DMRG_SPD
default variant of the two-site DMRG algorithm for symmetric positive-definite operators using the la...
const ALSVariant ALS_SPD
default variant of the single-site ALS algorithm for symmetric positive-definite operators using the ...
value_t convergenceEpsilon
default value for the change in the energy functional at which the ALS assumes it is converged ...
std::vector< Tensor > left
ContractedTNCache localOperatorCache
stacks for the local operator (either xAx or xAtAx)