Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #377

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ Install this package
]add BasicBSpline
```

## Example
## Quick start
### B-spline basis function

The value of B-spline basis function $B_{(i,p,k)}$ can be obtained with `bsplinebasis`. ([example in Desmos](https://www.desmos.com/calculator/ql6jqgdabs))
The value of B-spline basis function $B_{(i,p,k)}$ can be obtained with `bsplinebasis₊₀`. ([example in Desmos](https://www.desmos.com/calculator/ql6jqgdabs))

$$
\begin{aligned}
Expand All @@ -74,10 +74,10 @@ P1 = BSplineSpace{1}(k) # 1st degree piecewise polynomial space
P2 = BSplineSpace{2}(k) # 2nd degree piecewise polynomial space
P3 = BSplineSpace{3}(k) # 3rd degree piecewise polynomial space
plot(
plot([t->bsplinebasis(P0,i,t) for i in 1:dim(P0)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis(P1,i,t) for i in 1:dim(P1)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis(P2,i,t) for i in 1:dim(P2)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis(P3,i,t) for i in 1:dim(P3)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis₊₀(P0,i,t) for i in 1:dim(P0)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis₊₀(P1,i,t) for i in 1:dim(P1)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis₊₀(P2,i,t) for i in 1:dim(P2)], 0, 10, ylims=(0,1), legend=false),
plot([t->bsplinebasis₊₀(P3,i,t) for i in 1:dim(P3)], 0, 10, ylims=(0,1), legend=false),
layout=(2,2),
)
```
Expand Down
14 changes: 11 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ function generate_indexmd_from_readmemd()
text_index = text_readme
text_index = replace(text_index, "![](docs/src/img" => "![](img")
text_index = replace(text_index, r"\$\$((.|\n)*?)\$\$" => s"```math\1```")
text_index = replace(text_index, "(https://hyrodium.github.io/BasicBSpline.jl/dev/math/bsplinebasis/#Differentiability-and-knot-duplications)" => "(@ref differentiability-and-knot-duplications)")
text_index = replace(text_index, r"https://github.com/hyrodium/BasicBSpline\.jl/assets/.*" => "![](math/differentiability.mp4)")
text_index = """
```@meta
EditURL = "https://github.com/hyrodium/BasicBSpline.jl/blob/main/README.md"
```

""" * text_index

