Skip to content

Commit b0599ec

Browse files
committed
Update doc for global pivot finders
1 parent 65ce12c commit b0599ec

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

docs/src/index.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,27 +356,33 @@ A each TCI2 sweep, we can find the index sets with high interpolation error and
356356
By default, we use a greedy search algorithm to find the index sets with high interpolation error.
357357
However, this may not be effective in some cases.
358358
In such cases, you can use a custom global pivot finder, which must inherit from `TCI.AbstractGlobalPivotFinder`.
359+
Then, you can implement a call method for the global pivot finder with this signature:
360+
359361

360362
Here's an example of a custom global pivot finder that randomly selects pivots:
361363

362364
```julia
363365
import TensorCrossInterpolation as TCI
366+
import TensorCrossInterpolation: GlobalPivotSearchInput, MultiIndex, crossinterpolate2
367+
import Random: AbstractRNG
364368

365369
struct CustomGlobalPivotFinder <: TCI.AbstractGlobalPivotFinder
366370
npivots::Int
367371
end
368372

369373
function (finder::CustomGlobalPivotFinder)(
370-
tci::TensorCI2{ValueType},
374+
input::GlobalPivotSearchInput{ValueType},
371375
f,
372376
abstol::Float64;
373-
verbosity::Int=0
377+
verbosity::Int=0,
378+
rng::AbstractRNG=Random.default_rng()
374379
)::Vector{MultiIndex} where {ValueType}
375-
L = length(tci.localdims)
376-
return [[rand(1:tci.localdims[p]) for p in 1:L] for _ in 1:finder.npivots]
380+
return [[rand(1:input.localdims[p]) for p in 1:L] for _ in 1:finder.npivots]
377381
end
378382
```
379383

384+
Note that the `GlobalPivotSearchInput` object contains the local dimensions of the TCI2 object, the function to be interpolated, and the tolerance, and the current pivots, etc. See [`GlobalPivotSearchInput`](@ref) for more details.
385+
380386
You can use this custom finder by passing it to the `optimize!` function:
381387

382388
```julia

0 commit comments

Comments
 (0)