On Sun, Jul 17, 2016 at 8:05 PM, J Luis <[email protected]> wrote:
> Ghrrr, this works
>
> julia> [pointer_to_array(C[1], DS.n_rows) pointer_to_array(C[2], DS.n_rows)]
> 186x2 Array{Float64,2}:
>  7.0      53.3242
>  6.99583  53.325
>  6.99249  53.3264
> ...

You'll be better off to just create the Matrix and copy over the data
with `unsafe_copy!(pointer(dest, DS.n_rows * (i - 1) + 1),
unsafe_load(DS.data, i), DS.n_rows)`

>
> but I need a generic solution for a variable number of columns.
>
>
> segunda-feira, 18 de Julho de 2016 às 00:40:25 UTC+1, J Luis escreveu:
>>
>> Hi, need help reshaping an output from C that comes out in N (columns)
>> vectors into a 2-D matrix
>>
>> julia> C = pointer_to_array(DS.data, 2)
>> 2-element Array{Ptr{Float64},1}:
>>  Ptr{Float64} @0x000000001bf17360
>>  Ptr{Float64} @0x000000001bf17970
>>
>> and
>>
>> julia> pointer_to_array(C[1], DS.n_rows)
>> 186-element Array{Float64,1}:
>>  7.0
>>  6.99583
>>  6.99249
>> ...
>>
>> and I need to reshape these 2 columns into a 186x2 matrix but that's where
>> all my attempts fails. I tried for example
>>
>> julia> hcat([pointer_to_array(C[k], DS.n_rows) for k=1:2])
>> 2x1 Array{Array{T,N},2}:
>>
>> [7.0,6.99583,6.99249,6.98917,6.98639,6.98306,6.98029,6.97694,6.97417,6.97111
>> …
>> 6.44916,6.44472,6.44056,6.43612,6.43139,6.42611,6.42167,6.41694,6.41306,6.4089]
>>
>> [53.3242,53.325,53.3264,53.3281,53.33,53.3314,53.3331,53.3344,53.3364,53.338
>> …
>> 53.6008,53.6017,53.6028,53.6033,53.6042,53.6047,53.6053,53.6061,53.6072,53.6075]
>>
>> or
>>
>> julia> cat(2,[pointer_to_array(C[k], DS.n_rows) for k=1:2])
>> 2x1 Array{Array{T,N},2}:
>>
>> [7.0,6.99583,6.99249,6.98917,6.98639,6.98306,6.98029,6.97694,6.97417,6.97111
>> …
>> 6.44916,6.44472,6.44056,6.43612,6.43139,6.42611,6.42167,6.41694,6.41306,6.4089]
>>
>> [53.3242,53.325,53.3264,53.3281,53.33,53.3314,53.3331,53.3344,53.3364,53.338
>> …
>> 53.6008,53.6017,53.6028,53.6033,53.6042,53.6047,53.6053,53.6061,53.6072,53.6075]
>>
>> but that is not what I need,  as mentioned I need a Mx2 matrix.
>>
>> Thanks
>>
>> Joaquim

Reply via email to