Skip to content

Commit 89b202c

Browse files
authored
Merge pull request #180 from JuliaDiff/ar/rand_tangent_zeroarrays
Rand tangent zero-dimensional arrays
2 parents 96b1abd + b8d5573 commit 89b202c

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/rand_tangent.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ end
2929
# multiply by 9 to give a bigger range of values tested: no so tightly clustered around 0.
3030
rand_tangent(rng::AbstractRNG, ::BigFloat) = round(big(9 * randn(rng)), sigdigits=5, base=2)
3131

32+
rand_tangent(rng::AbstractRNG, x::StridedArray{T, 0}) where {T} = fill(rand_tangent(x[1]))
3233
rand_tangent(rng::AbstractRNG, x::StridedArray) = rand_tangent.(Ref(rng), x)
3334
rand_tangent(rng::AbstractRNG, x::Adjoint) = adjoint(rand_tangent(rng, parent(x)))
3435
rand_tangent(rng::AbstractRNG, x::Transpose) = transpose(rand_tangent(rng, parent(x)))

test/rand_tangent.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ using FiniteDifferences: rand_tangent
2727
(big(5.0), BigFloat),
2828

2929
# StridedArrays.
30+
(fill(randn(Float32)), Array{Float32, 0}),
31+
(fill(randn(Float64)), Array{Float64, 0}),
3032
(randn(Float32, 3), Vector{Float32}),
3133
(randn(Complex{Float64}, 2), Vector{Complex{Float64}}),
3234
(randn(5, 4), Matrix{Float64}),

0 commit comments

Comments
 (0)