def toC(module, algebra_type):
    module.generate_milnor_action()
    max_degree = max(module.gens.values()) + 1
    module.c_algebra = cAlgebra.getAlgebra(algebra_type,
                                           p=module.milnor_algebra.p,
                                           max_degree=max_degree)
    number_of_basis_elements_in_degree = [0] * max_degree
    basis_element_indices = {}
    index_to_basis_element = {}
    for (b, degree) in module.gens.items():
        index = number_of_basis_elements_in_degree[degree]
        number_of_basis_elements_in_degree[degree] += 1
        basis_element_indices[b] = index
        index_to_basis_element[(degree, index)] = b
    c_list_of_uints_type = max_degree * c_uint
    c_number_of_basis_elements_in_degree = c_list_of_uints_type(
        *number_of_basis_elements_in_degree)

    module.c_algebra.generateBasis(max_degree)
    c_module = CSteenrod.FiniteDimensionalModule_construct(
        module.c_algebra.c_alg_ptr, 0, max_degree,
        c_number_of_basis_elements_in_degree)
    module.c_module = c_module
    module.basis_element_indices = basis_element_indices
    module.index_to_basis_element = index_to_basis_element
    module.number_of_basis_elements_in_degree = number_of_basis_elements_in_degree
    for ((op, input), output) in module.milnor_actions.items():
        input_degree = module.gens[input]
        input_index = basis_element_indices[input]
        output_degree = output.degree()
        output_vector = [None
                         ] * number_of_basis_elements_in_degree[output_degree]
        op_degree = output_degree - input_degree
        op_index = cMilnorBasisElement.toIndex(module.c_algebra, op)
        for (b, coeff) in output.items():
            output_vector[basis_element_indices[b]] = coeff
        c_vector = cFpVector.cVector(module.p, vector=output_vector)
        CSteenrod.FiniteDimensionalModule_setAction(c_module, op_degree,
                                                    op_index, input_degree,
                                                    input_index, c_vector)
        c_vector.free()
    return c_module
Beispiel #2
0
def act(module, op, element):
    c_module = module.c_module
    c_module_cast = cast(c_module, POINTER(c_Module))
    op_deg = op.degree()
    elt_deg = element.degree()
    output_degree = elt_deg + op_deg
    output_dimension = CSteenrod.FreeModule_getDimension(c_module_cast, output_degree)
    c_result = cFpVector.cVector(module.p, output_dimension)
    CSteenrod.FreeModule_ConstructBlockOffsetTable(c_module, elt_deg)
    CSteenrod.FreeModule_ConstructBlockOffsetTable(c_module, output_degree)
    for (op_basis_elt, c1) in op.items():
        op_idx = module.algebra.basis_type.toIndex(module.c_algebra, op_basis_elt)
        for ((elt_op, gen), c2) in element.items():
            elt_op_deg = elt_op.degree()
            elt_op = next(iter(elt_op))
            elt_op_idx = module.algebra.basis_type.toIndex(module.c_algebra, elt_op)
            gen_deg = module.gens[gen]
            gen_idx = module.generator_indices[gen]
            elt_idx = CSteenrod.FreeModule_operationGeneratorToIndex(c_module, elt_op_deg, elt_op_idx, gen_deg, gen_idx)
            CSteenrod.FreeModule_actOnBasis(c_module_cast, c_result.vector, c1*c2, op_deg, op_idx, elt_deg, elt_idx)    
    result = free_module_elt_from_c(module, output_degree, c_result)
    c_result.free()
    return result
def act(module, op, gen):
    c_module = module.c_module
    gen_deg = gen.degree()
    gen_idx = module.basis_element_indices[gen]
    op_deg = op.degree()
    output_degree = op_deg + gen_deg
    if (output_degree > len(module.number_of_basis_elements_in_degree)):
        return 0
    output_dimension = module.number_of_basis_elements_in_degree[output_degree]
    c_result = cFpVector.cVector(module.p, output_dimension)
    for (op_basis_elt, c) in op.items():
        op_idx = cmilnor.milnor_basis_elt_to_C_index(module.milnor_algebra,
                                                     op_basis_elt)
        CSteenrod.FiniteDimensionalModule_actOnBasis(
            cast(c_module, POINTER(c_Module)), c_result.vector, c, op_deg,
            op_idx, gen_deg, gen_idx)
    result = c_result.unpack()
    c_result.free()
    result = {
        module.index_to_basis_element[(output_degree, i)]: c
        for i, c in enumerate(result) if c != 0
    }
    result = module.get_element(result)
    return result
Beispiel #4
0
 def apply(f, element):
     degree = element.degree()
     c_source = f.source.c_module
     c_target_cast = cast(f.target.c_module, POINTER(c_Module))
     output_dimension = CSteenrod.FreeModule_getDimension(
         c_target_cast, degree)
     c_result = cFpVector.cVector(f.source.p, output_dimension)
     for ((elt_op, gen), coeff) in element.items():
         elt_op_deg = elt_op.degree()
         elt_op = next(iter(elt_op))
         elt_op_idx = f.source.c_algebra.idxFromPy(elt_op)
         gen_deg = f.source.gens[gen]
         gen_idx = f.source.generator_indices[gen]
         # print(elt_op_deg, elt_op_idx, gen_deg, gen_idx)
         elt_idx = CSteenrod.FreeModule_operationGeneratorToIndex(
             f.source.c_module, elt_op_deg, elt_op_idx, gen_deg, gen_idx)
         # print(elt_op, gen)
         # print("degree: ", degree, "idx: ", elt_idx)
         CSteenrod.FreeModuleHomomorphism_applyToBasisElement(
             f.cf, c_result.vector, coeff, degree, elt_idx)
         # print(free_module_elt_from_c(f.target, degree, c_result))
     result = cFreeModule.elementFromC(f.target, degree, c_result.vector)
     c_result.free()
     return result
Beispiel #5
0
def elementFromC(module, degree, c_elt):
    result_array = cFpVector.cVector(module.p, vector=c_elt).unpack()
    return elementFromArray(module, degree, result_array)