# Weight Enumerators

## `CompleteWeightEnumerator(C): Code -> RngMPolElt`

Let $C$ be a code over a finite ring $R$ of cardinality $q$, and suppose that the elements of $R$ are ordered in some way. Then for a codeword $v \in C$ and the $i$-th element $a \in R$, let $s_i(v)$ denote the number of components of $v$ equal to $a$.

This function returns the complete weight enumerator ${\cal W}_C(X_0, X_1, \ldots, X_{q-1})$ of $C$, which is defined by:

$$
{\cal W}_C(X_0, X_1, \ldots, X_{q-1}) =
   \sum_{v \in C}{{X_0}^{s_0(v)}{X_1}^{s_1(v)}\cdots{X_{q-1}}^{s_{q-1}(v)}}.
$$

See [[Wan, 1997](../../references.md#cite-wan-z4), p. 9] for more information. The result will lie in a global multivariate polynomial ring over ${\mathbb{Z}}$ with q variables. The angle-bracket notation may be used to assign names to the indeterminates.

## `SymmetricWeightEnumerator(C): Code -> RngMPolElt`

Suppose $C$ is a ${\mathbb{Z}}_4$-code. This function returns the symmetric weight enumerator $\hbox{swe}_C(X_0, X_1, X_2)$ of $C$, which is defined by:

$$
\hbox{swe}_C(X_0, X_1, X_2) = {\cal W}_C(X_0, X_1, X_2, X_1),
$$

where ${\cal W}_C$ is the complete weight enumerator, defined above. See [[Wan, 1997](../../references.md#cite-wan-z4), p. 14] for more information. The result will lie in a global multivariate polynomial ring over ${\mathbb{Z}}$ with three variables. The angle-bracket notation may be used to assign names to the indeterminates.

## `WeightEnumerator(C): Code -> RngMPolElt`

## `HammingWeightEnumerator(C): Code -> RngMPolElt`

Suppose $C$ is a code over some finite ring $R$. This function returns the Hamming weight enumerator $\hbox{Ham}_C(X, Y)$ of $C$, which is defined by:

$$
\hbox{Ham}_C(X, Y) = \sum_{v \in C}{X^{n-w_H(v)}Y^{w_H(v)}},
$$

where $w_H(v)$ is the Hamming weight function. The result will lie in a global multivariate polynomial ring over ${\mathbb{Z}}$ with two variables. The angle-bracket notation may be used to assign names to the indeterminates.

## `LeeWeightEnumerator(C): Code -> RngMPolElt`

Suppose $C$ is a ${\mathbb{Z}}_4$-code. This function returns the Lee weight enumerator $\hbox{Lee}_C(X, Y)$ of $C$, which is defined by:

$$
\hbox{Lee}_C(X, Y) = \sum_{v \in C}{X^{2*n-w_L(v)}Y^{w_L(v)}},
$$

where $w_L(v)$ is the Lee weight function, defined in Section [Lee Weight](weight-distribution.md#sec-lee-weight). The result will lie in a global multivariate polynomial ring over ${\mathbb{Z}}$ with two variables. The angle-bracket notation may be used to assign names to the indeterminates.

## `EuclideanWeightEnumerator(C): Code -> RngMPolElt`

Suppose $C$ is a ${\mathbb{Z}}_4$-code. This function returns the Euclidean weight enumerator $\hbox{Euclidean}_C(X, Y)$ of $C$, which is defined by:

$$
\hbox{Euclidean}_C(X, Y) = \sum_{v \in C}{X^{4*n-w_E(v)}Y^{w_E(v)}},
$$

where $w_E(v)$ is the Euclidean weight function, defined in Section [Euclidean Weight](weight-distribution.md#sec-euclidean-weight). The result will lie in a global multivariate polynomial ring over ${\mathbb{Z}}$ with two variables. The angle-bracket notation may be used to assign names to the indeterminates.

## `Example: Weight Enumerator (ex-92ee64)`

Several different weight enumerators are calculated for the octacode. To ensure the polynomials print out nicely, names are assigned to the polynomial ring indeterminates in each case. These names will persist if further calls to these functions (over ${\mathbb{Z}}_4$) are made.

```magma
> Z4 := IntegerRing(4);
> O8 := LinearCode<Z4, 8 |
>     [1,0,0,0,3,1,2,1],
>     [0,1,0,0,1,2,3,1],
>     [0,0,1,0,3,3,3,2],
>     [0,0,0,1,2,3,1,1]>;
> #O8;
256
> CWE<X0,X1,X2,X3> := CompleteWeightEnumerator(O8);
> CWE;
X0^8 + 14*X0^4*X2^4 + 56*X0^3*X1^3*X2*X3 + 56*X0^3*X1*X2*X3^3 +
    56*X0*X1^3*X2^3*X3 + 56*X0*X1*X2^3*X3^3 + X1^8 + 14*X1^4*X3^4 +
    X2^8 + X3^8
> SWE<X0,X1,X2> := SymmetricWeightEnumerator(O8);
> SWE;
X0^8 + 14*X0^4*X2^4 + 112*X0^3*X1^4*X2 + 112*X0*X1^4*X2^3 + 16*X1^8 +
    X2^8
> HWE<X,Y> := HammingWeightEnumerator(O8);
> HWE;
X^8 + 14*X^4*Y^4 + 112*X^3*Y^5 + 112*X*Y^7 + 17*Y^8
> LeeWeightEnumerator(O8);
X^16 + 112*X^10*Y^6 + 30*X^8*Y^8 + 112*X^6*Y^10 + Y^16
> EuclideanWeightEnumerator(O8);
X^32 + 128*X^24*Y^8 + 126*X^16*Y^16 + Y^32

```
