summaryrefslogtreecommitdiffstats
path: root/two.py
diff options
context:
space:
mode:
authorsyn <isaqtm@gmail.com>2020-02-16 11:56:52 +0300
committersyn <isaqtm@gmail.com>2020-02-16 11:56:52 +0300
commitfd78d0fd00e6b98ae8b9894db8be028575e205ac (patch)
treeee9dd35e871d222aa60a1958e9b6f28eaa6ecc54 /two.py
downloadalg3-fd78d0fd00e6b98ae8b9894db8be028575e205ac.tar.gz
Init commit
Diffstat (limited to 'two.py')
-rw-r--r--two.py107
1 files changed, 107 insertions, 0 deletions
diff --git a/two.py b/two.py
new file mode 100644
index 0000000..b5e8b86
--- /dev/null
+++ b/two.py
@@ -0,0 +1,107 @@
+from libsolve import *
+from fractions import Fraction
+import numpy as np
+
+TWO_SIMEQ = '\\overset{{\\texttt{{two.py}}}}\\simeq'
+
+# generate figure as plain file, so we can \input it
+def gen_figure(figname, text):
+ with open(f'figures/fig_two_{figname}.tex', 'w') as fd:
+ fd.write('$$' + text + '$$')
+
+AT = Matrix([
+ [-2, 14, 18, 14],
+ [-3, -9, -3, -3],
+ [-12, -6, 18, 12],
+ [6, 18, 6, 6]
+])
+
+
+before = AT.to_tex()
+
+AT.make_D(0, -Fraction(1, 2))
+AT.make_D(1, -Fraction(1, 3))
+AT.make_D(2, -Fraction(1, 6))
+AT.make_D(3, Fraction(1, 6))
+
+AT.make_S(1, 0, -1)
+AT.make_S(2, 0, -2)
+AT.make_S(3, 0, -1)
+
+AT.make_S(2, 1, -Fraction(3, 2))
+AT.make_S(3, 1, -1)
+
+AT.make_D(1, Fraction(1, 2))
+
+gen_figure('fsr_A_T',
+f'''
+ {before}
+ {TWO_SIMEQ}
+ {AT.to_tex()}
+''')
+
+
+AB = Matrix([
+ [-2, -3, -12, 6],
+ [14, -9, -6, 18],
+ [18, -3, 18, 6],
+ [14, -3, 12, 6],
+ [2, -1, 1, 0],
+ [7, -4, 0, 5]
+])
+
+before = AB.to_tex()
+
+AB.triangulate()
+
+AB.make_D(0, Fraction(1, 2))
+AB.make_D(1, -Fraction(1, 30))
+AB.make_U(2, 4)
+
+
+gen_figure('AB_sol',
+f'''
+{before}
+{TWO_SIMEQ}
+{AB.to_tex()}
+''')
+
+
+A = Matrix([
+ [-2, -3, -12, 6],
+ [14, -9, -6, 18],
+ [18, -3, 18, 6],
+ [14, -3, 12, 6]
+])
+
+before = A.to_tex()
+A.triangulate()
+
+A.make_D(0, -1)
+A.make_D(1, -Fraction(1, 30))
+
+gen_figure('ker_A',
+f'''
+ {before}
+ {TWO_SIMEQ}
+ {A.to_tex()}
+''')
+
+imker = Matrix([
+ [-2, 14, 18, 14],
+ [-3, -9, -3, -3],
+ [-12, -6, 18, 12],
+ [6, 18, 6, 6],
+ [-3, -6, 2, 0],
+ [0, 2, 0, 1]
+])
+
+before = imker.to_tex()
+imker.triangulate()
+
+gen_figure('imker',
+f'''
+ {before}
+ {TWO_SIMEQ}
+ {imker.to_tex()}
+''') \ No newline at end of file