Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
1d array as 4d with easy reshaping
with Ada.Text_IO; use Ada.Text_IO; procedure Hello is type tensor is array(1..36) of aliased integer; t : tensor := (1,2,3, 4,5,6, 7,8,9, 10,11,12, 13,14,15, 16,17,18, 19,20,21, 22,23,24, 25,26,27, 28,29,30, 31,32,33, 34,35,36); ln : positive := 3; lc : positive := 2; lh : positive := 2; lw : positive := 3; type reference_type(element : not null access integer) is limited null record with Implicit_Dereference => element; function get(n,c,h,w : positive) return reference_type is begin return reference_type'(element=> t((n-1)*lc*lh*lw + (c-1)*lh*lw + (h-1)*lw + w)'access); end get; begin get(2,2,2,2):=99; for n in 1..ln loop for c in 1..lc loop for h in 1..lh loop for w in 1..lw loop Put_Line(integer'image(get(n,c,h,w))); end loop; end loop; end loop; end loop; end Hello;
run
|
edit
|
history
|
help
1
Please
log in
to post a comment.
Memory Alignment
Dynamic Dispatching with dynamic allocation
Ada Dimentional System
Bc130400116
Dynamic Dispatching with no dynamic allocation
Stack (Using Tasking)
nested ADA code, same procedure name
Dynamic Dispatching
Overloaded Ada
plop
Please log in to post a comment.