Skip to content

Commit

Permalink
Update array docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Jul 15, 2022
1 parent 858755f commit 8d7d418
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/mallocarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# Definition and constructors:
"""
```julia
MallocArray{T,N} <: AbstractArray{T,N}
MallocArray{T,N} <: DenseArray{T,N} <: AbstractArray{T,N}
```
`N`-dimensional dense heap-allocated array with elements of type `T`.
Much like `Base.Array`, except (1) backed by memory that is not tracked by
the Julia garbage collector (is directly allocated with `malloc`) so is
StaticCompiler-safe, (2) should be `free`d when no longer in use, and
(3) indexing returns views rather than copies.
(3) indexing returns `ArrayView`s rather than copies.
"""
struct MallocArray{T,N} <: DensePointerArray{T,N}
pointer::Ptr{T}
Expand Down Expand Up @@ -174,7 +174,7 @@
## Examples
```julia
julia> meye(Int32, 2,2)
julia> meye(Int32, 2)
2×2 MallocMatrix{Int32}:
1 0
0 1
Expand Down
25 changes: 13 additions & 12 deletions src/stackarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# Definition and constructors:
"""
```julia
StackArray{T,N} <: AbstractArray{T,N}
StackArray{T,N} <: DenseArray{T,N} <: AbstractArray{T,N}
```
`N`-dimensional dense stack-allocated array with elements of type `T`.
Much like `Base.Array`, except (1) backed by memory that is not tracked by
the Julia garbage collector (is stack allocated by `alloca`), so is
StaticCompiler-friendly, and (2) indexing returns views rather than copies.
StaticCompiler-friendly, and (2) contiguous slice indexing returns
`ArrayView`s rather than copies.
"""
mutable struct StackArray{T,N,L,D} <: DenseStaticArray{T,N}
data::NTuple{L,T}
Expand Down Expand Up @@ -68,11 +69,11 @@
## Examples
```julia
julia> A = StackArray{Float64}(undef, 3,3) # implicit N
3×3 StackMatrix{Float64}:
3.10504e231 6.95015e-310 2.12358e-314
1.73061e-77 6.95015e-310 5.56271e-309
6.95015e-310 0.0 -1.29074e-231
julia> StackArray{Float64}(undef, 3,3)
3×3 StackMatrix{Float64, 9, (3, 3)}:
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
```
"""
@inline StackArray(x::NTuple, dims::Vararg{Int}) = StackArray(x, dims)
Expand Down Expand Up @@ -125,7 +126,7 @@
## Examples
```julia
julia> szeros(Int32, 2,2)
2×2 StackMatrix{Int32}:
2×2 StackMatrix{Int32, 4, (2, 2)}:
0 0
0 0
```
Expand All @@ -148,7 +149,7 @@
## Examples
```julia
julia> sones(Int32, 2,2)
2×2 StackMatrix{Int32}:
2×2 StackMatrix{Int32, 4, (2, 2)}:
1 1
1 1
```
Expand All @@ -170,8 +171,8 @@
## Examples
```julia
julia> seye(Int32, 2,2)
2×2 StackMatrix{Int32}:
julia> seye(Int32, 2)
2×2 StackMatrix{Int32, 4, (2, 2)}:
1 0
0 1
```
Expand Down Expand Up @@ -200,7 +201,7 @@
## Examples
```julia
julia> sfill(3, 2, 2)
2×2 StackMatrix{Int64}:
2×2 StackMatrix{Int64, 4, (2, 2)}:
3 3
3 3
```
Expand Down

2 comments on commit 8d7d418

@brenhinkeller
Copy link
Owner Author

@brenhinkeller brenhinkeller commented on 8d7d418 Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • Refactor StaticRNGs, add Gaussian RNGs (BoxMuller,MarsagliaPolar) and randn methods for them
  • Add a stack-allocated StackArray type that mirrors the syntax and conventions of MallocArray. As with StaticString vs MallocString, the size of the stack-allocated option must be known at compile time to be StaticCompilerd (StackArray:MallocArray::StaticString:MallocString)
  • Contiguous slice-indexing of either a StackArray or a MallocArray now returns a lightweight ArrayView (similar to how slice-indexing either a StaticString or MallocString returns a StringView to avoid excessive copying
  • Add some convenience constructors for MallocArrays and StackArrays (mzeros/szeros, mones/sones, meye/seye, mfill/sfill)

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/64295

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.0 -m "<description of version>" 8d7d418403f17f5605b314b37652faa06e2ca8c2
git push origin v0.5.0

Please sign in to comment.