This commit is contained in:
Valentin Boettcher 2023-03-10 11:24:52 -05:00
parent 6abf712764
commit fa996de265
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE
6 changed files with 52 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/Manifest.toml
/.direnv/
docs/build

View file

@ -5,6 +5,7 @@ version = "0.1.0"
[deps]
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

5
docs/make.jl Normal file
View file

@ -0,0 +1,5 @@
push!(LOAD_PATH,"../src/")
using Documenter, Looping
DocMeta.setdocmeta!(Looping.Utilities, :DocTestSetup, :(using Looping.Utilities); recursive=true)
makedocs(sitename="Looping Documentation", modules=[Looping.Utilities], draft=false, strict=:doctest)

11
docs/src/index.md Normal file
View file

@ -0,0 +1,11 @@
# Looping.jl Documentation
Some numerical tools and experiments for the fiber loop reservoir
engineering project.
```@contents
Pages = ["modules/Utilities.md"]
Depth = 3
```

View file

@ -0,0 +1,17 @@
# Utilities
```@docs
Looping.Utilities
```
```@meta
CurrentModule = Looping.Utilities
```
```@docs
periodic_distance
restrict_to_range
```

View file

@ -1,3 +1,6 @@
"""
Some common utilities that haven't yet made it into their own packagage.
"""
module Utilities
export periodic_distance
@ -11,9 +14,10 @@ conditions for a chain of length `N`.
# Examples
```jldoctest
julia> periodic_difference(1,4,5)
julia> periodic_distance(1, 4, 5)
2
julia> periodic_difference(1,3,5)
julia> periodic_distance(1, 3, 5)
-2
```
"""
@ -32,7 +36,17 @@ end
"""
restrict_to_range(x, border)
Returns the value `x` restricted to the range `[-border, border]`.
Returns the value `x` restricted to the range `[-border, border]` by
lettting it roll over to `+-border`.
# Examples
```jldoctest
julia> restrict_to_range(6, 5)
-4
julia> restrict_to_range(5, 5)
5
```
"""
function restrict_to_range(x::Real, border::Real)
sign = x border ? -1 : 1