Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Obj-c

Idiom #26 Create a 2-dimensional array

Declare and initialize a matrix x having m rows and n columns, containing real numbers.

NSArray *x=@[
  @[@0.1, @0.2, ... ], // n column values
  ... // m rows
];

Object arrays are one-dimensional, but can contain nested arrays (accessible later, if needed, through x[i][j] all right). With plain-C types it would be precisely same as in plain C.
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...