@@ -107,8 +107,13 @@ function standardLowRankFun(f::Function,dx::Space,dy::Space;tolerance::Union{Sym
107
107
ptsx,ptsy= points (dx,gridx),points (dy,gridy)
108
108
X = zeros (T,gridx,gridy)
109
109
maxabsf,r= findapproxmax! (f,X,ptsx,ptsy,gridx,gridy)
110
- if maxabsf < eps (zero (T))/ eps (T) return LowRankFun ([Fun (dx,[zero (T)])],[Fun (dy,[zero (T)])]),maxabsf end
111
- a,b= Fun (x-> f (x,r[2 ]),dx),Fun (y-> f (r[1 ],y),dy)
110
+ if maxabsf < eps (zero (T))/ eps (T)
111
+ return LowRankFun ([Fun (dx,[zero (T)])],[Fun (dy,[zero (T)])]), maxabsf
112
+ end
113
+
114
+ a,b= let r1= r[1 ], r2= r[2 ] # avoid boxing r
115
+ Fun (x-> f (x,r2),dx),Fun (y-> f (r1,y),dy)
116
+ end
112
117
113
118
# If necessary, we resize the grid to be at least as large as the
114
119
# lengths of the first row and column Funs and we recompute the values of X.
@@ -117,7 +122,9 @@ function standardLowRankFun(f::Function,dx::Space,dy::Space;tolerance::Union{Sym
117
122
ptsx,ptsy= points (dx,gridx),points (dy,gridy)
118
123
X = zeros (T,gridx,gridy)
119
124
maxabsf,r= findapproxmax! (f,X,ptsx,ptsy,gridx,gridy)
120
- a,b= Fun (x-> f (x,r[2 ]),dx),Fun (y-> f (r[1 ],y),dy)
125
+ a,b= let r1= r[1 ], r2= r[2 ]
126
+ Fun (x-> f (x,r2),dx),Fun (y-> f (r1,y),dy)
127
+ end
121
128
end
122
129
123
130
A,B= typeof (a)[],typeof (b)[]
@@ -161,8 +168,12 @@ function CholeskyLowRankFun(f::Function,dx::Space;tolerance::Union{Symbol,Tuple{
161
168
pts= points (dx,grid)
162
169
X = zeros (T,grid)
163
170
maxabsf,r= findcholeskyapproxmax! (f,X,pts,grid)
164
- if maxabsf < eps (zero (T))/ eps (T) return LowRankFun ([Fun (dx,[zero (T)])],[Fun (dx,[zero (T)])]),maxabsf end
165
- a= Fun (x-> f (x,r),dx)
171
+ if maxabsf < eps (zero (T))/ eps (T)
172
+ return LowRankFun ([Fun (dx,[zero (T)])],[Fun (dx,[zero (T)])]), maxabsf
173
+ end
174
+ a= let r= r # avoid boxing r
175
+ Fun (x-> f (x,r),dx)
176
+ end
166
177
167
178
# If necessary, we resize the grid to be at least as large as the
168
179
# ncoefficients of the first row/column Fun and we recompute the values of X.
@@ -171,7 +182,9 @@ function CholeskyLowRankFun(f::Function,dx::Space;tolerance::Union{Symbol,Tuple{
171
182
pts= points (dx,grid)
172
183
X = zeros (T,grid)
173
184
maxabsf,r= findcholeskyapproxmax! (f,X,pts,grid)
174
- a= Fun (x-> f (x,r),dx)
185
+ a= let r= r
186
+ Fun (x-> f (x,r),dx)
187
+ end
175
188
end
176
189
177
190
A,B= typeof (a)[],typeof (a)[]
0 commit comments