Skip to content

Commit 9de0d2b

Browse files
committed
Add sample_layout
1 parent 249b4b0 commit 9de0d2b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.15.7"
4+
version = "0.15.8"
55

66

77
[deps]

src/roots.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ function _searchsortedfirst(::ExpansionLayout{<:AbstractOPLayout}, f, x; iterati
5151
end
5252
searchsortedfirst(f::AbstractQuasiVector, x; kwds...) = _searchsortedfirst(MemoryLayout(f), f, x; kwds...)
5353

54-
function sample(f::AbstractQuasiVector, n...)
54+
sample(f::AbstractQuasiArray, n...) = sample_layout(MemoryLayout(f), f, n...)
55+
56+
function sample_layout(_, f::AbstractQuasiVector, n...)
5557
g = cumsum(f)
5658
searchsortedfirst.(Ref(g/last(g)), rand(n...))
5759
end
5860

61+
function sample_layout(_, f::AbstractQuasiMatrix, n...)
62+
@assert size(f,2) == 1 # TODO generalise
63+
sample(f[:,1], n...)
64+
end
65+
5966
####
6067
# min/max/extrema
6168
####

0 commit comments

Comments
 (0)