N dimensional array with different type

Hello, Is it possible to create a multidimensional array that would have several types of data of the following type?


Here id and i is index. P1, P2, time ev type of Float64. check ev type of bool and another is arrays where elements is Float64.
thank you for your help

Yes, you can have an Array{Any, N}:

julia> rand([1.0, true, "x"], 3, 3, 3)
3Γ—3Γ—3 Array{Any, 3}:
[:, :, 1] =
 true     true  true
     "x"  true     1.0
    1.0   true     1.0

[:, :, 2] =
  "x"     1.0       "x"
 1.0   true     true
  "x"      "x"      "x"

[:, :, 3] =
 1.0      1.0  true
 1.0      1.0     1.0
  "x"  true       1.0

whether that’s a good idea is a different question - certainly not if you are using this in any performance critical code.

Maybe it’s an artefact of your drawing but your image looks like a table rather than a multidimensional array (maybe what people sometimes call a β€œlong format” table), maybe a DataFrame works for you:

julia> using DataFrames

julia> DataFrame(id = [1,1,1,2,2,2], i = [1:3; 1:3], P1 = rand(6), check_ev = rand(Bool, 6))
6Γ—4 DataFrame
 Row β”‚ id     i      P1         check_ev
     β”‚ Int64  Int64  Float64    Bool
─────┼───────────────────────────────────
   1 β”‚     1      1  0.761151       true
   2 β”‚     1      2  0.946944      false
   3 β”‚     1      3  0.633906      false
   4 β”‚     2      1  0.696095      false
   5 β”‚     2      2  0.87252       false
   6 β”‚     2      3  0.0642857      true
3 Likes

Thank you for the suggestion. One row of the array contains elements, for example dots u0, which are array where elements contains vector of 3 elements.
dots u0 and dots on ev is static vector, Ξ±s just vector

I use StructArray in BifurcationKit.jl for that

Thank you, I will try to use this package

I haven’t come up with anything better than this yet.
Foreach value from the interval, there are 50 elements from these data structures. 1-st value from the interval corresponds to elements with indexes from 1 to 50, the second from 50 to 100 and so on.

number_points_on_side = 25
total_count_points = number_points_on_side * 2

length_p = 20
start_p = -1.700
end_p = -1.71

size_vector = length_p * total_count_points

prange =  range(start_p, end_p, length = length_p)

dots_u0 = fill(Vector{Float64}(undef, 3), total_count_points)
check_events = Vector{Bool}(undef, total_count_points)
time_events = Vector{Float64}(undef, total_count_points)
dots_on_event = fill(Vector{Float64}(undef, 3), total_count_points)
Ξ±s = fill(Vector{Float64}(undef, 3), total_count_points)
norms = Vector{Float64}(undef, total_count_points)