# vector

vector, a Python code which considers a problem involving vectors, which can be considered to belong to equivalence classes, for which an arbitrary collection of coefficients must be gathered, averaged, and then scattered again.

Consider vectors X of dimension D, whose entries are integers between 1 and B.

For instance, if D = 3 and B = 3, our set of vectors includes the 27 triples:

```      111, 112, 113, 121, 122, 123, 131, 132, 133,
211, 212, 213, 221, 222, 223, 231, 232, 233,
311, 312, 313, 321, 322, 323, 331, 332, 333
```

We will say two vectors are equivalent if one is simply a permutation of the other. Thus, for instance, in the above example, the six vectors 123, 132, 213, 231, 312 and 321 are equivalent.

Now we suppose that every vector X has an associated weight or coefficient C. We wish to modify the set of coefficients so that each vector in an equivalence class is assigned a coefficient computed as the average of the coefficients of all the members of that class.

To do this efficiently, we need to be able to generate each vector and its original coefficient, identify the corresponding equivalence class and ``gather'' the coefficient to an ongoing sum, then normalize that sum by the size of the equivalence class, and ``scatter'' the new coefficients back to the vectors.

The software supplied here is constructed in such a way as to enable the smooth carrying out of this process. In particular, the equivalence classes are identified by ``monotone vectors'', that is, the unique entry of each equivalence class whose elements are in ascending order.

### Languages:

vector is available in a MATLAB version and an Octave version and a Python version.

### Related Data and Programs:

combo, a Python code which contains many combinatorial routines.

monomial, a Python code which enumerates, lists, ranks, unranks and randomizes multivariate monomials in a space of m dimensions, with total degree less than n, equal to n, or lying within a given range.

subset, a Python code which generates, ranks and unranks various combinatorial objects.

### Source Code:

Last revised on 01 December 2022.