From bcc16cc2dffe9449042dd5355ea4c1fb0e1765d4 Mon Sep 17 00:00:00 2001 From: Prabhat1308 Date: Sun, 1 Oct 2023 16:34:17 +0530 Subject: [PATCH] added Constants.huff and updated Helper.huff --- src/Complex.huff | 16 +++++++++------- src/Constants.Huff | 4 ++++ src/Helper.huff | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 src/Constants.Huff diff --git a/src/Complex.huff b/src/Complex.huff index d4bb950..dbd3903 100644 --- a/src/Complex.huff +++ b/src/Complex.huff @@ -1,4 +1,5 @@ #include './Helper.huff' +#include './Constants.huff' #define function addZ(int256 , int 256 , int256 , int256) returns (int256 ,int256) #define function subZ(int256 , int 256 , int256 , int256) returns (int256 ,int256) @@ -153,16 +154,16 @@ swap2 // [Re(A),Re(B),Im(A)*Im(B),Re(B)*Im(A)-Re(A)*Im(B),X] mul // [Re(A)*Re(B),Im(A)*Im(B),Re(B)*Im(A)-Re(A)*Im(B),X] add // [Re(A)*Re(B)+Im(A)*Im(B),Re(B)*Im(A)-Re(A)*Im(B),X] ; Let Re(A)*Re(B)+Im(A)*Im(B) be Y and Re(B)*Im(A)-Re(A)*Im(B) be W - 0xDE0B6B3A7640000 // [1e18,Y,W,X] + [X3]// [1e18,Y,W,X] mul // [1e18*Y,W,X] dup3 // [X,1e18*Y,W,X] swap1 // [1e18*Y,X,W,X] - div // [1e18*Y/X,W,X] + sdiv // [1e18*Y/X,W,X] swap2 // [X,W,1e18*Y/X] swap1 // [W,X,1e18*Y/X] - 0xDE0B6B3A7640000 // [1e18,W,X,1e18*Y/X] + [X3]// [1e18,W,X,1e18*Y/X] mul // [1e18*W,X,1e18*Y/X] - div // [1e18*W/X,1e18*Y/X] + sdiv // [1e18*W/X,1e18*Y/X] swap1 // [1e18*Y/X,1e18*W/X] } @@ -193,12 +194,12 @@ CALC_R() // [r,Re(a),Im(a)] dup1 // [r,r,Re(a),Im(a)] 0x00 // [0,r,r,Re(a),Im(a)] - lt // [0 [T,r] dup1 // [T,T,r] 0x00 // [0,T,T,r] - lt // [0 [x] + 0x00 //[0,x] + dup2 //[x,0,x] + slt // [x<0,x] + reverse + jumpi + + reverse: + dup1 //[x,x] + dup1 //[x,x,x] + add //[2x,x] + swap1 //[x,2x] + sub //[-x] +} + +#define macro PUT_X3_CUBE = takes(0) returns(1){ + 0x03 //[2] + [X3] //[1e18,3] + exp //[1e54] +} \ No newline at end of file