Beispiel #1
0
def main():
    print("What happens when you invert the identity matrix?")
    a = identity_matrix()
    print(inverse(a))

    print()
    print("What do you get when you multiply a matrix by its inverse?")
    a = identity_matrix()
    a[1][0] = 2
    a[0][3] = -5
    b = multiply_matrix(a, inverse(a))
    print(b)

    print()
    print(
        "Is there any difference between the inverse of the transpose of a matrix, and the transpose of the inverse?"
    )
    c = inverse(transpose(a))
    d = transpose(inverse(a))
    print(c)
    print(d)

    print()
    print(
        "Remember how multiplying the identity matrix by a tuple gives you the tuple, unchanged?"
    )
    t = tuple_4d(5, 4, 3, 1)
    i = identity_matrix()
    c = multiply_tuple(i, t)
    print(c)

    print()
    print(
        "Now, try changing any single element of the identity matrix to a different number, and then multiplying it by a tuple. What happens to the tuple?"
    )
    i[1][1] = 2
    i[2][2] = 3
    c = multiply_tuple(i, t)
    print(c)
def step_impl(context):
    context.b = inverse(context.m)
def step_impl(context):
    actual = multiply_matrix(context.c, inverse(context.b))
    expected = context.m
    assert_matrix(actual, expected)
def step_impl(context):
    context.inv = inverse(context.half_quarter)
def step_impl(context):
    context.transform = inverse(scaling(2, 3, 4))
Beispiel #6
0
 def set_transform(self, transformation_matrix):
     """set transformation matrix for the shape"""
     self.__transform = transformation_matrix
     self.__inverse_transform = inverse(transformation_matrix)
Beispiel #7
0
 def set_transform(self, transformation_matrix):
     self.__transform = transformation_matrix
     self.__inverse_transform = inverse(transformation_matrix)
Beispiel #8
0
def mobius_transform(z, a, b, c, d):
    numerator = core._multiply(a, z, reduced) ^ b
    denominator = core._multiply(c, z, reduced) ^ d
    return core._multiply(numerator, core.inverse(denominator, reduced),
                          reduced)
Beispiel #9
0
import analysis

# A list of irreducible polynomials and constants
# http://www.sciencedirect.com/science/article/pii/S2212017313006051
irreducibles = [
    0x11B, 0x11D, 0x12B, 0x12D, 0x139, 0x13F, 0x14D, 0x15F, 0x163, 0x165,
    0x169, 0x171, 0x177, 0x17B, 0x187, 0x18B, 0x18D, 0x19F, 0x1A3, 0x1A9,
    0x1B1, 0x1BD, 0x1C3, 0x1CF, 0x1D7, 0x1DD, 0x1E7, 0x1F3, 0x1F5, 0x1F9
]

constants = [
    0x0A, 0x0F, 0x15, 0x2A, 0x2B, 0x31, 0x32, 0x35, 0x38, 0x40, 0x4A, 0x4E,
    0x54, 0x5E, 0x62, 0x6E, 0x74, 0x7E, 0xF5, 0xF0, 0xEA, 0xD5, 0xD4, 0xCE,
    0xCD, 0xCA, 0xC7, 0xBF, 0xB5, 0xB1, 0xAB, 0xA1, 0x9D, 0x91, 0x2B, 0x81
]

for p in irreducibles:
    reduced = core._B2I(core._I2B(p)[1:])

    for c in constants:

        sbox = []

        for elem in range(256):
            sbox.append(
                core.affine(core.inverse(elem, reduced), u=0x1F, v=0x63))

        val = analysis.values(sbox)
        out = "Polynomial: %02x, Constant: %02x, NL: %d, DP: %d"
        print(out % (p, c, val[0], val[1]))