vendredi 22 octobre 2021

Pointer to portions of array

I have an object of std::vector<std::array<double, 16>>

vector entry    Data
[0]           - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[1]           - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[2]           - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[...]         - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

This is intended to represent a 4x4 matrix in ravel format.

To not duplicate information I would like to create a pointer to extract a 3x3 from the above structure: I have mathematical operations for the 3x3 structure (std::array<double, 9>)

someStructure: pointing to data elements [0, 1, 2, 4, 5, 6, 8, 9 10]

The end goal is do: std::array<double, 9> tst = someStructure[0] + someStructure[1];

Is this doable?

Best Regards

Aucun commentaire:

Enregistrer un commentaire