alloc_array function

Allocate 3d-array and fill with matrix along first dimension