Skip to content

Commit 92b7d01

Browse files
committed
Add a cconvert for each unsafe_convert
1 parent 8f7f8e4 commit 92b7d01

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/BlockSkylineMatrix.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ _parent_blocks(V::BlockBandedBlock)::Tuple{Int,Int} =
456456
MemoryLayout(::Type{<:BlockBandedBlock}) = ColumnMajor()
457457
Base.elsize(::Type{<:BlockSkylineMatrix{T,R}}) where {T,R} = Base.elsize(R)
458458

459+
function Base.cconvert(::Type{Ptr{T}}, V::BlockBandedBlock{T}) where T
460+
V
461+
end
459462
function Base.unsafe_convert(::Type{Ptr{T}}, V::BlockBandedBlock{T}) where T
460463
A = parent(V)
461464
K,J = _parent_blocks(V)

src/linalg.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ sub_materialize(::BlockLayout{<:AbstractBandedLayout}, V, _) = BlockBandedMatrix
105105
strides(V::SubBlockSkylineMatrix{<:Any,LL,UU,<:Union{BlockRange1,Block1},Block1}) where {LL,UU} =
106106
(1,parent(V).block_sizes.block_strides[Int(parentindices(V)[2].block)])
107107

108-
108+
function Base.cconvert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,<:Union{BlockRange1,Block1},Block1}) where {T,LL,UU}
109+
V
110+
end
109111
function unsafe_convert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,<:Union{BlockRange1,Block1},Block1}) where {T,LL,UU}
110112
A = parent(V)
111113
JR = parentindices(V)[2]
@@ -117,6 +119,9 @@ end
117119
strides(V::SubBlockSkylineMatrix{<:Any,LL,UU,<:BlockRange1,<:BlockIndexRange1}) where {LL,UU} =
118120
(1,parent(V).block_sizes.block_strides[Int(Block(parentindices(V)[2]))])
119121

122+
function Base.cconvert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,<:BlockRange1,<:BlockIndexRange1}) where {T,LL,UU}
123+
V
124+
end
120125
function unsafe_convert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,<:BlockRange1,<:BlockIndexRange1}) where {T,LL,UU}
121126
A = parent(V)
122127
JR = parentindices(V)[2]
@@ -127,6 +132,9 @@ function unsafe_convert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,<:Block
127132
p + sizeof(T)*(JR.block.indices[1][1]-1)*stride(V,2)
128133
end
129134

135+
function Base.cconvert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,BlockIndexRange1,BlockIndexRange1}) where {T,LL,UU}
136+
V
137+
end
130138
function unsafe_convert(::Type{Ptr{T}}, V::SubBlockSkylineMatrix{T,LL,UU,BlockIndexRange1,BlockIndexRange1}) where {T,LL,UU}
131139
A = parent(V)
132140
JR = parentindices(V)[2]

0 commit comments

Comments
 (0)