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, x1s and x2s, where x1s is a vector of elements, and x2s is a vector of vectors. It creates a vector of pairs, where each pair consists of an element from x1s and an element from each subvector of x2s, and returns the resulting vector of pairs.

Note

The size of x2s must match the size of x1s, and the function iterates over each subvector in x2s, pairing each element with the corresponding element in x1s.

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 x1s and an element from each subvector in x2s.