Skip to content

Commit d7f113b

Browse files
committed
docstrings
1 parent fe0eb8a commit d7f113b

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/contraction.jl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,31 @@ function contract_TCI(
399399
)
400400
end
401401

402+
"""
403+
function contract(
404+
A::TensorTrain{ValueType,4},
405+
B::TensorTrain{ValueType,4};
406+
algorithm::Symbol=:TCI,
407+
tolerance::Float64=1e-12,
408+
maxbonddim::Int=typemax(Int),
409+
f::Union{Nothing,Function}=nothing,
410+
kwargs...
411+
) where {ValueType}
412+
413+
Contract two tensor trains `A` and `B`.
414+
415+
Currently, two implementations are available:
416+
1. `algorithm=:TCI` constructs a new TCI that fits the contraction of `A` and `B`.
417+
2. `algorithm=:naive` uses a naive tensor contraction and subsequent SVD recompression of the tensor train.
418+
419+
Arguments:
420+
- `A` and `B` are the tensor trains to be contracted.
421+
- `algorithm` chooses the algorithm used to evaluate the contraction.
422+
- `tolerance` is the tolerance of the TCI or SVD recompression.
423+
- `maxbonddim` sets the maximum bond dimension of the resulting tensor train.
424+
- `f` is a function to be applied elementwise to the result. This option is only available with `algorithm=:TCI`.
425+
- `kwargs...` are forwarded to [`crossinterpolate2`](@ref) if `algorithm=:TCI`.
426+
"""
402427
function contract(
403428
A::TensorTrain{ValueType,4},
404429
B::TensorTrain{ValueType,4};
@@ -411,7 +436,7 @@ function contract(
411436
if algorithm === :TCI
412437
return contract_TCI(A, B; tolerance=tolerance, maxbonddim=maxbonddim, f=f, kwargs...)
413438
elseif algorithm === :naive
414-
return contract_naive(A, B)
439+
return contract_naive(A, B; tolerance=tolerance, maxbonddim=maxbonddim)
415440
else
416441
throw(ArgumentError("Unknown algorithm $algorithm."))
417442
end

src/integration.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
Integrate the function `f` using TCI and Gauss--Kronrod quadrature rules.
1212
1313
Arguments:
14-
- ValueType: return type of `f`.
15-
- a: Vector of lower bounds in each dimension. Effectively, the lower corner of the hypercube that is being integrated over.
16-
- b: Vector of upper bounds in each dimension.
17-
- tolerance: tolerance of the TCI approximation for the values of f.
18-
- GKorder: Order of the Gauss--Kronrod rule, e.g. 15.
14+
- `ValueType``: return type of `f`.
15+
- `a``: Vector of lower bounds in each dimension. Effectively, the lower corner of the hypercube that is being integrated over.
16+
- `b``: Vector of upper bounds in each dimension.
17+
- `tolerance`: tolerance of the TCI approximation for the values of f.
18+
- `GKorder`: Order of the Gauss--Kronrod rule, e.g. 15.
1919
"""
2020
function integrate(
2121
::Type{ValueType},

0 commit comments

Comments
 (0)