Skip to content

Commit d020ead

Browse files
committed
Add missing file
1 parent 12715e2 commit d020ead

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/globalpivotfinder.jl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
"""
3+
Default implementation of global pivot finder that uses random search.
4+
"""
5+
struct DefaultGlobalPivotFinder <: AbstractGlobalPivotFinder
6+
nsearch::Int
7+
maxnglobalpivot::Int
8+
tolmarginglobalsearch::Float64
9+
end
10+
11+
# Constructor for backward compatibility
12+
function DefaultGlobalPivotFinder(;
13+
nsearch::Int=5,
14+
maxnglobalpivot::Int=5,
15+
tolmarginglobalsearch::Float64=10.0
16+
)
17+
return DefaultGlobalPivotFinder(nsearch, maxnglobalpivot, tolmarginglobalsearch)
18+
end
19+
20+
"""
21+
Find global pivots where the interpolation error exceeds the tolerance.
22+
"""
23+
function (finder::AbstractGlobalPivotFinder)(
24+
tci::TensorCI2{ValueType},
25+
f,
26+
abstol::Float64;
27+
verbosity::Int=0
28+
)::Vector{MultiIndex} where {ValueType}
29+
error("find_global_pivots not implemented for $(typeof(finder))")
30+
end
31+
32+
# Default implementation using the existing searchglobalpivots
33+
function (finder::DefaultGlobalPivotFinder)(
34+
tci::TensorCI2{ValueType},
35+
f,
36+
abstol::Float64;
37+
verbosity::Int=0
38+
)::Vector{MultiIndex} where {ValueType}
39+
return searchglobalpivots(
40+
tci, f, finder.tolmarginglobalsearch * abstol,
41+
verbosity=verbosity,
42+
nsearch=finder.nsearch,
43+
maxnglobalpivot=finder.maxnglobalpivot
44+
)
45+
end
46+
47+
# Helper function for backward compatibility
48+
function _create_default_finder(;
49+
nsearch::Int=5,
50+
maxnglobalpivot::Int=5,
51+
tolmarginglobalsearch::Float64=10.0
52+
)
53+
return DefaultGlobalPivotFinder(
54+
nsearch=nsearch,
55+
maxnglobalpivot=maxnglobalpivot,
56+
tolmarginglobalsearch=tolmarginglobalsearch
57+
)
58+
end

0 commit comments

Comments
 (0)