Inner Products and Duals

The functions described in this section use the symplectic inner product defined for quantum codes.

SymplecticInnerProduct(v1, v2) : ModTupFldElt, ModTupFldElt -> FldFinElt
    ExtendedFormat: BoolElt             Default: false
Let v1 and v2 be two vectors belonging to the vector space K(n), where K is a finite field. This function returns the inner product of v1 and v2 with respect to the symplectic inner product used for quantum codes. The symplectic inner product in extended format is defined by (a|b) * (c|d) = ad - bc, and its definition transfers naturally to the compact format.

Let p be the characteristic of K. In extended format the intrinsic returns (Tr)K/GF(p)(ad - bc). In compact format K = GF(q2) and each coordinate is written as a + λ b with a, b ∈GF(q) (where λ is QuantumBasisElement(GF(q))); the product ad - bc is formed over GF(q) and the intrinsic returns (Tr)GF(q)/GF(p)(ad - bc), the trace from GF(q) rather than the absolute trace from GF(q2). In both cases the return value lies in the prime field GF(p) (for example GF(2) when K = GF(4)), not in K in general. For binary quantum codes whose compact format is over GF(4) this amounts to Trace(v1 ./line(v)2).

This product is an alternating GF(p)-bilinear form on K(n) regarded as a vector space over GF(p), but in general it is neither K-valued nor K-bilinear. To evaluate a K-valued alternating form attached to the K-space itself, attach the form to the space with SymplecticSpace (or VectorSpace(K,n,J)) and use InnerProduct; see Chapter POLAR SPACES.

Example QECC_symplectic-products-compared (H171E18)

The coding-theory product and an attached alternating form can give different values for vectors with the same coordinates.
> F<w> := GF(4);
> V := VectorSpace(F,2);
> v := V![1,0];
> x := V![1,w];
> coding := SymplecticInnerProduct(v,x);
> coding;
0
> Parent(coding);
Finite field of size 2
> J := Matrix(F,2,2,[0,1,-1,0]);
> W := SymplecticSpace(J);
> ordinary := InnerProduct(W![1,0],W![1,w]);
> ordinary;
w
> Parent(ordinary);
Finite field of size 2^2

Example QECC_symplectic-product-formats (H171E19)

Writing each coordinate of the compact vector [w, 0] over GF(4) as a + λ b with λ = w (so w = 0 + λ and 0 = 0) gives the extended vector [0, 0, 1, 0] over GF(2). Both formats yield the same symplectic inner product.
> F<w> := GF(4);
> V := VectorSpace(F, 2);
> compact := SymplecticInnerProduct(V![w,0], V![1,0]);
> compact;
1
> W := VectorSpace(GF(2), 4);
> extended := SymplecticInnerProduct(W![0,0,1,0], W![1,0,0,0] : ExtendedFormat);
> extended;
1
> compact eq extended;
true
SymplecticDual(C) : CodeAdd -> CodeAdd
    ExtendedFormat: BoolElt             Default: false
The dual of the additive (or possibly linear) code C with respect to the symplectic inner product. By default, C is interpreted as being in the compact format (a length n code over GF(q2)), but if ExtendedFormat is set to true, then it will be interpreted as being in extended format (a code of length 2n over GF(q)).
IsSymplecticSelfDual(C) : CodeAdd -> BoolElt
    ExtendedFormat: BoolElt             Default: false
Return true if the code C is equal to its symplectic dual and false otherwise. By default, C is interpreted as being in the compact format (a length n code over GF(q2)), but if ExtendedFormat is set to true, then it will be interpreted as being in extended format (a code of length 2n over GF(q)).
IsSymplecticSelfOrthogonal(C) : CodeAdd -> BoolElt
    ExtendedFormat: BoolElt             Default: false
Return true if the code C is contained in its symplectic dual. By default, C is interpreted as being in the compact format (a length n code over GF(q2)), but if ExtendedFormat is set to true, then it will be interpreted as being in extended format (a code of length 2n over GF(q)).

Example QECC_SymplecticEg (H171E20)

Vectors which are symplectically orthogonal to one another can be used to construct symplectic self-orthogonal codes.
> F<w> := GF(4);
> V5 := VectorSpace(F, 5);
> v := V5 ! [1,0,w,0,1];
> w := V5 ! [w,1,0,w,w];
> SymplecticInnerProduct(v,w);
0
> C := AdditiveCode<F, GF(2), 5 | v, w>;
> C;
[5, 1 : 2] GF(2)-Additive Code over GF(2^2)
Generator matrix:
[  1   0   w   0   1]
[  w   1   0   w   w]
> D := SymplecticDual(C);
> D;
[5, 4 : 8] GF(2)-Additive Code over GF(2^2)
Generator matrix:
[  1   0   0   0   1]
[  w   0   0   0   w]
[  0   1   0   0   0]
[  0   w   0   0   1]
[  0   0   1   0   w]
[  0   0   w   0   0]
[  0   0   0   1   1]
[  0   0   0   w   0]
> C subset D;
true
> Q := QuantumCode(C);
> Q;
[[5, 3]] Quantum code over GF(2^2), stabilised by:
[  1   0   w   0   1]
[  w   1   0   w   w]

Example QECC_symplecticselforthog (H171E21)

Any vector over GF(4) will be symplectically orthogonal to itself.
> V5 := VectorSpace(GF(4), 5);
> { SymplecticInnerProduct(v, v) : v in V5 };
{ 0 }
V2.29, 3 August 2026