cpp_arrays_test, a C++ code which illustrates the use of vectors, matrices and tensors.
The information on this web page is distributed under the MIT license.
cpp_arrays_test is available in a C version and a C++ version.
cpp_test, C++ codes which illustrate some features of the C++ language;
cpp_intrinsics_test, a C++ code which illustrates the use of intrinsic functions.
cpp_random_test, C++ codes which illustrate the use of the random number generator routines.
ARRAYS is a very simple example of how to set up arrays in C++. In particular, we note that vectors are easy to declare with fixed or dynamic dimensions, but that arrays of dimension 2 or greater aren't easy to declare dynamically. The example shows how to work around this by settting up a two dimensional array as a one dimensional vector.
POINTERS shows how a two-dimensional array can be defined, either as row or column major, using pointers. Unfortunately, the column major format means that the double indexing lists the column index first!
TENSOR_EXAMPLE1 demonstrates how a 3D array can be created by repeated used of the vector operator.
TENSOR_EXAMPLE2 demonstrates how a 3D array can be created by using a class child of std::vector, which implements a 3D array as a linear vector. This is probably more efficient.