cartesian_product

pyapprox.util.cartesian_product(input_sets, elem_size=1)[source]

Compute the cartesian product of an arbitray number of sets.

The sets can consist of numbers or themselves be lists or vectors. All the lists or vectors of a given set must have the same number of entries (elem_size). However each set can have a different number of scalars, lists, or vectors.

Parameters:
input_sets

The sets to be used in the cartesian product.

elem_sizeinteger

The size of the vectors within each set.

Returns:
resultnp.ndarray (num_sets*elem_size, num_elems)

The cartesian product. num_elems = np.prod(sizes)/elem_size, where sizes[ii] = len(input_sets[ii]), ii=0,..,num_sets-1. result.dtype will be set to the first entry of the first input_set