9191AUTHORS:
9292
9393- Marketa Slukova (2019-08-16): initial version
94+ - Camille Garnier and Rubén Muñoz-\-Bertrand (2024-02-13): added rank_support_of_vector, and corrected the documentation
9495
9596TESTS::
9697
@@ -146,9 +147,9 @@ def to_matrix_representation(v, sub_field=None, basis=None):
146147 specified, it is the prime subfield `\GF{p}` of `\GF{q^m}`
147148
148149 - ``basis`` -- (default: ``None``) a basis of `\GF{q^m}` as a vector space over
149- ``sub_field``. If not specified, given that `q = p^s`, let
150- `1,\beta,\ldots,\beta^{sm }` be the power basis that SageMath uses to
151- represent `\GF{q^m}`. The default basis is then `1,\beta,\ldots,\beta^{m-1}` .
150+ ``sub_field``. If not specified, the default basis is
151+ `1,\beta,\ldots,\beta^{m-1 }` where `\beta` is the generator of `\GF{q^m}`
152+ given by SageMath .
152153
153154 EXAMPLES::
154155
@@ -198,9 +199,9 @@ def from_matrix_representation(w, base_field=None, basis=None):
198199 ``w``.
199200
200201 - ``basis`` -- (default: ``None``) a basis of `\GF{q^m}` as a vector space over
201- `\GF{q}`. If not specified, given that `q = p^s`, let
202- `1,\beta,\ldots,\beta^{sm }` be the power basis that SageMath uses to
203- represent `\GF{q^m}`. The default basis is then `1,\beta,\ldots,\beta^{m-1}` .
202+ `\GF{q}`. If not specified, the default basis is
203+ `1,\beta,\ldots,\beta^{m-1 }` where `\beta` is the generator
204+ of `\GF{q^m}` given by SageMath .
204205
205206 EXAMPLES::
206207
@@ -230,7 +231,7 @@ def rank_weight(c, sub_field=None, basis=None):
230231 Return the rank of ``c`` as a matrix over ``sub_field``.
231232
232233 If ``c`` is a vector over some field `\GF{q^m}`, the function converts it
233- into a matrix over `\GF{q} `.
234+ into a matrix over ``sub_field`` `.
234235
235236 INPUT:
236237
@@ -240,9 +241,9 @@ def rank_weight(c, sub_field=None, basis=None):
240241 specified, it is the prime subfield `\GF{p}` of `\GF{q^m}`
241242
242243 - ``basis`` -- (default: ``None``) a basis of `\GF{q^m}` as a vector space over
243- ``sub_field``. If not specified, given that `q = p^s`, let
244- `1,\beta,\ldots,\beta^{sm }` be the power basis that SageMath uses to
245- represent `\GF{q^m}`. The default basis is then `1,\beta,\ldots,\beta^{m-1}` .
244+ ``sub_field``. If not specified, the default basis is
245+ `1,\beta,\ldots,\beta^{m-1 }` where `\beta` is the generator
246+ of `\GF{q^m}` given by SageMath .
246247
247248 EXAMPLES::
248249
@@ -278,9 +279,9 @@ def rank_distance(a, b, sub_field=None, basis=None):
278279 specified, it is the prime subfield `\GF{p}` of `\GF{q^m}`
279280
280281 - ``basis`` -- (default: ``None``) a basis of `\GF{q^m}` as a vector space over
281- ``sub_field``. If not specified, given that `q = p^s`, let
282- `1,\beta,\ldots,\beta^{sm }` be the power basis that SageMath uses to
283- represent `\GF{q^m}`. The default basis is then `1,\beta,\ldots,\beta^{m-1}` .
282+ ``sub_field``. If not specified, the default basis is
283+ `1,\beta,\ldots,\beta^{m-1 }` where `\beta` is the generator
284+ of `\GF{q^m}` given by SageMath .
284285
285286 EXAMPLES::
286287
@@ -379,9 +380,9 @@ def __init__(self, base_field, sub_field, length, default_encoder_name,
379380 - ``default_decoder_name`` -- the name of the default decoder of ``self``
380381
381382 - ``basis`` -- (default: ``None``) a basis of `\GF{q^m}` as a vector space over
382- ``sub_field``. If not specified, given that `q = p^s`, let
383- `1,\beta,\ldots,\beta^{sm }` be the power basis that SageMath uses to
384- represent `\GF{q^m}`. The default basis is then `1,\beta,\ldots,\beta^{m-1}` .
383+ ``sub_field``. If not specified, the default basis is
384+ `1,\beta,\ldots,\beta^{m-1 }` where `\beta` is the generator
385+ of `\GF{q^m}` given by SageMath .
385386
386387 EXAMPLES:
387388
@@ -588,6 +589,67 @@ def rank_weight_of_vector(self, word):
588589 """
589590 return rank_weight (word , self .sub_field ())
590591
592+ def rank_support_of_vector (self , word , sub_field = None , basis = None ):
593+ r"""
594+ Return the rank support of ``word`` over ``sub_field``, i.e. the vector space over
595+ ``sub_field`` generated by its coefficients.
596+
597+ If ``word`` is a vector over some field `\GF{q^m}`, and ``sub_field`` is a subfield of
598+ `\GF{q^m}`, the function converts it into a matrix over ``sub_field``, with
599+ respect to the basis ``basis``.
600+
601+ INPUT:
602+
603+ - ``word`` -- a vector over the ``base_field`` of ``self``.
604+
605+ - ``sub_field`` -- (default: ``None``) a sub field of the
606+ ``base_field`` of ``self``; if not specified, it is the prime
607+ subfield of `\GF{p}` the ``base_field`` of ``self``.
608+
609+ - ``basis`` -- (default: ``None``) a basis of ``base_field`` of
610+ ``self`` as a vector space over ``sub_field``. If not specified,
611+ the default basis is `1,\beta,\ldots,\beta^{m-1}`, where `\beta` is
612+ the generator of `\GF{q^m}` given by SageMath.
613+
614+ EXAMPLES::
615+
616+ sage: G = Matrix(GF(64), [[1,1,0], [0,0,1]])
617+ sage: C = codes.LinearRankMetricCode(G, GF(4))
618+ sage: a = GF(64).gen()
619+ sage: c = vector([a^4 + a^3 + 1, a^4 + a^3 + 1, a^4 + a^3 + a^2 + 1])
620+ sage: c in C
621+ True
622+ sage: C.rank_support_of_vector(c)
623+ Vector space of degree 6 and dimension 2 over Finite Field of size 2
624+ Basis matrix:
625+ [1 0 0 1 1 0]
626+ [0 0 1 0 0 0]
627+
628+ An example with a non canonical basis::
629+
630+ sage: K.<a> = GF(2^3)
631+ sage: G = Matrix(K, [[1,1,0], [0,0,1]])
632+ sage: C = codes.LinearRankMetricCode(G)
633+ sage: c = vector([a^2, a^2, 0])
634+ sage: basis = [a, a+1, a^2]
635+ sage: C.rank_support_of_vector(c, basis=basis)
636+ Vector space of degree 3 and dimension 1 over Finite Field of size 2
637+ Basis matrix:
638+ [0 0 1]
639+
640+ TESTS::
641+
642+ sage: C.rank_support_of_vector(c, GF(2^4))
643+ Traceback (most recent call last):
644+ ...
645+ TypeError: the input subfield Finite Field in z4 of size 2^4 is not a subfield of Finite Field in a of size 2^3
646+ """
647+ word = self .ambient_space ()(word )
648+ if sub_field is not None :
649+ if self .base_field ().degree () % sub_field .degree () != 0 :
650+ raise TypeError (f"the input subfield { sub_field } is not a subfield of { self .base_field ()} " )
651+ return to_matrix_representation (word , sub_field , basis ).column_module ()
652+
591653 def matrix_form_of_vector (self , word ):
592654 r"""
593655 Return the matrix representation of a word.
@@ -679,9 +741,9 @@ def __init__(self, generator, sub_field=None, basis=None):
679741 specified, it is the prime field of ``base_field``
680742
681743 - ``basis`` -- (default: ``None``) a basis of `\GF{q^m}` as a vector space over
682- ``sub_field``. If not specified, given that `q = p^s`, let
683- `1,\beta,\ldots,\beta^{sm }` be the power basis that SageMath uses to
684- represent `\GF{q^m}`. The default basis is then `1,\beta,\ldots,\beta^{m-1}` .
744+ ``sub_field``. If not specified, the default basis is
745+ `1,\beta,\ldots,\beta^{m-1 }` where `\beta` is the generator `\GF{q^m}`
746+ given by SageMath .
685747
686748 EXAMPLES::
687749
0 commit comments