Skip to content

Commit

Permalink
Merge pull request #14 from TimSiebert1/cxxmatrix
Browse files Browse the repository at this point in the history
Add some methods for CxxMatrix
  • Loading branch information
TimSiebert1 authored Jun 21, 2024
2 parents 18d47e2 + 0268153 commit c33e696
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/array_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit c33e696

Please sign in to comment.