Пример #1
0
 def __init__(self, l_fac, r0):
     self.PI_2 = acos(D0)
     self.ph = self.phDot = D0
     self.r = r0
     self.L = l_fac * sqrt(r0)
     self.L2 = self.L**2
     self.rDot = - sqrt(r0 - self.L2) / self.r
     self.H0 = self.h()
Пример #2
0
def genNlatValue(latitude):
    j = 2
    buff = numpy.empty(63,dtype = object)
    #print buff
    buff[:] = [mpfr('1.0') for _ in range(63)] #double array of length 63
    
    for i in xrange(2,60):
        Nlat = mpfr(0.0)
        sqrtHold = mpfr(0.0)
        Nlat = (180/pi)*(gmpy2.acos(math.sqrt((1-(math.cos(pi/30)))/(1-(gmpy2.cos((2*pi)/i))))));
        buff[j] = Nlat
        j = j+1
    
    for k in xrange(59,1,-1):
        if ( latitude > buff[k]):
            pass
        else:
            if (k<2):
                return 1
            return k
Пример #3
0
 def __init__(self, cc, a, mu2, e, l, q, r0, th0, xh):
     self.l_3 = cc / D3
     self.a = a
     self.mu2 = mu2
     self.E = e
     self.L = l
     self.a2 = a**2
     self.a2l_3 = self.a2 * self.l_3
     self.a2mu2 = self.a2 * mu2
     self.aE = a * e
     self.aL = a * l
     self.X2 = (D1 + self.a2l_3)**2
     self.two_EX2 = D2 * e * self.X2
     self.two_aE = D2 * a * e
     self.K = q + self.X2 * (l - self.aE)**2
     self.t = self.ph = D0
     self.r = r0
     self.th = (mpfr("90.0") - th0) * acos(mpfr("-1")) / mpfr("180.0")
     self.cross = xh
     self.refresh()
     self.Ur = - sqrt(self.r_potential if self.r_potential >= D0 else -self.r_potential)
     self.Uth = - sqrt(self.th_potential if self.th_potential >= D0 else -self.th_potential)
Пример #4
0
def genNlatValue(latitude):
    j = 2
    buff = numpy.empty(63, dtype=object)
    #print buff
    buff[:] = [mpfr('1.0') for _ in range(63)]  #double array of length 63

    for i in xrange(2, 60):
        Nlat = mpfr(0.0)
        sqrtHold = mpfr(0.0)
        Nlat = (180 / pi) * (gmpy2.acos(
            math.sqrt((1 - (math.cos(pi / 30))) / (1 - (gmpy2.cos(
                (2 * pi) / i))))))
        buff[j] = Nlat
        j = j + 1

    for k in xrange(59, 1, -1):
        if (latitude > buff[k]):
            pass
        else:
            if (k < 2):
                return 1
            return k
Пример #5
0
import gmpy2
#import matplotlib.pyplot as plt
import os
import bisect
from numpy import linspace
# gmpy2 precision initialization
BITS = (1 << 10)
BYTES = BITS/8
gmpy2.get_context().precision = BITS # a whole lotta bits

def random():
    seed = int(os.urandom(BYTES).encode('hex'), 16)
    return gmpy2.mpfr_random(gmpy2.random_state(seed))

# Useful constants as mpfr
PI = gmpy2.acos(-1)
LOG2E = gmpy2.log2(gmpy2.exp(1))
LN2 = gmpy2.log(2)
# Same, as 192.64 fixedpoint
FX_PI = int(PI * 2**64)
FX_LOG2E = int(LOG2E * 2**64)
FX_LN2 = int(LN2 * 2**64)
FX_ONE = 1 << 64
## The index of a poly is the power of x,
## the val at the index is the coefficient.
##
## An nth degree poly is a list of len n + 1.
##
## The vals in a poly must all be floating point
## numbers.
Пример #6
0
op = op[::-1]  #reverse the memory

op = [''.join(op[6 * i:6 * i + 6]) for i in range(len(op) // 6)]
# print(op) #op contains bytes in little-endian form, need to be careful
int_val = '0000' + op[0]  #integer has lower bytes as zero
float_vals = [s + 'd6bf'
              for s in op[1:]]  #float has higher bytes as 'd6bf' coz cosine

(int_val, ) = struct.unpack(
    'd', bytes.fromhex(int_val))  #read the value as a double

import gmpy2

l = []
for s in float_vals:
    (a, ) = struct.unpack('d', bytes.fromhex(s))  #read as double
    l.append(a)

l = [
    gmpy2.mpz((gmpy2.acos(i) - gmpy2.mpq(1) - gmpy2.mpq(15, 16) -
               gmpy2.mpq(8, 16**12)) * gmpy2.mpz(16**11)) for i in l
]  #find out X, and make it integer
l.insert(3,
         gmpy2.mpz(int_val))  #0:4, 4:8, 8:12 then insert the integer([12:16])
s = []
for i in l:
    (a, ) = struct.unpack('4s', bytes.fromhex(
        hex(i)[2:]))  #read integer as qword, convert to 4-length string
    s.append(a[::-1]
             )  #need to reverse because X was reversed(X4 X3 X2 X1, remember)
print(b''.join(s))  #flag :)
 def arccos(self):
     return Numeric(gmpy2.acos(self.val))
Пример #8
0
import gmpy2
#import matplotlib.pyplot as plt
import os
import bisect
from numpy import linspace
# gmpy2 precision initialization
BITS = (1 << 10)
BYTES = BITS/8
gmpy2.get_context().precision = BITS # a whole lotta bits

def random():
    seed = int(os.urandom(BYTES).encode('hex'), 16)
    return gmpy2.mpfr_random(gmpy2.random_state(seed))

# Useful constants as mpfr
PI = gmpy2.acos(-1)
LOG2E = gmpy2.log2(gmpy2.exp(1))
LN2 = gmpy2.log(2)
# Same, as 192.64 fixedpoint
FX_PI = int(PI * 2**64)
FX_LOG2E = int(LOG2E * 2**64)
FX_LN2 = int(LN2 * 2**64)
FX_ONE = 1 << 64
## The index of a poly is the power of x,
## the val at the index is the coefficient.
##
## An nth degree poly is a list of len n + 1.
##
## The vals in a poly must all be floating point
## numbers.
 def arccos(self):
     return Numeric(gmpy2.acos(self.val))