mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-08-20 14:27:29 +00:00
fix(octave,go): Octave QS scope, Go module path
Octave: QS now passed as parameter instead of global variable Go: go.mod in go/ directory for proper module resolution
This commit is contained in:
parent
48ee7f7fdb
commit
e7e1a3d143
2 changed files with 12 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ import CoreFormalism.FixedPoint
|
||||||
|
|
||||||
open SilverSight.BraidStateN
|
open SilverSight.BraidStateN
|
||||||
open SilverSight.FixedPoint
|
open SilverSight.FixedPoint
|
||||||
|
open SilverSight.FixedPoint.Q16_16
|
||||||
|
|
||||||
namespace SilverSight.HopfFibration
|
namespace SilverSight.HopfFibration
|
||||||
|
|
||||||
|
|
@ -19,11 +20,11 @@ def conj (q : Quaternion) : Quaternion :=
|
||||||
{ a := q.a, b := Q16_16.neg q.b, c := Q16_16.neg q.c, d := Q16_16.neg q.d }
|
{ a := q.a, b := Q16_16.neg q.b, c := Q16_16.neg q.c, d := Q16_16.neg q.d }
|
||||||
|
|
||||||
def sumSq (q : Quaternion) : Q16_16 :=
|
def sumSq (q : Quaternion) : Q16_16 :=
|
||||||
let sq (x : Q16_16) := Q16_16.mul x x
|
let sq (x : Q16_16) : Q16_16 := Q16_16.mul x x
|
||||||
Q16_16.add (Q16_16.add (sq q.a) (sq q.b)) (Q16_16.add (sq q.c) (sq q.d))
|
Q16_16.add (Q16_16.add (sq q.a) (sq q.b)) (Q16_16.add (sq q.c) (sq q.d))
|
||||||
|
|
||||||
def isUnit (q : Quaternion) : Prop :=
|
def isUnit (q : Quaternion) : Prop :=
|
||||||
sumSq q = Q16_16.one
|
(Quaternion.sumSq q).val = Q16_16.one.val
|
||||||
|
|
||||||
def ofChiralLabel (label : ChiralLabel) : Quaternion :=
|
def ofChiralLabel (label : ChiralLabel) : Quaternion :=
|
||||||
match label with
|
match label with
|
||||||
|
|
@ -34,7 +35,7 @@ def ofChiralLabel (label : ChiralLabel) : Quaternion :=
|
||||||
|
|
||||||
theorem ofChiralLabel_isUnit (label : ChiralLabel) : isUnit (ofChiralLabel label) := by
|
theorem ofChiralLabel_isUnit (label : ChiralLabel) : isUnit (ofChiralLabel label) := by
|
||||||
unfold isUnit ofChiralLabel sumSq
|
unfold isUnit ofChiralLabel sumSq
|
||||||
simp
|
cases label <;> native_decide
|
||||||
|
|
||||||
end Quaternion
|
end Quaternion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ function check(cond, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_basic_add(avm)
|
function test_basic_add(avm)
|
||||||
|
QS = avm.Q16_SCALE;
|
||||||
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(5*QS), 'arg2', false), ...
|
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(5*QS), 'arg2', false), ...
|
||||||
struct('op', avm.OP_PUSH_Q16, 'arg', int32(3*QS), 'arg2', false), ...
|
struct('op', avm.OP_PUSH_Q16, 'arg', int32(3*QS), 'arg2', false), ...
|
||||||
struct('op', avm.OP_PRIM, 'arg', int32(avm.PRIM_ADD_Q16), 'arg2', false), ...
|
struct('op', avm.OP_PRIM, 'arg', int32(avm.PRIM_ADD_Q16), 'arg2', false), ...
|
||||||
|
|
@ -19,6 +20,7 @@ function test_basic_add(avm)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_div(avm)
|
function test_div(avm)
|
||||||
|
QS = avm.Q16_SCALE;
|
||||||
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(3*QS), 'arg2', false), ...
|
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(3*QS), 'arg2', false), ...
|
||||||
struct('op', avm.OP_PUSH_Q16, 'arg', int32(5*QS), 'arg2', false), ...
|
struct('op', avm.OP_PUSH_Q16, 'arg', int32(5*QS), 'arg2', false), ...
|
||||||
struct('op', avm.OP_PRIM, 'arg', int32(avm.PRIM_DIV_Q16), 'arg2', false), ...
|
struct('op', avm.OP_PRIM, 'arg', int32(avm.PRIM_DIV_Q16), 'arg2', false), ...
|
||||||
|
|
@ -30,6 +32,7 @@ function test_div(avm)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_saturation(avm)
|
function test_saturation(avm)
|
||||||
|
QS = avm.Q16_SCALE;
|
||||||
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(avm.AVM_CLAMP_MAX - 1), 'arg2', false), ...
|
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(avm.AVM_CLAMP_MAX - 1), 'arg2', false), ...
|
||||||
struct('op', avm.OP_PUSH_Q16, 'arg', int32(2), 'arg2', false), ...
|
struct('op', avm.OP_PUSH_Q16, 'arg', int32(2), 'arg2', false), ...
|
||||||
struct('op', avm.OP_PRIM, 'arg', int32(avm.PRIM_ADD_Q16), 'arg2', false), ...
|
struct('op', avm.OP_PRIM, 'arg', int32(avm.PRIM_ADD_Q16), 'arg2', false), ...
|
||||||
|
|
@ -40,6 +43,7 @@ function test_saturation(avm)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_locals(avm)
|
function test_locals(avm)
|
||||||
|
QS = avm.Q16_SCALE;
|
||||||
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(42*QS), 'arg2', false), ...
|
prog = {struct('op', avm.OP_PUSH_Q16, 'arg', int32(42*QS), 'arg2', false), ...
|
||||||
struct('op', avm.OP_STORE, 'arg', int32(0), 'arg2', false), ...
|
struct('op', avm.OP_STORE, 'arg', int32(0), 'arg2', false), ...
|
||||||
struct('op', avm.OP_LOAD, 'arg', int32(0), 'arg2', false), ...
|
struct('op', avm.OP_LOAD, 'arg', int32(0), 'arg2', false), ...
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue