You could in addition use ImmutableArrays: immutable Packet{T} ID::{T} position::Vector3{T} direction::Vector3{T} energy::{T} time::{T} end Which makes Packet a bitstype, with efficient memory layout. If you need to mutate these, there are actually ways, when the Packets are stored in an array. I'm implementing FixedSizeArrays at the moment, which would have this feature. Otherwise, you need to replace the whole struct in the array, which can be reasonable, considering the benefits. Other benefit? If you want to Visualize this in OpenGL, it should be fairly easy to upload, as it has a dense memory layout =) (With T= Float32, you wouldn't even need conversions)
Am Mittwoch, 14. Januar 2015 05:34:55 UTC+1 schrieb tugul...@gmail.com: > > I am writing a monte carlo radiation transport code (for applications in > astrophysics), where I follow the temporal and spacial evolution of > millions of whats called "monte-carlo packets". And I am wondering whether > if I should use the Julia's type system, if so how should I implement it > and also if there is any performance loss/gain. > > Let's say I define a type like following (based on this example tutorial > <http://forio.com/labs/julia-studio/tutorials/advanced/1/>): > > type Packet{T} >> ID::{T} >> position::Vector{T} >> direction::Vector{T} >> energy::{T} >> time::{T} >> end > > > obviously this could make the code much more easier to read than a version > with all information represented in separate arrays. But beside this > elegance, is there anything else I should know about types? when I apply > this to millions of objects will there be any effect to the performance? > > thanks, >