def codesize_upper_bound(n, d, q, algorithm=None): r""" This computes the minimum value of the upper bound using the methods of Singleton, Hamming, Plotkin, and Elias. If algorithm="gap" then this returns the best known upper bound `A(n,d)=A_q(n,d)` for the size of a code of length n, minimum distance d over a field of size q. The function first checks for trivial cases (like d=1 or n=d), and if the value is in the built-in table. Then it calculates the minimum value of the upper bound using the algorithms of Singleton, Hamming, Johnson, Plotkin and Elias. If the code is binary, `A(n, 2\ell-1) = A(n+1,2\ell)`, so the function takes the minimum of the values obtained from all algorithms for the parameters `(n, 2\ell-1)` and `(n+1, 2\ell)`. This wraps GUAVA's (i.e. GAP's package Guava) UpperBound( n, d, q ). If algorithm="LP" then this returns the Delsarte (a.k.a. Linear Programming) upper bound. EXAMPLES:: sage: codesize_upper_bound(10,3,2) 93 sage: codesize_upper_bound(24,8,2,algorithm="LP") 4096 sage: codesize_upper_bound(10,3,2,algorithm="gap") # optional - gap_packages (Guava package) 85 sage: codesize_upper_bound(11,3,4,algorithm=None) 123361 sage: codesize_upper_bound(11,3,4,algorithm="gap") # optional - gap_packages (Guava package) 123361 sage: codesize_upper_bound(11,3,4,algorithm="LP") 109226 """ if algorithm == "gap": gap.load_package('guava') return int(gap.eval("UpperBound(%s,%s,%s)" % (n, d, q))) if algorithm == "LP": return int(delsarte_bound_hamming_space(n, d, q)) else: eub = elias_upper_bound(n, q, d) gub = griesmer_upper_bound(n, q, d) hub = hamming_upper_bound(n, q, d) pub = plotkin_upper_bound(n, q, d) sub = singleton_upper_bound(n, q, d) return min([eub, gub, hub, pub, sub])
def codesize_upper_bound(n, d, q, algorithm=None): r""" This computes the minimum value of the upper bound using the methods of Singleton, Hamming, Plotkin, and Elias. If algorithm="gap" then this returns the best known upper bound `A(n,d)=A_q(n,d)` for the size of a code of length n, minimum distance d over a field of size q. The function first checks for trivial cases (like d=1 or n=d), and if the value is in the built-in table. Then it calculates the minimum value of the upper bound using the algorithms of Singleton, Hamming, Johnson, Plotkin and Elias. If the code is binary, `A(n, 2\ell-1) = A(n+1,2\ell)`, so the function takes the minimum of the values obtained from all algorithms for the parameters `(n, 2\ell-1)` and `(n+1, 2\ell)`. This wraps GUAVA's (i.e. GAP's package Guava) UpperBound( n, d, q ). If algorithm="LP" then this returns the Delsarte (a.k.a. Linear Programming) upper bound. EXAMPLES:: sage: codes.bounds.codesize_upper_bound(10,3,2) 93 sage: codes.bounds.codesize_upper_bound(24,8,2,algorithm="LP") 4096 sage: codes.bounds.codesize_upper_bound(10,3,2,algorithm="gap") # optional - gap_packages (Guava package) 85 sage: codes.bounds.codesize_upper_bound(11,3,4,algorithm=None) 123361 sage: codes.bounds.codesize_upper_bound(11,3,4,algorithm="gap") # optional - gap_packages (Guava package) 123361 sage: codes.bounds.codesize_upper_bound(11,3,4,algorithm="LP") 109226 """ if algorithm == "gap": gap.load_package("guava") return int(gap.eval("UpperBound(%s,%s,%s)" % (n, d, q))) if algorithm == "LP": return int(delsarte_bound_hamming_space(n, d, q)) else: eub = elias_upper_bound(n, q, d) gub = griesmer_upper_bound(n, q, d) hub = hamming_upper_bound(n, q, d) pub = plotkin_upper_bound(n, q, d) sub = singleton_upper_bound(n, q, d) return min([eub, gub, hub, pub, sub])