From 967678970ea8eaf93ab43c1c3a839b26020935f1 Mon Sep 17 00:00:00 2001 From: Omar Elrefaei Date: Thu, 23 Feb 2023 21:33:02 -0500 Subject: [PATCH] Implement StridedArray interface for compatibility with BLAS/LAPACK operations --- src/QuasiTriangular.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/QuasiTriangular.jl b/src/QuasiTriangular.jl index 23999a6..c056032 100644 --- a/src/QuasiTriangular.jl +++ b/src/QuasiTriangular.jl @@ -8,6 +8,10 @@ import Base.getindex import Base.require_one_based_indexing import Base.setindex! import Base.copy +import Base.Matrix +import Base.strides +import Base.elsize +import Base.unsafe_convert import LinearAlgebra.checksquare import LinearAlgebra.BlasInt import LinearAlgebra.BLAS.@blasfunc @@ -72,6 +76,11 @@ function setindex!(A::QuasiUpperTriangular, x, i::Integer, j::Integer) return A end +## Implement StridedArray interface to be compatible with generic BLAS calls +Base.strides(a::QuasiUpperTriangular{T, <: AbstractMatrix{T}}) where {T} = strides(a.data) +Base.elsize(::Type{<:QuasiUpperTriangular{T, <: AbstractMatrix{T}}}) where T = Base.elsize(Matrix{T}) +Base.unsafe_convert(::Type{Ptr{T}}, a::QuasiUpperTriangular{T, <: AbstractMatrix{T}}) where {T} = pointer(a.data) + ## Generic quasi triangular right vector, multiplication function A_mul_B!(a::QuasiUpperTriangular,b::AbstractVector,work::AbstractVector) if size(a,1) < 27