It makes sense. Thanks, once again!
For reference, I ended up with code like this:
# internal only
type XMatrixStruct
rows::Cint
cols::Cint
data::Ptr{Float64}
end
type XMatrix
ptr::Ptr{XMatrixStruct}
data::Ptr{Float64} # copied from `unsafe_load(ptr).data`
end
This way I
On Sun, Apr 17, 2016 at 6:23 AM, Andrei Zh wrote:
> A followup question. In the above example I'd like to add method `getindex`
> for `XMatrix`. Previously, I could do it like this:
>
> type XMatrix
> rows::Cint
> cols::Cint
> data::Ptr{Float64}
> end
>
>
A followup question. In the above example I'd like to add method `getindex`
for `XMatrix`. Previously, I could do it like this:
type XMatrix
rows::Cint
cols::Cint
data::Ptr{Float64}
end
getindex(mat::XMatrix, i::Integer) = unsafe_load(mat.data, i)
Now after Yichao's suggestion my type
This is exactly the answer I hoped to see! Thanks a lot!
On Sunday, April 17, 2016 at 2:46:15 AM UTC+3, Yichao Yu wrote:
>
> On Sat, Apr 16, 2016 at 6:55 PM, Andrei Zh > wrote:
> > I have a question regarding Struct Type correspondences section of the
> > documentation.
On Sat, Apr 16, 2016 at 6:55 PM, Andrei Zh wrote:
> I have a question regarding Struct Type correspondences section of the
> documentation. Let's say, in a C library we have a struct like this:
>
> typedef struct {
> int rows;
> int cols;
> double* data;
> }