# save index.md
open(path_index, "w") do f
Expand All @@ -38,7 +46,7 @@ makedocs(;
modules = [BasicBSpline, BasicBSplineFitting],
format = Documenter.HTML(
ansicolor=true,
canonical = "https://hyrodium.github.io/BasicBSpline.jl/stable/",
canonical = "https://hyrodium.github.io/BasicBSpline.jl",
assets = ["assets/favicon.ico", "assets/custom.css"],
edit_link="main",
repolink="https://github.com/hyrodium/BasicBSpline.jl"
Expand All @@ -54,8 +62,8 @@ makedocs(;
"Derivative" => "math/derivative.md",
"Inclusive relationship" => "math/inclusive.md",
"Refinement" => "math/refinement.md",
"Fitting" => "math/fitting.md",
"Rational B-spline manifold" => "math/rationalbsplinemanifold.md",
"Fitting" => "math/fitting.md",
],
# "Differentiation" => [
# "BSplineDerivativeSpace" => "bsplinederivativespace.md",
Expand All @@ -71,9 +79,9 @@ makedocs(;
"Interpolations" => "interpolations.md",
"API" => "api.md",
],
repo = "https://github.com/hyrodium/BasicBSpline.jl/blob/{commit}{path}#L{line}",
sitename = "BasicBSpline.jl",
authors = "hyrodium <[email protected]>",
warnonly = true,
)

deploydocs(
Expand Down
7 changes: 7 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ bsplinebasis
BasicBSpline.bsplinebasis₋₀I
intervalindex
bsplinebasisall
bsplinesupport
dim
exactdim_R(P::BSplineSpace)
exactdim_I(P::BSplineSpace)
BSplineSpace
isnondegenerate
isdegenerate(P::BSplineSpace)
```

```@docs
Expand Down
174 changes: 0 additions & 174 deletions docs/src/index.md

This file was deleted.

22 changes: 16 additions & 6 deletions docs/src/math/bsplinebasis.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ In these cases, each B-spline basis function ``B_{(i,2,k)}`` is coninuous, so [`

[TODO: fig]

```@docs
bsplinesupport
```

## Partition of unity
!!! info "Thm. Partition of unity"
Let ``B_{(i,p,k)}`` be a B-spline basis function, then the following equation is satisfied.
Expand Down Expand Up @@ -155,7 +151,7 @@ Here are all of valiations of the B-spline basis function.
* [`bsplinebasis`](@ref)
* [`BasicBSpline.bsplinebasis₋₀I`](@ref)

## Differentiability and knot duplications
## [Differentiability and knot duplications](@id differentiability-and-knot-duplications)

The differentiability of the B-spline basis function depends on the duplications on the knot vector.

Expand Down Expand Up @@ -215,6 +211,20 @@ nothing # hide
Sometimes, you may need the non-zero values of B-spline basis functions at specific point.
The [`bsplinebasisall`](@ref) function is much more efficient than evaluating B-spline functions one by one with [`bsplinebasis`](@ref) function.

```@example math_bsplinebasis
P = BSplineSpace{2}(KnotVector([0.0, 1.5, 2.5, 5.5, 8.0, 9.0, 9.5, 10.0]))
t = 6.3
plot(P; label="P", ylims=(0,1))
scatter!(fill(t,3), [bsplinebasis(P,2,t), bsplinebasis(P,3,t), bsplinebasis(P,4,t)]; markershape=:hline, label="bsplinebasis")
scatter!(fill(t,3), bsplinebasisall(P, 2, t); markershape=:vline, label="bsplinebasisall")
savefig("bsplinebasis_vs_bsplinebasisall.png") # hide
nothing # hide
```

![](bsplinebasis_vs_bsplinebasisall.png)

Benchmark:

```@repl
using BenchmarkTools, BasicBSpline
P = BSplineSpace{2}(KnotVector([0.0, 1.5, 2.5, 5.5, 8.0, 9.0, 9.5, 10.0]))
Expand All @@ -237,7 +247,7 @@ for p in 1:3
plot(P, legend=:topleft, label="B-spline basis (p=1)")
plot!(t->intervalindex(P,t),0,10, label="Interval index")
plot!(t->sum(bsplinebasis(P,i,t) for i in 1:dim(P)),0,10, label="Sum of B-spline basis")
scatter!(k.vector,zero(k.vector), label="knot vector")
plot!(k, label="knot vector")
plot!([t->bsplinebasisall(P,1,t)[i] for i in 1:p+1],0,10, color=:black, label="bsplinebasisall (i=1)", ylim=(-1,8-2p))
savefig("bsplinebasisall-$(p).html") # hide
nothing # hide
Expand Down
42 changes: 21 additions & 21 deletions docs/src/math/bsplinespace.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# B-spline space

```@setup math
## Setup

```@example math_bsplinespace
using BasicBSpline
using BasicBSplineExporter
using StaticArrays
using Plots; plotly()
using Plots; gr()
```

## Defnition
Expand Down Expand Up @@ -52,10 +54,6 @@ Note that each element of the space ``\mathcal{P}[p,k]`` is a piecewise polynomi

[TODO: fig]

```@docs
BSplineSpace
```

## Degeneration

!!! tip "Def. Degeneration"
Expand All @@ -66,14 +64,6 @@ BSplineSpace
\end{aligned}
```

```@docs
isnondegenerate
```

```@docs
isdegenerate(P::BSplineSpace)
```

## Dimensions

!!! info "Thm. Dimension of B-spline space"
Expand All @@ -82,14 +72,24 @@ isdegenerate(P::BSplineSpace)
\dim(\mathcal{P}[p,k])=\# k - p -1
```

```@docs
dim
```@repl math_bsplinespace
P1 = BSplineSpace{1}(KnotVector([1,2,3,4,5,6,7]))
P2 = BSplineSpace{1}(KnotVector([1,2,4,4,4,6,7]))
P3 = BSplineSpace{1}(KnotVector([1,2,3,5,5,5,7]))
dim(P1), exactdim_R(P1), exactdim_I(P1)
dim(P2), exactdim_R(P2), exactdim_I(P2)
dim(P3), exactdim_R(P3), exactdim_I(P3)
```

```@docs
exactdim_R(P::BSplineSpace)
```
Visualization:

```@docs
exactdim_I(P::BSplineSpace)
```@example math_bsplinespace
pl1 = plot(P1); plot!(pl1, knotvector(P1))
pl2 = plot(P2); plot!(pl2, knotvector(P2))
pl3 = plot(P3); plot!(pl3, knotvector(P3))
plot(pl1, pl2, pl3; layout=(1,3), legend=false)
savefig("dimension-degeneration.png") # hide
nothing # hide
```

![](dimension-degeneration.png)
Loading
Loading