Skip to content

Commit 1f7b7f9

Browse files
Merge pull request #355 from oscardssmith/undefmatrix-for-numbers
add undefmatrix for numbers
2 parents 1bd114a + 10723ba commit 1f7b7f9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,9 @@ returns the matrix linear operator type which acts on the `vec` of the array.
526526
function undefmatrix(u)
527527
similar(u, length(u), length(u))
528528
end
529-
529+
function undefmatrix(u::Number)
530+
return zero(u)
531+
end
530532
"""
531533
restructure(x,y)
532534

lib/ArrayInterfaceCore/test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Aqua.test_all(ArrayInterfaceCore)
2525
@test size(um) == (length(v),length(v))
2626
@test typeof(um) == Matrix{T}
2727
@test zeromatrix(v) == zeros(T,4*4*4,4*4*4)
28+
@test zeromatrix(rand(T)) == zero(T)
29+
@test undefmatrix(rand(T)) isa T
2830
end
2931
end
3032

0 commit comments

Comments
 (0)