Skip to content
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
73 changes: 63 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
# The test items tagged `slow` (the AD cross-check harness and the exp/log AD tests) take
# most of the suite's CPU time, so the OS matrix skips them, and the `slow` job below runs
# them once, on Ubuntu with the latest Julia. The other test items tagged `ad`, which
# spend most of their time compiling the AD packages, run only on Ubuntu, because the AD
# code paths do not depend on the operating system. Coverage is uploaded only from the
# Ubuntu job with the latest Julia and the `slow` job, which together run the whole suite.
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
Expand All @@ -36,7 +42,6 @@ jobs:
include:
- version: 'lts'
os: ubuntu-latest
arch: x64
steps:
- uses: actions/checkout@v7
- uses: julia-actions/setup-julia@v3
Expand All @@ -46,20 +51,69 @@ jobs:
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
test_args: ${{ matrix.os == 'ubuntu-latest' && '--exclude slow' || '--exclude slow,ad' }}
- uses: julia-actions/julia-processcoverage@v1
if: matrix.os == 'ubuntu-latest' && matrix.version == '1'
- uses: codecov/codecov-action@v7
if: "matrix.os == 'ubuntu-latest'"
if: matrix.os == 'ubuntu-latest' && matrix.version == '1'
with:
files: lcov.info
flags: fast
token: ${{ secrets.CODECOV_TOKEN }}

slow:
name: Slow tests - Julia 1 - ubuntu-latest - ${{ github.event_name }}
runs-on: ubuntu-latest
if: >-
!contains(github.ref, 'refs/tags/')
&& !contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip tests]')
steps:
- uses: actions/checkout@v7
- uses: julia-actions/setup-julia@v3
with:
version: '1'
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
test_args: '--tags slow'
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v7
with:
files: lcov.info
flags: slow
token: ${{ secrets.CODECOV_TOKEN }}

# The workspace test environment cannot be instantiated before Julia 1.9, so the oldest
# supported Julia runs a few smoke tests in a fresh environment instead.
compat16:
name: Smoke tests - Julia 1.6 - ubuntu-latest - ${{ github.event_name }}
runs-on: ubuntu-latest
if: >-
!contains(github.ref, 'refs/tags/')
&& !contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip tests]')
steps:
- uses: actions/checkout@v7
- uses: julia-actions/setup-julia@v3
with:
version: '1.6'
- uses: julia-actions/cache@v3
- run: julia --project=compat16 -e 'using Pkg; Pkg.develop(path="."); Pkg.add(["ChainRulesCore", "ForwardDiff", "StaticArrays"])'
- run: julia --project=compat16 test/compat16_smoke.jl

