From 55a386d7a0053f5987fb627185deb9171d2684c8 Mon Sep 17 00:00:00 2001 From: Andy Zhang <37402126+AnzhiZhang@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:07:34 +0100 Subject: [PATCH] feat(matrices): add randjorth --- docs/src/reference.md | 1 + src/matrices/index.jl | 3 +++ src/matrices/randjorth.jl | 29 +++++++++++++++++++++++++++++ test/matrices/randjorth.jl | 11 +++++++++++ 4 files changed, 44 insertions(+) create mode 100644 src/matrices/randjorth.jl create mode 100644 test/matrices/randjorth.jl diff --git a/docs/src/reference.md b/docs/src/reference.md index 69a8f4b..f3028dd 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -73,6 +73,7 @@ TypedMatrices.Poisson TypedMatrices.Prolate TypedMatrices.Randcolu TypedMatrices.Randcorr +TypedMatrices.Randjorth TypedMatrices.Rando TypedMatrices.RandSVD TypedMatrices.Redheff diff --git a/src/matrices/index.jl b/src/matrices/index.jl index 9a50377..a0e14fb 100644 --- a/src/matrices/index.jl +++ b/src/matrices/index.jl @@ -48,6 +48,7 @@ export Prolate, Randcolu, Randcorr, + Randjorth, Rando, RandSVD, Redheff, @@ -113,6 +114,7 @@ include("poisson.jl") include("prolate.jl") include("randcolu.jl") include("randcorr.jl") +include("randjorth.jl") include("rando.jl") include("randsvd.jl") include("redheff.jl") @@ -178,6 +180,7 @@ MATRIX_GROUPS[GROUP_BUILTIN] = Set([ Prolate, Randcolu, Randcorr, + Randjorth, Rando, RandSVD, Redheff, diff --git a/src/matrices/randjorth.jl b/src/matrices/randjorth.jl new file mode 100644 index 0000000..5bcc258 --- /dev/null +++ b/src/matrices/randjorth.jl @@ -0,0 +1,29 @@ +# TODO: Randjorth Matrix +""" +Randjorth Matrix +================ +This matrix is currently not implemented. +""" +struct Randjorth{T<:Number} <: AbstractMatrix{T} + n::Integer + + function Randjorth{T}(n::Integer) where {T<:Number} + n >= 0 || throw(ArgumentError("$n < 0")) + return new{T}(n) + end +end + +# constructors +Randjorth(n::Integer) = Randjorth{Float64}(n) + +# metadata +@properties Randjorth [:random] + +# properties +size(A::Randjorth) = (A.n, A.n) + +# functions +@inline Base.@propagate_inbounds function getindex(A::Randjorth{T}, i::Integer, j::Integer) where {T} + @boundscheck checkbounds(A, i, j) + return zero(T) +end diff --git a/test/matrices/randjorth.jl b/test/matrices/randjorth.jl new file mode 100644 index 0000000..c3168bc --- /dev/null +++ b/test/matrices/randjorth.jl @@ -0,0 +1,11 @@ +# constructors & content (random matrix) +@test allequal([ + size(Randjorth(5)), + size(Randjorth{Float64}(5)), +]) + +# linear algebra functions +run_test_linearalgrbra_functions(Randjorth.(1:5)) + +# eltype +@test test_matrix_elements(Randjorth{Float32}(5))