Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++

Idiom #26 Create a 2-dimensional array

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

#include <vector>
std::vector<std::vector<double>> x (m, std::vector<double>(n));
#include <array>
::std::array<::std::array<int, n>, m> x;

n and m is constexpr.
X : array (1 .. M, 1 .. N) of Float := (others => (others => 1.0));

New implementation...