Densities of Codes of Various Linearity Degrees in Translation-Invariant Metric Spaces

We investigate the asymptotic density of error-correcting codes with good distance properties and prescribed linearity degree, including sublinear and nonlinear codes. We focus on the general setting of finite translation-invariant metric spaces, and then specialize our results to the Hamming metric, to the rank metric, and to the sum-rank metric. Our results show that the asymptotic density of codes heavily depends on the imposed linearity degree and the chosen metric.


Introduction
The asymptotic performance of error-correcting codes is a classical topic in coding theory, going back to the work of Shannon, where random codes are used to get arbitrarily close to the capacity of a given discrete memoryless channel [21].As in Shannon's proof, most of the literature has focused on the case where the field size is fixed and the code length goes to infinity.Recently, increasing attention has been paid to the case where the field size grows and the other code parameters stay fixed, especially in connection with open questions in the theory of rank-metric codes and their related open questions in semifield theory [17].For example, it was unknown if there are maximum rank distance codes that are not equivalent to a Gabidulin code, until it was shown that maximum rank distance codes are dense in the set of linear codes (for growing field extension degree of the ambient space), whereas Gabidulin codes are not [18].Furthermore, lower bounds (in particular the Gilbert-Varshamov bound) for the minimum distance of a randomly chosen code (attained by high probability) are needed in several applications in code-based cryptography, see e.g.[3,8,23].Such lower bounds can again be derived by density results about the respective code families.
In this paper, we investigate the proportion, or density, of error correcting codes with good distance properties, distinguishing between different degrees of linearity of the codes.We develop a general framework for determining (upper and lower bounds on) densities of codes in discrete translation-invariant metric spaces, with a focus on the asymptotic behavior of these densities.We then use this framework to determine the asymptotic densities of linear, (sub)linear and nonlinear codes over finite fields with respect to various metrics, namely the Hamming metric, the rank metric, and the sum-rank metric.In particular, we study extremal (or optimal) codes, in the sense that they attain the Singleton-type bound for the respective metric.
Considering codes in F n q m endowed with the Hamming metric it is known that if n < q m + 1 there exist linear maximum distance separable (MDS) codes, i.e., codes that achieve the classical Singleton bound, e.g., Reed-Solomon codes [20] and their generalizations.Furthermore, it is folklore knowledge that linear MDS codes are dense as the field size tends to infinity.This follows, for example, by the fact that all the maximal minors of a uniformly random matrix over F q are nonzero with probability approaching 1 as q goes to infinity.Only few results are known about the nonlinear case, e.g., in [5] it was observed that over a binary field the minimum distance of random nonlinear codes is asymptotically worse than in the linear setting.They even show that for growing n that the order is square (which corresponds to our square in the little-o notation.Nevertheless they neither considered this with respect to the Singleton bound nor asymptotically as the field size tends to infinity.In [15], the sparsity of nonlinear MDS codes over F q was established for q large.Furthermore, the question of the existence of (sub)linear MDS codes has recently received attention, due to their application in quantum coding.For example in [4] a geometric approach is used to classify all additive codes over F 9 .Then the MDS conjecture for this class of codes could be verified and hence the quantum MDS conjecture over F 3 .
In the rank metric it is also known that linear maximum rank-distance (MRD) codes in F n q m exist if n ≤ m, namely Gabidulin codes [11].Moreover, several density results of MRD codes are known, depending on whether they are nonlinear, F q -linear or even linear over the extension field F q m .In particular, it has been shown in [18] that F q m -linear MRD codes are dense as m → +∞.But if the codes belong to the wider class of F q -linear MRD codes they are not dense, neither for q → +∞, nor for m → +∞ (except for trivial parameter choices).In particular, F q -linear MRD codes are sparse as q → +∞ [16].
In the sum-rank metric the asymptotic densities for an arbitrary degree of linearity remained mostly unexplored.Recently, in [19], the Schwartz-Zippel Lemma was used to show that for m → +∞, most F q m -linear codes in F n q m are maximum sum-rank distance (MSRD) codes.This contrasting behavior with respect to different metrics and different types of linearity motivated us to study the density of codes in general metric spaces, with various degrees of linearity.
For this, we consider codes in F n q m , equipped with an arbitrary translation-invariant metric D. 1 For the linearity degree of the code we consider the maximal subfield F q ℓ ⊆ F q m over which the codes are linear.Clearly, ℓ is a divisor of m.
We then classify the asymptotic densities of (possibly) nonlinear codes and codes that are linear over the subfield F q ℓ ⊆ F q m separately.We also treat the asymptotic density with respect to the four parameters q, n, ℓ and s := [F q m : F q ℓ ] separately.
Our contribution.We determine upper and lower bounds on the proportion of codes in F n q m with a prescribed minimum distance (with respect to an arbitrary translation-invariant distance D) among all codes of a fixed cardinality.For this, we distinguish the case of nonlinear and F q ℓ -linear codes in F n q m , for any suitable ℓ.We then analyze the asymptotic behavior of these bounds and show that this highly depends on the volume of the balls with respect to D. In particular, we give conditions on the volume with respect to the prescribed cardinality and minimum distance, such that the family of codes is dense or sparse (both in the nonlinear or (sub)linear case).With these results we can straightforwardly see that nonlinear random codes achieve the Gilbert-Varshamov bound with probability going to zero, both for growing length or field size, while (sub)linear codes achieve it with probability going to 1, for growing field size or linearity degree (but not for growing length).
In the Hamming metric, we show that independent of the linearity degree, the class of F q ℓlinear MDS codes, as well as the class of nonlinear MDS codes, are both sparse as n → +∞.
When considering the asymptotic densities with respect to the field size, (sub)linear MDS codes are dense as q → +∞ (or ℓ → +∞).On the other hand, the probability that a nonlinear code is MDS tends to zero as q → +∞.Finally, we give an upper bound for the asymptotic density of MDS codes with respect to s which shows that MDS codes are not dense as s → +∞.
In the rank metric we show that nonlinear MRD codes are sparse with respect to both the field size and the code length.Moreover, we recover the previously known results on the sparsity and density of F q -or F q m -linear MRD codes.As new contributions we derive more general results for F q ℓ -linear MRD codes with respect to any of the parameters q, n, ℓ, s.In particular, we derive bounds on ℓ, for which MRD codes are sparse and for which they are dense, for q → +∞.For ℓ → +∞ we show that MRD codes are always dense.For growing n or s we derive again upper bounds on the density.
In the sum-rank metric we show that nonlinear MSRD codes are sparse with respect to the field size.For (sub)linear MSRD codes and letting q go to infinity, we derive bounds on ℓ such that the parameters for which MSRD codes are sparse and for which they are dense can be classified.
The outline of this article is as follows: In Section 2 we start by introducing the relevant terminology used throughout the article.We define the density functions associated with families of (sub)linear as well as (possibly) nonlinear codes.We also clarify the terms sparsity and density with respect to the parameters q, n, s and ℓ.Then we briefly provide the graph theory tools to obtain the upper and lower bounds on the density of a code family within a larger family.For more details on this and the specific bipartite graphs we refer to [16].In Section 3 we consider the asymptotic versions of these bounds with respect to the parameters n, s, ℓ and q.Under certain assumptions we can derive that the codes are sparse or dense with respect to a given parameter.In the second part of this article, covering Sections 4 to 6, we apply the developed classifiers from Section 3 to codes with respect to various distance functions.Particularly, we will focus on three major distance functions, namely the Hamming, rank, and sum-rank distance.

Finite Metric Spaces and Codes
Throughout this paper we let n and m be integers with 1 ≤ m, n.Moreover, we let q be a prime power, we denote the finite field of order q by F q and its extension field of degree m by F q m .From now on, unless otherwise stated, we work in F n q m and consider a translation-invariant distance D : Notation 1.1.We will repeatedly use the Bachmann-Landau notation ("Big O", "Little O","∼" and "Omega") to describe the asymptotic growth rate of functions defined on an infinite set of natural numbers; see for example [9].Since we are often interested in the asymptotics as the field size q tends to infinity, we denote the set of prime powers by Q and we omit "q ∈ Q" when writing q → +∞.
For a divisor ℓ of m, we denote an F q ℓ -linear code C ⊆ F n q m of cardinality S and minimum distance at least d by [F n q m , S, ℓ, d] D -code.If on the other hand C ⊆ F n q m is nonlinear, of cardinality S and minimum distance at least d, we say C is an [F n q m , S, 0, d] D -code.
We will make extensive use of the q-ary binomial coefficient, which is defined as and counts the number of b-dimensional subspaces of an a-dimensional vector space over F q .
Note that the number of F q ℓ -linear codes in . This formula will play a crucial role in determining bounds for the proportion of codes with certain distance properties among the set of codes of the same cardinality or dimension.
Definition 1.3.We let denote the density of (possibly) nonlinear codes of minimum distance D(C ) at least d within the set of (possibly) nonlinear codes of the same cardinality S. Analogously, we define as the density of F q ℓ -linear codes of minimum distance D(C ) at least d within the set of F q ℓ -linear codes of the same cardinality S.
Taking the limit in Equation (1.1) or Equation (1.2) as q, n, s or ℓ tends to infinity (and the other three parameters are fixed constants) defines the asymptotic density.
If the limit is 0 we say that F q ℓ -linear codes of minimum distance at least d and cardinality |S| are sparse as q, n, s or ℓ → +∞.If the limit is 1 we say that such codes are dense as q, n, s or ℓ → +∞.
Since we assume D to be invariant under translation, the ball with center c ∈ F n q m of radius 0 ≤ r < ∞ in F n q m , which is the set {x ∈ F n q m : D(x, c) ≤ r}, has the same size for any center c ∈ F n q m .Thus, when we consider the volume of the ball of radius r in F n q m , we do not specify the center of the ball.For ease of exhibition, we propose the following notation.

Graph Theory Tools
In this subsection we briefly recall some graph theory results from [16,Section 3].As we will show shortly, studying the number of isolated vertices in certain bipartite graphs will give us bounds on the number of codes we are interested in.
Definition 1.5.A (directed) bipartite graph is a 3-tuple B = (V , W , E ), where V and W are finite non-empty sets and E ⊆ V × W .The elements of V ∪ W are the vertices of the graph and the tuples given by relation E are called the edges of B. We say that a vertex To derive a lower bound for the number of non-isolated vertices in a left-regular bipartite graph, we introduce the concept of an association.This notion generalizes strong regularity properties on a bipartite graph with respect to certain functions defined on its left-vertices.Definition 1.6.Let V be a finite non-empty set and let 0 ≤ r be an integer.An association on V of magnitude r is a function α : V × V → {0, ..., r} satisfying the following: Definition 1.7.Let B = (V , W , E ) be a finite bipartite graph and let α be an association on V of magnitude r.We say that If this is the case, we denote this number by W ℓ (α), where ℓ = α(V, V ′ ) ∈ {0, . . ., r}.
We can now bound the number of non-isolated vertices in a left-regular bipartite graph.With these two bounds we will derive a lower and an upper bound for the density function of codes in F n×s q ℓ having certain distance properties.Lemma 1.9 (see [16,Lemma 3.2]).Let B = (V , W , E ) be a bipartite and left-regular graph of degree 0 < ∂.Let F ⊆ W be the collection of non-isolated vertices of W .We have The following lemma follows by combining the notion of an association and the Cauchy-Schwarz Inequality.Lemma 1.10 (see [16,Lemma 3.5]).Let B = (V , W , E ) be a finite bipartite α-regular graph, where α is an association on V of magnitude r.Let F ⊆ W be the collection of non-isolated vertices of

Upper and Lower Bounds on the Density of Codes
In this subsection we use the upper bound of Lemma 1.9 and the lower bound of Lemma 1.10 to give bounds on the number of codes in the metric space (F n q m , D) that have minimum distance bounded from below by some positive integer d.From these bounds we will later obtain a prediction for the asymptotic behavior of the density of these codes.

Bounds for Nonlinear Codes
We first consider nonlinear codes.Since we do not impose any linearity (nor (sub)linearity) on our codes in this subsection, we let m = 1, meaning that our ambient space is F n q and as before, D is a translation-invariant distance on F n q .
Theorem 2.1.Let 2 ≤ S and 1 ≤ d < +∞ be integers.Define the quantities and let Proof.We work with the bipartite graph B = (V , W , E ), where W is the collection of codes C ⊆ F n q with |C | = S, and ({x, y}, C ) ∈ E if and only if {x, y} ⊆ C .Note that the set of non-isolated vertices in W is exactly F .We have Moreover, one easily checks that Hence B is a left-regular graph of degree Applying Lemma 1.9 we obtain the upper bound on |F |.
As a corollary we get the following bounds on the proportion of codes in F n q of minimum distance at least d, again using the identity in (2.1).
Corollary 2.2.Let 2 ≤ S be an integer and consider 1 ≤ d < +∞.We have where Θ is the same as in Theorem 2.1.

Bounds for (Sub)Linear Codes
In this subsection, we fix a divisor ℓ of m and let s = [F q m : F q ℓ ].We will consider F q ℓ -linear codes in the metric space (F n q m , D).We start by providing the bounds obtained using the tools from graph theory.Theorem 2.3.Let 1 ≤ k ≤ ns and 1 ≤ d < +∞ be integers.Let We have Proof.We work with the bipartite graph where V is the set of elements in F n q m of minimum distance at most d − 1 (up to multiples by elements of F q ℓ ) from 0, W is the collection of F q ℓ -linear codes in F n q m of F q ℓ -dimension k, and (M, C ) ∈ E if and only if M ∈ C .Hence F is the family of non-isolated vertices in W .Note that we have Moreover, for M ∈ V we have Hence the bipartite graph B is left-regular of degree ns − 1 k − 1 q ℓ .With this, the upper bound in the theorem is an easy consequence of Lemma 1.9.For the lower bound, consider the association It is easy to see that and B is α-regular.Furthermore we have which combined with Lemma 1.10 directly implies the second bound in the theorem.
As an immediate consequence of the last theorem we obtain bounds on the density function of F q ℓ -codes with minimum distance bounded from below.

Asymptotic Results
This section is devoted to general asymptotic results on the density function of codes in F n q m endowed with a translation-invariant metric D.More precisely, we are interested in the following question: What is the probability that a uniformly random code in (F n q m , D) of a given cardinality has minimum distance (at least) d, as either q, n, or in the (sub)linear case s or ℓ tend to infinity, where s := [F q m : F q ℓ ].Our results indicate that the answer to this question highly depends on the volume of balls in (F n q m , D).We treat the nonlinear and (sub)linear case separately again.

The Nonlinear Case
From Corollary 2.2 we obtain asymptotic bounds on the density (as q → +∞ or n → +∞) of (possibly) nonlinear codes with minimum distance bounded from below.
Theorem 3.1.Let 2 ≤ n and let 1 ≤ d ≤ n be integers.Consider the sequence (F n q ) q∈Q and a sequence of integers (S q ) q∈Q with 2 ≤ S q for all q ∈ Q.
In particular, Proof.The first statement of the theorem is an easy consequence of Corollary 2.2 and the fact that we always have 0 ≤ δ D q (F n q , S q , 0, d).For the second statement, as in Theorem 2.1 we let It is easy to check that we have In order to prove that the asymptotic upper bound in the theorem is smaller than 1, note that v D q (F n q , d − 1) ∈ Ω q n S −2 q as q → +∞ means that In particular, rewriting (3.1) gives lim sup concluding the proof of the theorem.
We now establish the analogous result to Theorem 3.1 when n tends to infinity.The proof of the following statement is an easy alteration of the proof of Theorem 3.1 and hence we omit it.
Theorem 3.2.Let q ∈ Q be a prime power and d be an integer such that 1 ≤ d < +∞.Consider the sequence (F n q ) n≥1 and a sequence of integers (S n ) n≥1 with 2 ≤ S n for all 1 ≤ n.
In particular, As we applied the bounds given in Corollary 2.2 in a very general way, without having any knowledge about v D q (F n q , r), the requirements on the asymptotic behavior on the cardinalities in Theorem 3.1 and Theorem 3.2 for certain codes to be dense or sparse are the same, even though we send different parameters to infinity.This is something that we will also observe when looking at (sub)linear codes in the next subsection.Remark 3.3.In [12,22] Gilbert and Varshamov gave a lower bound that shows the existence of codes of sufficiently large cardinality and minimum distance.More precisely, it says that there exists a code C ⊆ F n q of minimum distance d with It is an immediate consequence of Theorem 3.1 and Theorem 3.2 that, while such codes exist, the probability that a uniformly random (possibly nonlinear) code, whose cardinality is close to the Gilbert-Varshamov bound, has minimum distance at least d, goes to 0 both as q → +∞ and n → +∞.

The (Sub)Linear Case
From Corollary 2.4 we obtain results for the asymptotic density of (sub)linear codes with minimum distance bounded from below as one of the parameters q, n, s or ℓ tends to infinity and the other three parameters are treated as constants.We will repeatedly use some asymptotic estimates of the q-binomial coefficient.One of these estimates involves the quantity Note that the infinite product π(q) is closely linked to the Euler function φ; see e.g.[2, Section 14].The Euler function φ : (−1, 1) → R is defined as We have π(q) = 1/φ(1/q) for all q ∈ Q.We will also need the following asymptotic estimates.
Lemma 3.4.Let 0 ≤ b ≤ a be integers and let k : N → N and k : N → N be linear functions such that k(n) ≤ k(n) for all n ∈ N. We have (b) a b q ℓ ∼ q ℓb(a−b) both as q → +∞, (respectively ℓ → +∞.) Similar asymptotic estimates as in Lemma 3.4 have been proved in [16,Section 6], and thus we omit the proofs.Theorem 3.5.Let 1 ≤ n, ℓ, s and 1 ≤ d < +∞ be integers.We fix 1 ≤ k ≤ ns and consider the sequence (F n q m ) q∈Q .
In particular, Proof.From Lemma 3.4 we obtain as q → +∞.Now (i) is an easy consequence of Corollary 2.4 and the fact that 0 ≤ δ D q (F n q m , q ℓk , ℓ, d).
For the second statement we consider the upper bound of Corollary 2.4.Together with Lemma 3.4 we have as q → +∞.Hence we obtain , as q → +∞.Now, taking the limit superior as q → +∞ in the bound of (2.2) reads lim sup .
as q → +∞, we have lim sup yielding the statement in (3.2).
Note that the asymptotic estimates for the q-binomial coefficient given in Lemma 3.4 are the same as q → +∞, respectively as ℓ → +∞.Hence we can give an analogous result to Theorem 3.5 but with ℓ tending to infinity.
Further note that the parameters of the q-binomial coefficient involved in the upper and lower bound of δ D q (F n q m , q ℓk , ℓ, d) (see Corollary 2.4) can be written as a linear function in either n or in s such that the assumptions of Lemma 3.4 are fulfilled.This gives us then two asymptotic results regarding n → +∞ (and s → +∞).Since the proofs of Theorem 3.6, Theorem 3.7 and Theorem 3.8 follow the same arguments as the proof of Theorem 3.5 we omit them.Theorem 3.6.Let 1 ≤ n, s and 1 ≤ d < +∞ be integers and let q ∈ Q.We fix 1 ≤ k ≤ ns and consider the sequence (F n q ℓs ) ℓ≥1 .
(i) We have max lim inf In particular, In the next theorem we consider the asymptotic density, where n tends to infinity and the other parameters are treated as constants.
Theorem 3.7.Let q ∈ Q, 1 ≤ s, ℓ and 1 ≤ d < +∞ be integers.Define a linear function k : N → N such that (k(n)) n≥1 describes a sequence of integers where 1 ≤ k(n) ≤ ns for all 1 ≤ n and consider the sequence (F n q m ) n≥1 .
(i) We have max lim inf In particular, In the last theorem concerning the asymptotic density of F q ℓ -linear codes we let s, go to infinity.Theorem 3.8.Let q ∈ Q, 1 ≤ n, ℓ and 1 ≤ d < +∞ be integers.Define a linear function k : N → N such that (k(s)) s≥1 describes a sequence of integers with 1 ≤ k(s) ≤ ns for all 1 ≤ s and consider the sequence (F n q ℓs ) s≥1 .
(ii) If v D q (F n q ℓs , d − 1) ∈ Ω q ℓ(ns+1−k) as s → +∞, then lim sup s→+∞ δ D q (F n q ℓs , q ℓk , ℓ, d) ≤ lim sup where we used the asymptotic estimate for n → +∞ in Lemma 5.5.The second statement in the theorem is then a consequence of Theorem 3.2.

(Sub)linear MRD Codes
The problem of determining whether (F q -linear and F q m -linear) MRD codes are dense or sparse has been studied before and we start this subsection by revisiting the results and their approaches that have been developed so far (see e.g.[1,7,13,16,17,18]), one of which is the application of the results presented in Section 2. We give a short recap of some of the results obtained with the other approaches in the language of this paper.
In [16] it was shown that [F n q m , q m(n−d+1) , 1, d]-MRD codes are sparse as q → +∞ unless d = 1 or n = d = 2. Together with a result from [1], where they computed the exact asymptotic density for when n = d = 2 using the theory of spectrum-free matrices, the density question for F q -linear MRD codes as q → +∞ is fully solved.Moreover, in [13], for the case where m = n = d = 3, an exact asymptotic estimate as for the density function of [F n q m , q m(n−d+1) , 1, d]-MRD codes q → +∞ was provided.This result was later generalized in [17] for any m = n = d that are prime.
Both the approach of [13] and the one of [17] are based on the connection between full-rank MRD codes and semifields.
Finally, using the Schwartz-Zippel Lemma, in [18] it was shown that F q m -linear MRD codes are dense as m → +∞.For F q -linear MRD codes it has only been shown that they are not dense as m → +∞ (see [1,7,16]).Whether they are sparse or not is to this day still an open question.
As the density of MRD codes has already been investigated rather thoroughly, in this subsection we will just close the gap by discussing the remaining asymptotic density results.We start by looking at the (sub)linear case for the field size q tending to infinity.As explained in Remark 5.4, when ℓs < n, then the codes of maximum possible dimension are not necessarily MRD codes.For this reason, the following theorem is split into two parts.
where k := ⌊n(ℓs − d + 1)/ℓ⌋ and r : Proof.For the first part of the theorem, note that we have Hence Write p(h) = h(mt+n−h) as a polynomial in h with roots at h = 0, h = mt+n and a maximum at h * = mt+n 2 .Note that p is monotonically increasing on 0, mt+n

2
. For h ≤ r ≤ t min{η, m} we have from which we can conclude that where z ≡ r (mod t).
As we saw in Remark 6.2, both the Hamming and the rank metric are special instances of the sum-rank metric.By analyzing the asymptotic densities of (sub)linear codes in these two metrics, we can infer that their behavior differs, especially when looking at q → +∞.This interesting fact motivates us to generalize and to analyze the asymptotic density as q tends to infinity in the sum-rank metric.
Figure 1: Block size η depending on t to fully characterize the asymptotic density of F q -linear MSRD codes as q → +∞.The green dots above the red line represent sets of parameters for which MSRD codes are sparse in F ηt q m , whereas those below the blue line indicate a dense behaviour.The black dots represent sets of parameters for which the asymptotic behaviour of the density is unknown, or as in the case of t = 1 and η = 2 can not be classified as asymptotically dense or sparse.Remark 6.12.Recall from Remark 6.2 that codes in the Hamming metric and codes in the rank metric are subfamilies of sum-rank-metric codes.It is interesting to observe that these two classes of codes behave very differently with respect to density considerations as q → +∞.More explicitly, in Section 4 we saw that F q -linear MDS codes are dense as q → +∞.This is in stark contrast with the behavior of F q -linear MRD codes: they are sparse as q → +∞ (see Section 5).Even though there does not seem to be an obvious way to fully characterize for which values of η, t and d we have sparsity or density (or non-density) of the corresponding codes, experimental results strongly indicate that, in general, sum-rank-metric codes behave similarly to standard rank-metric codes, with an exception when η = 1 (which is the case of Hamming-metric codes).Therefore MDS codes behave rather atypical with respect to density considerations.We collect some examples of the asymptotic behavior of the density of sum-rank-metric codes in Table 1.Table 1: Examples illustrating the asymptotic behavior of the density of F q -linear sum-rankmetric codes as q → +∞.

Conclusion and Outlook
We developed a general framework for determining densities of codes over finite fields, equipped with an arbitrary translation-invariant metric, with any linearity degree.This unifies several previous results (which were mostly derived with different mathematical tools) on densities of linear and nonlinear codes in the Hamming, rank and sum-rank metric.Moreover, we established new results for codes in these three metrics, answering many of the open question in this field.One general observation is that nonlinear codes achieving the Gilbert-Varshamov bound in any metric, or the Singleton-type bound in the sum-rank metric (including the Hamming and rank metric as special cases), are always sparse, for both the field size or the length going to infinity.However, in the (sub)linear case, the metric, the linearity degree and the parameter going to infinity make a difference.In some cases we get sparsity, in some density and in some cases we can only derive an upper bound on the asymptotic density, showing that the code family is not dense (but we do not know if they are sparse).
As a particular case of interest we studied the asymptotic behavior of MSRD codes for q → +∞, since MSRD codes generalize both the Hamming, as well as the rank metric.We derived bounds on the number of blocks for F q -linear MSRD codes to be dense or sparse.As explained in Remark 6.12, the only case where MSRD codes are dense is when they are MDS codes.In all other cases we either get sparsity or an upper bound below 1 for the density.
There are still many open questions for future work.E.g., in all cases where we obtained upper bounds below 1 for the density, it is not clear if this bound is sharp or if there are sharper bounds, or if these code families are even sparse.Furthermore, we only presented the asymptotic densities of MSRD codes as the field size q tends to infinity.With similar techniques we can derive results for the other parameters going to infinity, however, it was out of the scope of this paper to include them here; in particular, since they become more difficult due to the vast number of variable parameters.Moreover, we restricted ourselves to MSRD codes where each block has the same length, and it remains an open problem to study the densities of such codes with different block lengths.Lastly, we will extend our framework to other metric spaces and study the densities of codes over finite rings, equipped with the Hamming or the Lee metric.

Theorem 5 . 7 .
Let n, ℓ and s be positive integers and let 2 ≤ d ≤ n. (i) If n ≤ ℓs then we have lim q→+∞ δ rk q