I want to read one cell of a 2D xtensor table based on a matching cell in a column in the table.
Conside a 2D table of elements of type std::string:
+-----+---+---+---+
| fee | I | J | K |
+-----+---+---+---+
| fie | L | M | N |
+-----+---+---+---+
| fo | O | P | Q |
+-----+---+---+---+
| fum | R | S | T |
+-----+---+---+---+
I want to read the value of the 3rd cell in the row where the first column == 'fo', ie 'P'
Searches on the internet suggest code that uses the function xt::keep() which seems not to be implemented. How do I carry this out using xt functions that are actually implemented?
You can check where in your array is there an element equal to "fo". The result, in this case would be the index {2, 0}. Than you can use the first element of that index (2) and the desired column index (2) and get a view of the array in the desired position.
Like this: