Template Function otyca::array2
Function Documentation
-
template<typename T>
std::vector<std::array<T, 2>> otyca::array2(const std::vector<T> &x1s, const std::vector<std::vector<T>> &x2s) Combines two vectors into a vector of pairs of values.
This function takes two vectors,
x1sandx2s, wherex1sis a vector of elements, andx2sis a vector of vectors. It creates a vector of pairs, where each pair consists of an element fromx1sand an element from each subvector ofx2s, and returns the resulting vector of pairs.Note
The size of
x2smust match the size ofx1s, and the function iterates over each subvector inx2s, pairing each element with the corresponding element inx1s.- Template Parameters:
T – The type of elements in the vectors.
- Parameters:
x1s – The first vector containing elements that will form the first part of each pair.
x2s – The second vector containing subvectors, each of which contributes elements to the second part of each pair.
- Returns:
A vector of pairs, where each pair consists of an element from
x1sand an element from each subvector inx2s.