-1
I have a matrix float m2D[4][4]
. For the purposes of my program, I need at the same time to change the values in the components of m2D
be able to save the status prior to that change. It’s basically the idea of stacking, but I don’t know how to create a structure that can contain n versions of my multidimensional matrix m2D
.
One idea was to use another multidimensional matrix such as m3D[4][4][n]
, so I could do something like:
m3D[0][0][0] = m2D[0][0];
m3D[0][1][0] = m2D[1][0];
...
However, the third dimension of the matrix should vary according to the need to save the current state of m2D
- something this method does not provide.
Another possibility was to try using the template vector
to try to create an array of n versions of m2D
, but I don’t know how to create a vector template with the type of float[4][4].
You can store the entire array in the pre-change version or store only the (s) element(s) that has been (ram) changed(s). Maybe you want some other information extra matrix, such as the date of the change. If the amount of versions you store is not predetermined you can create a dynamic structure, such as a chained list of matrices, where each element in the list is a structure composed of an array and a pointer to the next or previous or both. The most suitable solution depends on the use you will make.
– anonimo