Has anybody made an Array type that is row-major for julia, precisely for memory compatibility with C code? (as well as optimized code to go from row-major <-> column-major layout?) It would seem that that would be very useful, with all of the C libraries available...
On Sunday, June 21, 2015 at 5:16:20 PM UTC-4, Isaiah wrote: > > I think I'll go for this idea. For the real project I cannot change the C >> library because it is not mine. So maybe I can overwrite the C variable the >> way you suggest. > > > To expand slightly, what I meant was that if you have an API like: > > compute_large_foo(double* array, int nrows, int ncols) > > You can pass a pointer to a Julia array via ccall and avoid copying > individual elements. Although note (correction!) that the default Array > memory layout in Julia is column-major (like Fortran), not row-major (like > C). > > On Sun, Jun 21, 2015 at 4:59 PM, Daniel Carrera <[email protected] > <javascript:>> wrote: > >> >> >> On 21 June 2015 at 22:13, Isaiah Norton <[email protected] >> <javascript:>> wrote: >> >>> 0.4-dev is not really recommended unless you are somewhat adventurous or >>> you know you need a specific feature. >>> >> >> Is there any estimate on when 0.4 will be stable? >> >> >> >>> (for general use, note also that depending on what APIs you are calling, >>> you could just do the full array-population on the Julia side and pass a >>> pointer to the array because Julia's arrays have C-compatible memory layout) >>> >> >> >> I think I'll go for this idea. For the real project I cannot change the C >> library because it is not mine. So maybe I can overwrite the C variable the >> way you suggest. >> >> >> Cheers, >> Daniel. >> > >
