Skip to content

Commit 591b366

Browse files
authored
Merge branch 'main' into sorted
2 parents 18e1dd5 + 9d539e6 commit 591b366

File tree

9 files changed

+171
-4
lines changed

9 files changed

+171
-4
lines changed

.github/workflows/Documentation.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Documentation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags: '*'
7+
pull_request:
8+
schedule:
9+
- cron: '47 20 * * 0'
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
15+
- uses: julia-actions/setup-julia@latest
16+
with:
17+
version: '1'
18+
- name: Install dependencies
19+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
20+
- name: Build and deploy
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
23+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
24+
run: julia --project=docs/ docs/make.jl
25+
- uses: julia-actions/julia-processcoverage@v1
26+
with:
27+
directories: src
28+
- uses: codecov/codecov-action@v3
29+
with:
30+
files: lcov.info

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FindFirstFunctions"
22
uuid = "64ca27bc-2ba2-4a57-88aa-44e436879224"
33
authors = ["Chris Elrod <[email protected]> and contributors"]
4-
version = "1.1.0"
4+
version = "1.2.0"
55

66
[compat]
77
julia = "1.8"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ See `sort!` for an explanation of the keyword arguments `by`, `lt` and `rev`.
4141
### `searchsortedfirstcorrelated(v::AbstractVector, x, guess)`
4242

4343
```julia
44-
searchsortedfirstcorrelated(v::AbstractVector, x, guess)
44+
searchsortedfirstcorrelated(v::AbstractVector{T}, x, guess::T)
4545
```
4646

4747
An accelerated `findfirst` on sorted vectors using a bracketed search. Requires a `guess`

docs/Project.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[deps]
2+
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
5+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
6+
RegularizationTools = "29dad682-9a27-4bc3-9c72-016788665182"
7+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
8+
9+
[compat]
10+
DataInterpolations = "4"
11+
Documenter = "1"
12+
Optim = "1"
13+
Plots = "1"
14+
RegularizationTools = "0.6"
15+
StableRNGs = "1"

docs/make.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Documenter, FindFirstFunctions
2+
3+
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
4+
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
5+
6+
ENV["GKSwstype"] = "100"
7+
8+
makedocs(modules = [FindFirstFunctions],
9+
sitename = "FindFirstFunctions.jl",
10+
clean = true,
11+
doctest = false,
12+
linkcheck = true,
13+
warnonly = [:missing_docs],
14+
format = Documenter.HTML(assets = ["assets/favicon.ico"],
15+
canonical = "https://docs.sciml.ai/FindFirstFunctions/stable/"),
16+
pages = ["index.md"])
17+
18+
deploydocs(repo = "github.com/SciML/FindFirstFunctions.jl"; push_preview = true)

docs/src/assets/favicon.ico

1.36 KB
Binary file not shown.

docs/src/assets/logo.png

26 KB
Loading

docs/src/index.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# FindFirstFunctions.jl
2+
3+
FindFirstFunctions.jl is a library for accelerated `findfirst` type functions.
4+
5+
## Installation
6+
7+
To install FindFirstFunctions.jl, use the Julia package manager:
8+
9+
```julia
10+
using Pkg
11+
Pkg.add("FindFirstFunctions")
12+
```
13+
14+
## Available Functions
15+
16+
```@docs
17+
FindFirstFunctions.findfirstequal
18+
FindFirstFunctions.bracketstrictlymontonic
19+
FindFirstFunctions.searchsortedfirstcorrelated
20+
```
21+
22+
## Contributing
23+
24+
- Please refer to the
25+
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
26+
for guidance on PRs, issues, and other matters relating to contributing to SciML.
27+
28+
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
29+
- There are a few community forums:
30+
31+
+ The #diffeq-bridged and #sciml-bridged channels in the
32+
[Julia Slack](https://julialang.org/slack/)
33+
+ The #diffeq-bridged and #sciml-bridged channels in the
34+
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
35+
+ On the [Julia Discourse forums](https://discourse.julialang.org)
36+
+ See also [SciML Community page](https://sciml.ai/community/)
37+
38+
## Reproducibility
39+
40+
```@raw html
41+
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
42+
```
43+
44+
```@example
45+
using Pkg # hide
46+
Pkg.status() # hide
47+
```
48+
49+
```@raw html
50+
</details>
51+
```
52+
53+
```@raw html
54+
<details><summary>and using this machine and Julia version.</summary>
55+
```
56+
57+
```@example
58+
using InteractiveUtils # hide
59+
versioninfo() # hide
60+
```
61+
62+
```@raw html
63+
</details>
64+
```
65+
66+
```@raw html
67+
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
68+
```
69+
70+
```@example
71+
using Pkg # hide
72+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
73+
```
74+
75+
```@raw html
76+
</details>
77+
```
78+
79+
```@eval
80+
using TOML
81+
using Markdown
82+
version = TOML.parse(read("../../Project.toml", String))["version"]
83+
name = TOML.parse(read("../../Project.toml", String))["name"]
84+
link_manifest = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
85+
"/assets/Manifest.toml"
86+
link_project = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
87+
"/assets/Project.toml"
88+
Markdown.parse("""You can also download the
89+
[manifest]($link_manifest)
90+
file and the
91+
[project]($link_project)
92+
file.
93+
""")
94+
```

src/FindFirstFunctions.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module FindFirstFunctions
22

3-
43
function _findfirstequal(vpivot::Int64, ptr::Ptr{Int64}, len::Int64)
54
Base.llvmcall(("""
65
declare i8 @llvm.cttz.i8(i8, i1);
@@ -65,6 +64,11 @@ function _findfirstequal(vpivot::Int64, ptr::Ptr{Int64}, len::Int64)
6564
len)
6665
end
6766

67+
"""
68+
findfirstequal(x::Int64,A::DenseVector{Int64})
69+
70+
Finds the first value in `A` equal to `x`
71+
"""
6872
findfirstequal(vpivot, ivars) = findfirst(isequal(vpivot), ivars)
6973
function findfirstequal(vpivot::Int64, ivars::DenseVector{Int64})
7074
GC.@preserve ivars begin
@@ -113,7 +117,7 @@ purpose of using this function first would be to accelerate convergence in those
113117
by using correlated `guess`es for repeated calls. The best `guess` for the next call of
114118
this function would be the index returned by the previous call to `searchsorted`.
115119
116-
See [`sort!`](@ref) for an explanation of the keyword arguments `by`, `lt` and `rev`.
120+
See `Base.sort!` for an explanation of the keyword arguments `by`, `lt` and `rev`.
117121
"""
118122
function bracketstrictlymontonic(v::AbstractVector,
119123
x,
@@ -148,6 +152,12 @@ function bracketstrictlymontonic(v::AbstractVector,
148152
return lo, hi
149153
end
150154

155+
"""
156+
searchsortedfirstcorrelated(v::AbstractVector{T}, x, guess)
157+
158+
An accelerated `findfirst` on sorted vectors using a bracketed search. Requires a `guess::T`
159+
to start the search from.
160+
"""
151161
function searchsortedfirstcorrelated(v::AbstractVector, x, guess)
152162
lo, hi = bracketstrictlymontonic(v, x, guess, Base.Order.Forward)
153163
searchsortedfirst(v, x, lo, hi, Base.Order.Forward)

0 commit comments

Comments
 (0)