# The docs job does not wait for the tests, so that the docs (and their previews on pull
# requests) can be checked even while some tests fail.
docs:
name: Documentation
runs-on: ubuntu-latest
if: >-
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip docs]')
permissions:
actions: write
contents: write
statuses: write
pull-requests: write
Expand All @@ -68,19 +122,18 @@ jobs:
- uses: julia-actions/setup-julia@v3
with:
version: '1'
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using Quaternionic
DocMeta.setdocmeta!(Quaternionic, :DocTestSetup, :(using Quaternionic); recursive=true)
doctest(Quaternionic)'
# A pull request from a fork has a read-only token, so it can neither comment nor
# deploy a preview.
- uses: marocchino/sticky-pull-request-comment@v3
if: github.event_name == 'pull_request'
if: >-
github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository
with:
message: |
[Documentation preview](https://moble.github.io/Quaternionic.jl/previews/PR${{ github.event.pull_request.number }}/)
[Documentation preview](https://moble.github.io/Quaternionic.jl/previews/PR${{ github.event.pull_request.number }}/)
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

# Files generated by invoking Julia with --track-allocation
*.jl.mem
*.jl.*.mem

# HTML coverage reports generated with genhtml (see test/runtests.jl)
/coverage/

# Python environments created by CondaPkg, and macOS metadata
.CondaPkg/
.DS_Store

# System-specific files and directories generated by the BinaryProvider and BinDeps packages
# They contain absolute paths specific to the host computer, and so should not be committed
Expand Down
39 changes: 29 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,71 @@ projects = ["test", "docs"]

[deps]
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

# ChainRules and Enzyme appear in [weakdeps] and [compat] partly to bound their versions:
# the ChainRules opt-outs were audited against ChainRules 1.73, and Enzyme's floor matches
# the EnzymeRules API used by QuaternionicEnzymeExt.
[weakdeps]
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
FastDifferentiation = "eb9bf01b-bf85-4b60-bf87-ee5de06c00be"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[extensions]
QuaternionicChainRulesCoreExt = "ChainRulesCore"
QuaternionicChainRulesExt = ["ChainRules", "ChainRulesCore"]
QuaternionicDifferentiationInterfaceExt = "DifferentiationInterface"
QuaternionicEnzymeExt = "Enzyme"
QuaternionicFastDifferentiationExt = "FastDifferentiation"
QuaternionicForwardDiffExt = "ForwardDiff"
QuaternionicLatexifyExt = "Latexify"
QuaternionicMooncakeExt = ["Mooncake", "ChainRulesCore"]
QuaternionicReverseDiffExt = "ReverseDiff"
QuaternionicSymbolicsExt = "Symbolics"
QuaternionicZygoteExt = ["Zygote", "ZygoteRules", "ChainRulesCore", "StaticArraysCore"]
QuaternionicZygoteExt = ["Zygote", "ChainRulesCore"]

# Every [weakdeps] entry is repeated here, so that Pkg before Julia 1.9, which does not
# know about [weakdeps], accepts their [compat] entries.
[extras]
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
FastDifferentiation = "eb9bf01b-bf85-4b60-bf87-ee5de06c00be"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
ChainRules = "1.72.6"
ChainRulesCore = "1"
ChainRulesCore = "1.15"
DifferentiationInterface = "0.7"
Enzyme = "0.13.82"
FastDifferentiation = "0.3.15, 0.4"
FastDifferentiation = "0.4"
ForwardDiff = "0.10, 1"
GenericLinearAlgebra = "0.3.11, 0.4"
LaTeXStrings = "1"
Latexify = "0.15, 0.16"
LinearAlgebra = "1, < 0.0.1"
Mooncake = "0.4.161, 0.5"
PrecompileTools = "1.2"
Random = "1, < 0.0.1"
Requires = "1"
ReverseDiff = "1.15"
StaticArrays = "1.8.1"
StaticArraysCore = "1.4.3"
Symbolics = "0.1, 1, 2, 3, 4, 5, 6, 7"
Zygote = "0.7.10"
ZygoteRules = "0.2.7"
julia = "1.6"
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Pkg.add("Quaternionic")
```

## Usage
See [the documentation](https://moble.github.io/Quaternionic.jl/dev) for details.
See [the documentation](https://moble.github.io/Quaternionic.jl/stable/) for details.

## Motivation
The goal of this project is to build a complete quaternion type in Julia. There are
Expand All @@ -28,11 +28,10 @@ several features that I consider to be fairly basic to a good quaternion package
* Subtypes for rotors and pure-vector quaternions, with corresponding specialized methods
* Numerous conversions to and from other representations of things quaternions can
represent — especially rotations
* Smooth interpolation, and differentation of the interpolant
* Smooth interpolation, and differentiation of the interpolant
* Intelligent handling of distance measures
* Construction of random quaternions of the various special types
* Enabling efficient integration of angular velocity
* Construction of a minimal rotation
* Documentation
* Thorough testing

Expand Down
22 changes: 17 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ makedocs(;
remotes=notes_remotes,
pages=[
"Introduction" => "index.md",
"Basics" => "manual.md",
"Manual" => [
"Types and construction" => "types.md",
"Algebra and mathematical functions" => "math.md",
"Rotations and conversions" => "conversions.md",
"Distances and alignment" => "distances.md",
"Lorentz transformations" => "lorentz.md",
],
"Functions of time" => "functions_of_time.md",
"Differentiating by quaternions" => "differentiation.md",
"All functions" => "functions.md",
"Geometric Algebra" => "geometric_algebra.md",
"Spacetime Algebra" => "spacetime_algebra.md",
"Differentiating by quaternionic arguments" => "differentiation.md",
"Theory" => [
"Geometric algebra" => "geometric_algebra.md",
"Spacetime algebra" => "spacetime_algebra.md",
],
"References" => "references.md",
notes_pages...,
"API index" => "api.md",
],
# Every exported or public name must be documented. Internal helpers, such as
# `squad_control_points`, may have docstrings that are deliberately left out.
checkdocs=:public,
# doctest = false,
doctestfilters = [
# Drop any digit after the 12th digit after a decimal, throughout the docs
Expand Down
25 changes: 23 additions & 2 deletions docs/serve.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
# This simply uses `make.jl` in this directory to build the docs, then serves them locally.
# Run `julia --project=docs docs/serve.jl` from the top directory to execute this script.
#
# LiveServer rebuilds the docs whenever a file in `docs/src` or in the package's `src`
# changes. Docstring edits in `src` appear in the rebuilt docs only if Revise is available
# (for example, from the default global environment), because otherwise the package is not
# reloaded between builds.

# Activate the docs environment even if this script was started with another project (for
# example, `--project=.`), because the doctests need packages such as Symbolics that only
# the docs environment provides.
import Pkg
Pkg.activate(@__DIR__)

try
using Revise
catch
@warn "Revise is not available, so docstring edits will not appear until the server is restarted."
else
using Quaternionic
end

#using Quaternionic
import LiveServer: servedocs

servedocs(; launch_browser=true)
servedocs(;
include_dirs=["src/", realpath(joinpath("docs", "src", "local_notes"))],
launch_browser=true,
)
26 changes: 26 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# API index

This page lists every documented function, type, and constant that the package
exports or declares public, with links to their documentation on the other pages.
Internal helper functions are not listed.

Some of these functions are defined in `Quaternionic`, while others extend functions
from Julia's `Base` and `LinearAlgebra` modules, such as `conj`, `abs`, `exp`, `log`,
`randn`, `normalize`, `⋅` (also known as `dot`), and `×` (also known as `cross`).
Many other functions from `Base` that are not listed here have also been extended to
work with quaternionic types, so that quaternions can generally function as numbers.
These include `+`, `-`, `*`, `/`, `inv`, `==`, `isequal`, `isnan`, `isinf`, `iszero`,
`isone`, `show`, `read`, `write`, `hash`, `promote_rule`, and so on. They are not
separately documented, but should behave analogously to their behavior with `Complex`
numbers.

A few exported names are documented together with closely related names: `distance2`
with [`distance`](@ref); the type aliases `QuaternionF64`, `QuaternionF32`, and
`QuaternionF16` with [`Quaternion`](@ref), and similarly for [`Rotor`](@ref) and
[`QuatVec`](@ref). Names that are public but not
exported, such as [`Quaternionic.value`](@ref) and [`Quaternionic.KAN`](@ref), must be
qualified with the module name or imported explicitly.

```@index
Modules = [Quaternionic, Base, LinearAlgebra]
```
14 changes: 14 additions & 0 deletions docs/src/conversions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Rotations and conversions

It can sometimes be useful to convert between quaternions and other
representations. Most of these functions are named `to_<representation>` and
have a corresponding `from_<representation>` function. Furthermore, most
convert to/from representations of rotations. While rotations are not the only
useful application of quaternions, they are probably the most common. The only
conversions that are not specifically related to rotations are
[`to_float_array`](@ref) and [`from_float_array`](@ref).

```@autodocs
Modules = [Quaternionic]
Pages = ["conversion.jl"]
```
Loading
Loading