Skip to content
Draft
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
24 changes: 24 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# StaticThings.jl news

## v0.3.0

Breaking:

* `maybestatic_reshape(A, sz)` only returns a static array if `A` is one.
It used to wrap any array in a `StaticArrays.SArray` for a static `sz`,
which copies device arrays and traced arrays to the host. The input
decides now: a static-size variate taken from a plain `Vector` is a
plain array or view, one taken from an `SVector` stays static.

New:

* `size_dims(sz)`, the inverse of `canonical_size`, and a type-level
`axes2size(::Type{<:Tuple{Vararg{StaticOneToLike}}})`.
* `static_mapreduce(f, op, T)`, `static_reduce(op, T)`, `static_all(f, T)`
and `static_any(f, T)`, pairwise folds over the element types of a tuple
type that infer as compile-time constants.
* `sum_leading_dims(A, n)`, `drop_leading_dims(A, n)`,
`merge_leading_dims(A, n)` and `all_leading_dims(A, n)` over a static
number of leading dimensions, keeping static arrays static.
* `maybestatic_view(A, r)` and `split_at(A, n)`, views and splits of
vectors and tuples that stay static for static inputs and indices.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StaticThings"
uuid = "7e4b4f32-fbf9-4b74-9510-4d15222ac973"
version = "0.2.0"
version = "0.3.0"

[deps]
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Expand Down
8 changes: 7 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ Built around these alias types, StaticThings provides:

* Length/size/axes query functions: [`maybestatic_length`](@ref), [`maybestatic_size`](@ref), [`maybestatic_axes`](@ref), [`maybestatic_eachindex`](@ref), [`maybestatic_first`](@ref), [`maybestatic_last`](@ref) and [`size_from_type`](@ref).

* Size/axes conversion functions: [`axes2size`](@ref), [`size2axes`](@ref), [`size2length`](@ref), [`asaxes`](@ref), [`canonical_indices`](@ref), [`canonical_size`](@ref) and [`canonical_axes`](@ref).
* Size/axes conversion functions: [`axes2size`](@ref), [`size2axes`](@ref), [`size2length`](@ref), [`size_dims`](@ref), [`asaxes`](@ref), [`canonical_indices`](@ref), [`canonical_size`](@ref) and [`canonical_axes`](@ref).

* Functions over a static number of leading array dimensions: [`sum_leading_dims`](@ref), [`drop_leading_dims`](@ref), [`merge_leading_dims`](@ref) and [`all_leading_dims`](@ref).

* Static-preserving views and splits: [`maybestatic_view`](@ref) and [`split_at`](@ref).

* Constant-folding reductions over the element types of tuple types: [`static_mapreduce`](@ref), [`static_reduce`](@ref), [`static_all`](@ref) and [`static_any`](@ref).

When creating arrays, StaticThings prefers allocation-free
types like `StaticArrays.SArray` and `FillArrays.Fill` where feasible.
4 changes: 3 additions & 1 deletion src/StaticThings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ static and non-static values and arrays.
"""
module StaticThings

using Base: Broadcast

using FillArrays: FillArrays, Fill

using Static: Static, StaticInteger, static, dynamic

using StaticArrayInterface: StaticArrayInterface

using StaticArrays: StaticArrays, StaticArray, SArray, SVector
using StaticArrays: StaticArrays, StaticArray, StaticVector, SArray, SVector

include("aliases.jl")
include("tools.jl")
Expand Down
Loading
Loading