1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
# Regina - A Normal Surface Theory Calculator
# Python Test Suite Component
#
# Copyright (c) 2007-2025, Ben Burton
# For further details contact Ben Burton (bab@debian.org).
#
# Provides some simple tests for arrow polynomials.
#
# This file is a single component of Regina's python test suite. To run
# the python test suite, move to the main python directory in the source
# tree and run "make check".
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# As an exception, when this program is distributed through (i) the
# App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or
# (iii) Google Play by Google Inc., then that store may impose any
# digital rights management, device limits and/or redistribution
# restrictions that are required by its terms of service.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
a = Arrow()
print(a, a.isZero())
print('--------')
a.initDiagram(3, 0, 1, 2)
print(a, a.isZero())
try:
a.initDiagram(3, 0, 'a')
except InvalidArgument:
print('Exception caught')
try:
a.initDiagram(1, 1, 0)
except InvalidArgument:
print('Exception caught')
print(a, a.isZero())
b = Arrow(a)
a += a
print(a, a.isZero(), b, b.isZero())
a -= a
print(a, a.isZero(), b, b.isZero())
print('--------')
a.set(Laurent(-1, [2, 0, 0, -1]))
a.set(1, Laurent(-2, [3, -1]))
try:
a.set(3, 0)
except InvalidArgument:
print('Exception caught')
try:
a.set(2, 0, Laurent(-2, [3, -1]))
except InvalidArgument:
print('Exception caught')
print(a, a.isZero())
print('--------')
b = Arrow()
b.set(1, Laurent(-2, [3, -1]))
print(b)
print(a + b)
print(a - b)
print(b + a)
print(b - a)
print(- a)
print('--------')
a += b
print(a)
a -= b
print(a)
a -= b
print(a)
print('--------')
a += b
print(a, 'vs', b)
a.swap(b)
print(a, 'vs', b)
swap(b, a)
print(a, 'vs', b)
print('--------')
print(a * -3)
print(-3 * a)
print(a * Laurent(2, [1]))
print(Laurent(2, [1]) * a)
print('--------')
print(a[[]])
print(a[[1]])
print(a[[2]])
print(a[[0, 1]])
a[[0, 1]] = Laurent(3, [2, 0, -5])
print(a)
print(a[[0, 1]])
try:
print(a[[0, 1, 0]])
except InvalidArgument:
print('Exception caught')
a[[0, 1]] = Laurent()
print(a)
print('--------')
a *= -3
print(a)
a *= Laurent(2, [1])
print(a)
print('--------')
a.shift(-2)
print(a)
a.negate()
print(a)
a.invertA()
print(a)
a.scaleUp(2)
print(a)
a.scaleDown(-2)
print(a)
print('--------')
print(a.tightEncoding())
print(Arrow.tightDecoding(a.tightEncoding()))
a.init()
print(a, a.isZero())
print(a.tightEncoding())
print(Arrow.tightDecoding(a.tightEncoding()))
print('--------')
print(Arrow([([], Laurent(-4, [1])), ([1], Laurent(-10, [-1,0,0,0,1]))]))
print(Arrow([([], (-4, [1])), ([1], (-10, [-1,0,0,0,1]))]))
print(Arrow([([], (-4, [1])), ([], (-4, [2])), ([1], (-10, [-1,0,0,0,1]))]))
print(Arrow([([], (-4, [1])), ([], (-4, [-1])), ([1], (-10, [-1,0,0,0,1]))]))
try:
print(Arrow([([], (-4, [1])), ([1, 'a'], (-10, [-1,0,0,0,1]))]))
except InvalidArgument:
print('Exception caught')
try:
print(Arrow([([], (-4, [1])), ([1, -2], (-10, [-1,0,0,0,1]))]))
except InvalidArgument:
print('Exception caught')
laurent = Laurent(-2, [4,0,0,-1])
print(Arrow([([], laurent)]) == laurent)
print(Arrow([([1], laurent)]) == laurent)
print(Arrow([([], laurent), ([1], laurent)]) == laurent)
print(Arrow([([], laurent), ([1], laurent)])[[1]] == laurent)
print('--------')
# Compute some actual arrow polynomials.
# The following examples are all taken from Dye & Kauffman, JKTR 18 (2009).
# These are also in the C++ test suite; see there for further discussion
# (including the reasons why some of our answers differ from Dye-Kauffman).
# Section 3.1: Virtual Hopf link
l = Link.fromData([-1], [[1], [-1]])
print(l); print(l.arrow())
# Section 3.2: Virtualised trefoil (not the virtual trefoil!)
l = Link.fromData([+1, +1, -1], [1, -2, 3, -1, 2, -3])
print(l); print(l.arrow())
# Section 3.3: Kishino's knot
l = Link.fromData([+1, -1, +1, -1], [1, -2, 4, -3, -4, 3, -1, 2])
print(l); print(l.arrow())
# Section 3.4: Slavik's knot
l = Link.fromData([+1, +1, -1, -1, -1], [1, -3, 4, -1, 2, -5, 3, -4, 5, -2])
print(l); print(l.arrow())
# Section 3.5: Miyazawa's knot
# Note: our answer differs by sign (+/-) for the coefficient of K_1^2 A^-4.
# However: our answer is consistent with the Jones polynomial for that same
# knot, and so it seems likely that the sign error is in the Dye-Kauffman paper.
l = Link.fromData([+1, -1, +1, +1], [1, -2, -3, -1, 3, 4, 2, -4])
print(l); print(l.arrow())
# Section 3.6: Two knots differentiated only by K_1 and K_3
l1 = Link.fromSignedGauss('O1-O2-O3-O4+U1-U3-U2-U4+') # knot 4.93
l2 = Link.fromSignedGauss('O1-O2-U3-O4+U2-U1-O3-U4+') # knot 4.103
print(l1); print(l1.arrow());
print(l2); print(l2.arrow());
# Section 3.8: Two virtual torus links
# Note: In the Dye-Kauffman paper, the polynomials for these links do not
# appear to be normalised using the writhe (though this is perhaps explicitly
# noted in the paper since they use the subscript <..>_A instead of <..>_NA.
l1 = Link.fromData([+1, +1, +1], [[1, -2, 3], [-1, 2, -3]])
l2 = Link.fromData([-1, -1, -1], [[3, -2, 1], [-1, 2, -3]])
print(l1); print(l1.arrow());
print(l2); print(l2.arrow());
|