cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A144017 Number of n X n X n alternating sign hypermatrices.

This page as a plain text file.
%I A144017 #14 Jul 15 2023 06:22:48
%S A144017 1,1,2,14,924,852960
%N A144017 Number of n X n X n alternating sign hypermatrices.
%C A144017 An alternating sign hypermatrix (ASHM) of order n is an n X n X n hypermatrix with entries from {0, 1, -1} such that the nonzero entries of each row, column, and vertical line alternate in sign, beginning and ending with +1.
%C A144017 ASHMs are the three-dimensional analog of alternating sign matrices and generalize Latin squares, as the set of n X n X n ASHMs containing no negative entries is in bijection with the set of n X n Latin squares.
%H A144017 R. Brualdi and G. Dahl, <a href="https://doi.org/10.1016/j.aam.2017.11.005">Alternating sign matrices and hypermatrices, and a generalization of Latin squares</a>, Advances in Applied Mathematics, 95 (2018), 116 - 151.
%H A144017 Cian O'Brien, <a href="https://doi.org/10.1016/j.aam.2020.102097">Alternating sign hypermatrix decompositions of Latin-like squares</a>, Advances in Applied Mathematics, 121 (2020), 102097.
%F A144017 Verified using 2 computer searches. The search given counts all sequences of n alternating sign matrices of order n that form an ASHM. The other search uses corner-sum matrices, which are known to be in bijection with alternating sign matrices, by counting all 3-dimensional analogs of corner-sum matrices.
%e A144017 For n = 1, the only n X n X n ASHM is [[[1]]].
%e A144017 For n = 2, the two n X n X n ASHMs are
%e A144017 [[[1,0],
%e A144017   [0,1]],
%e A144017  [[0,1],
%e A144017   [1,0]]]
%e A144017 and
%e A144017 [[[0,1],
%e A144017   [1,0]],
%e A144017  [[1,0],
%e A144017   [0,1]]].
%o A144017 (Sage)
%o A144017 # Program written in Sage
%o A144017 # Returns True if a given list of n n X n ASMs form an ASHM, returns False otherwise
%o A144017 def ASHM(L):
%o A144017     n = len(L)
%o A144017     # Searches through the vertical line in position (i,j) of the hypermatrix for each i and j
%o A144017     for i in range(n):
%o A144017         for j in range(n):
%o A144017             # Since the first nonzero entry in each line of an ASHM is +1, the alternating condition is checked
%o A144017             # as if the previous nonzero entry was -1
%o A144017             last = -1
%o A144017             for k in range(n):
%o A144017                 # In each position of the current vertical line, if the sign of the current entry is the opposite
%o A144017                 # of the previous, then the previous sign is updated
%o A144017                 if L[k][i,j]*last == -1:
%o A144017                     last *= -1
%o A144017                 # Otherwise False is returned unless the current entry is 0
%o A144017                 elif L[k][i,j] != 0:
%o A144017                     return False
%o A144017             # If the most recent nonzero entry is not +1 by the time all entries have been checked, False is returned
%o A144017             if last != 1:
%o A144017                 return False
%o A144017     # If False has not been returned, return True
%o A144017     return True
%o A144017 # Generates all combinations of one element from each list in L
%o A144017 def combos(L, current = [[]]):
%o A144017     # If there are no elements left which have not been combined, then return the combinations already made
%o A144017     if len(L) == 0:
%o A144017         return current
%o A144017     # Otherwise, each element of the next list in L is appended to the current list of combinations made
%o A144017     output = []
%o A144017     for K in current:
%o A144017         for a in L[0]:
%o A144017             output.append(K + [a])
%o A144017     return combos(L[1:], output)
%o A144017 # Counts all ASHMs of order n
%o A144017 def count_ASHMs(n):
%o A144017     # All ASMs of order n are imported as matrices
%o A144017     asms = []
%o A144017     for A in AlternatingSignMatrices(n):
%o A144017         asms.append(A.to_matrix())
%o A144017     # Initially, zero ASHMs have been counted
%o A144017     count = 0
%o A144017     # Every possible combination of n n X n ASMs is checked
%o A144017     for i in combos([[k for k in range(len(asms))] for m in range(n)]):
%o A144017         # If the current list of n n X n ASMs forms an ASHM, then it is counted
%o A144017         count += int(ASHM([asms[i[k]] for k in range(n)]))
%o A144017     # The final count is returned
%o A144017     return count
%o A144017 # Note: I ran a more efficient version of this program in Python to obtain the answer for n=5, and even then it took 6 hours.
%o A144017 print(count_ASHMs(0))
%o A144017 print(count_ASHMs(1))
%o A144017 print(count_ASHMs(2))
%o A144017 print(count_ASHMs(3))
%o A144017 print(count_ASHMs(4))
%o A144017 print(count_ASHMs(5))
%o A144017 # _Cian O'Brien_, May 31 2023
%Y A144017 3-dimensional analog of A005130, generalization of A002860.
%K A144017 nonn,hard,more
%O A144017 0,3
%A A144017 Samuel Zbarsky (sa_zbarsky(AT)yahoo.com), Sep 07 2008
%E A144017 a(4) corrected and a(5) added, and definition updated by _Cian O'Brien_, May 31 2023