@@ -220,23 +220,32 @@ const Results = Union{AbstractResult,AbstractVector{<:PathResult}}
220
220
Return all [`PathResult`](@ref)s for which satisfy the given conditions and apply,
221
221
if provided, the function `f`.
222
222
"""
223
- results (R:: Results ; kwargs... ) = results (identity, R; kwargs... )
223
+ results (R:: AbstractResult ; kwargs... ) = results (identity, R; kwargs... )
224
224
function results (
225
225
f:: Function ,
226
- R:: Results ;
226
+ R:: AbstractResult ;
227
227
only_real:: Bool = false ,
228
228
real_tol:: Float64 = 1e-6 ,
229
229
only_nonsingular:: Bool = false ,
230
230
only_singular:: Bool = false ,
231
231
only_finite:: Bool = true ,
232
232
multiple_results:: Bool = false ,
233
233
)
234
+ if multiple_results == false && typeof (R)!= Result
235
+ println (" Warning: Since result is a ResultIterator, counting multiple results" )
236
+ multiple_results = true
237
+ end
234
238
filter_function = r -> (! only_real || is_real (r, real_tol)) &&
235
239
(! only_nonsingular || is_nonsingular (r)) &&
236
240
(! only_singular || is_singular (r)) &&
237
241
(! only_finite || is_finite (r)) &&
238
242
(multiple_results || ! is_multiple_result (r, R))
239
- imap (f,Iterators. filter (filter_function,R))
243
+ return_iter = imap (f,Iterators. filter (filter_function,R))
244
+ if typeof (R) == Result
245
+ return (collect (return_iter))
246
+ else
247
+ return (return_iter)
248
+ end
240
249
end
241
250
242
251
"""
@@ -289,7 +298,7 @@ julia> solutions(solve(F))
289
298
[-3.0 + 0.0im, 0.0 + 0.0im]
290
299
```
291
300
"""
292
- solutions (result:: Results ; only_nonsingular = true , kwargs... ) =
301
+ solutions (result:: AbstractResult ; only_nonsingular = true , kwargs... ) =
293
302
results (solution, result; only_nonsingular = only_nonsingular, kwargs... )
294
303
295
304
"""
@@ -309,7 +318,7 @@ julia> real_solutions(solve(F))
309
318
[-3.0, 0.0]
310
319
```
311
320
"""
312
- function real_solutions (result:: Results ; tol:: Float64 = 1e-6 , kwargs... )
321
+ function real_solutions (result:: AbstractResult ; tol:: Float64 = 1e-6 , kwargs... )
313
322
results (real ∘ solution, result; only_real = true , real_tol = tol, kwargs... )
314
323
end
315
324
@@ -321,7 +330,7 @@ Return all [`PathResult`](@ref)s for which the solution is non-singular.
321
330
This is just a shorthand for `results(R; only_nonsingular=true, conditions...)`.
322
331
For the possible `conditions` see [`results`](@ref).
323
332
"""
324
- nonsingular (R:: Results ; kwargs... ) = results (R; only_nonsingular = true , kwargs... )
333
+ nonsingular (R:: AbstractResult ; kwargs... ) = results (R; only_nonsingular = true , kwargs... )
325
334
326
335
"""
327
336
singular(result; multiple_results=false, kwargs...)
@@ -331,7 +340,7 @@ If `multiple_results=false` only one point from each cluster of multiple solutio
331
340
returned. If `multiple_results = true` all singular solutions in `R` are returned.
332
341
For the possible `kwargs` see [`results`](@ref).
333
342
"""
334
- function singular (R:: Results ; kwargs... )
343
+ function singular (R:: AbstractResult ; kwargs... )
335
344
results (R; only_singular = true , kwargs... )
336
345
end
337
346
@@ -361,7 +370,7 @@ at_infinity(R::Results) = filter(is_at_infinity, path_results(R))
361
370
362
371
The number of solutions. See [`results`](@ref) for the possible options.
363
372
"""
364
- nsolutions (R:: Results ; only_nonsingular = true , options... ) =
373
+ nsolutions (R:: AbstractResult ; only_nonsingular = true , options... ) =
365
374
nresults (R; only_nonsingular = only_nonsingular, options... )
366
375
367
376
"""
@@ -376,11 +385,12 @@ larger than 1 or the condition number is larger than `tol`.
376
385
If `counting_multiplicities=true` the number of singular solutions times their
377
386
multiplicities is returned.
378
387
"""
379
- function nsingular (R:: Results ; counting_multiplicities:: Bool = false , kwargs... )
380
- S = results (R; only_singular = true , multiple_results = false , kwargs... )
381
- isempty (S) && return 0
382
- counting_multiplicities && return sum (multiplicity, S)
383
- length (S)
388
+ function nsingular (R:: AbstractResult ; counting_multiplicities:: Bool = false , kwargs... )
389
+ if counting_multiplicities
390
+ return (nresults (R; only_singular = true , multiple_results = true , kwargs... ))
391
+ else
392
+ return (nresults (R; only_singular = true , multiple_results = true , kwargs... ))
393
+ end
384
394
end
385
395
386
396
@@ -417,8 +427,8 @@ nnonsingular(R::AbstractResult) = count(is_nonsingular, R)
417
427
418
428
The number of real solutions. See also [`is_real`](@ref).
419
429
"""
420
- nreal (R:: Result ; tol = 1e-6 ) = nresults (R, only_real = true , real_tol = tol)
421
-
430
+ nreal (R:: AbstractResult ; tol = 1e-6 ) = nresults (R, only_real = true , real_tol = tol)
431
+ nreal (R :: ResultIterator ; tol = 1e-6 ) = nresults (R, only_real = true , real_tol = tol, multiple_results = true )
422
432
423
433
"""
424
434
ntracked(result)
0 commit comments