From f464977726ca133bbc825c57b04e625671ee1eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Fri, 21 Jun 2024 16:07:19 +0200 Subject: [PATCH] Add some methods for CxxMatrix --- src/array_types.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/array_types.jl b/src/array_types.jl index d17dbd5..a14e4f8 100644 --- a/src/array_types.jl +++ b/src/array_types.jl @@ -57,7 +57,7 @@ mutable struct CxxMatrix{T} <: AbstractMatrix{T} x = new{T}(alloc_mat(T, n, m), n, m) return finalizer(cxx_mat_finalizer, x) end - function CxxMatrix{T}(Y::Matrix{T}) where {T<:Real} + function CxxMatrix{T}(Y::AbstractMatrix{T}) where {T<:Real} check_type_mat(T) n, m = size(Y) X = new{T}(alloc_mat(T, n, m), n, m) @@ -70,6 +70,10 @@ mutable struct CxxMatrix{T} <: AbstractMatrix{T} end end +Base.size(A::CxxMatrix)=(A.n, A.m) +Base.setindex!(A::CxxMatrix{T}, v, i,j) where T= setindex!(A.data,T(v),i,j) +Base.getindex(A::CxxMatrix,i,j) = getindex(A.data,i,j) + function check_type_mat(::Type{T}) where {T<:Real} if !(T <: Union{Cdouble}) throw("Not implemented for type $T")