Пример #1
0
def carvedToWritten(n):
    n = ui(n)
    r = ui(0)
    for pos in arange(64, dtype=ui):
        b_val = innerFunct(n, pos)
        r |= (b_val & (ONE << pos))
    return r
Пример #2
0
def innerFunct(n, pos):
    #print("n=%s, pos=%s" % (n, pos))
    res = ui(0)
    for m in reversed(arange(n + 1, dtype=ui)):
        b = ui(0)
        for index in arange(pos + 1, dtype=ui):
            c = res ^ (((pos & n & ~m) | (pos & ~n & m) & ONE) << index)
            res ^= (m & (ONE << index)) ^ b
            b = (((c & m) | (c & b) | (m & b)) & (ONE << index)) << ONE
            #print("R: {0:064b}".format(res).replace("0"," ")+"|%s" % (res))

    return res & (ONE << pos)
Пример #3
0
def carvedToWritten(n):
    n = ui(n)
    r = ui(0)
    for i in arange(64, dtype=ui):
        a = ui(0)
        for j in reversed(arange(n + 1, dtype=ui)):
            b = ui(0)
            for k in arange(i + 1, dtype=ui):
                c = a ^ (((i & n & ~j) | (i & ~n & j) & ONE) << k)
                a ^= (j & (ONE << k)) ^ b
                b = (((c & j) | (c & b) | (j & b)) & (ONE << k)) << ONE
        r |= (a & (ONE << i))
    return r
Пример #4
0
def carvedToWritten(n):
    n = ui(n)
    r = ui(0)
    for i in arange(64, dtype=ui):
        a = ui(0)
        for j in reversed(arange(n + 1, dtype=ui)):
            b = ui(0)
            for k in arange(i + 1, dtype=ui):
                #print("N: {0:064b}".format(n).replace("0"," ")+"|%s" % n)
                #print("I: {0:064b}".format(i).replace("0"," ")+"|%s" % i)
                #print("J: {0:064b}".format(j).replace("0"," ")+"|%s" % j)
                #print("K: {0:064b}".format(k).replace("0"," ")+"|%s" % k)
                c = a ^ (((i & n & ~j) | (i & ~n & j) & ONE) << k)
                #print("C: {0:064b}".format(c).replace("0"," ")+"|%s" % c)
                a ^= (j & (ONE << k)) ^ b
                #print("A: {0:064b}".format(a).replace("0"," ")+"|%s" % a)
                b = (((c & j) | (c & b) | (j & b)) & (ONE << k)) << ONE
                #print("B: {0:064b}".format(b).replace("0"," ")+"|%s" % b)
                #print("-"*67+"+")
            #print("-"*67+"+")
        r |= (a & (ONE << i))
        #print("R: {0:064b}".format(r).replace("0"," ")+"|%s" % r)
        #print("-"*67+"+")
    return r
Пример #5
0
from numpy import uint64 as ui, arange

START = 1050

ONE = ui(1)


def carvedToWritten(n):
    n = ui(n)
    r = ui(0)
    for i in arange(64, dtype=ui):
        a = ui(0)
        for j in reversed(arange(n + 1, dtype=ui)):
            b = ui(0)
            for k in arange(i + 1, dtype=ui):
                #print("N: {0:064b}".format(n).replace("0"," ")+"|%s" % n)
                #print("I: {0:064b}".format(i).replace("0"," ")+"|%s" % i)
                #print("J: {0:064b}".format(j).replace("0"," ")+"|%s" % j)
                #print("K: {0:064b}".format(k).replace("0"," ")+"|%s" % k)
                c = a ^ (((i & n & ~j) | (i & ~n & j) & ONE) << k)
                #print("C: {0:064b}".format(c).replace("0"," ")+"|%s" % c)
                a ^= (j & (ONE << k)) ^ b
                #print("A: {0:064b}".format(a).replace("0"," ")+"|%s" % a)
                b = (((c & j) | (c & b) | (j & b)) & (ONE << k)) << ONE
                #print("B: {0:064b}".format(b).replace("0"," ")+"|%s" % b)
                #print("-"*67+"+")
            #print("-"*67+"+")
        r |= (a & (ONE << i))
        #print("R: {0:064b}".format(r).replace("0"," ")+"|%s" % r)
        #print("-"*67+"+")
    return r
Пример #6
0
from numpy import uint64 as ui, arange
from random import randint

from nimblenet.activation_functions import sigmoid_function
from nimblenet.cost_functions import cross_entropy_cost
from nimblenet.learning_algorithms import RMSprop
from nimblenet.data_structures import Instance
from nimblenet.neuralnet import NeuralNet

SAMPLE_SIZE = 10**1

ONE = ui(1)

ONE = ui(1)


def carvedToWritten(n):
    n = ui(n)
    r = ui(0)
    for i in arange(64, dtype=ui):
        a = ui(0)
        for j in reversed(arange(n + 1, dtype=ui)):
            b = ui(0)
            for k in arange(i + 1, dtype=ui):
                c = a ^ (((i & n & ~j) | (i & ~n & j) & ONE) << k)
                a ^= (j & (ONE << k)) ^ b
                b = (((c & j) | (c & b) | (j & b)) & (ONE << k)) << ONE
        r |= (a & (ONE << i))
    return r