In practice, don't use multidimensional arrays in C or C++. Just use a single dimension array, perhaps by making a class
containing it with some getter and setter methods.
However, there are many occasions where you would use a container of containers, e.g. types like std::set<std::vector<long>>
or occasionally std::vector<std::array<double,3>>
etc...
The practical exception for using raw 2D arrays might be for matrixes whose dimensions are a compile-time constant. So a 3D linear transform (from R3 to itself) might be represented by a double m[3][3];
; then a good optimizing compiler might even be able to vectorize the code.
But for a matrix whose both dimensions are only known at runtime, making it a bidimensional array is generally a mistake or an overkill (and this is why the STL does not provide you with a std::matrix
template). You could use std::vector<std::vector<double>>
but that requires allocating each row of your matrix.
Of course, you'll find a lot of existing linear algebra libraries like LAPACK, BLAS, etc... Use them for 2D or 3D computations. Some of them might even use hardware acceleration (e.g. using OpenCL to run on a GPGPU).
More generally, very often you should use and combine existing C++ standard containers (or even define your own templates providing your containers, perhaps by combining existing ones).