Example #1
0
def FiniteDirectSum(*rings):
    '''
        Given rings R1, R2, ..., represents
        the set R1 (+) R2 (+) ...
    '''
    mulXY = lambda x, y : tuple([rings[i].multiply(x[i], y[i]) for i in range(len(rings))])
    add_group = gFiniteDirectSum(*[ring.get_additive_group() for ring in rings])
    mult_op = OperationFactory.create_operation(mulXY, add_group)
    return FiniteRingFactory.create_ring(add_group, mult_op)
Example #2
0
def Zn(n):
    multXY = lambda x, y : (x * y) % n
    mult_op = OperationFactory.create_operation(multXY, gZn(n))
    return FiniteRingFactory.create_ring(gZn(n), mult_op)