Changeset a88bbe in git for Singular/LIB/modular.lib


Ignore:
Timestamp:
Sep 7, 2016, 2:21:41 PM (7 years ago)
Author:
Andreas Steenpass <steenpass@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
5600a4f5be2705b151d6d42fac572d137ff0924b
Parents:
af7c4768f3e8796ec97be6a476aa97989adfb24b
Message:
chg: make chinrem() and farey() work for lists in modular.lib
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/modular.lib

    raf7c47 ra88bbe  
    171171        // lift result
    172172        if (N == 1) {
    173             result_lift = chinrem(modresults, primes);
     173            result_lift = chinrem_recursive(modresults, primes);
    174174        }
    175175        else {
    176             result_lift = chinrem(list(result_lift)+modresults,
     176            result_lift = chinrem_recursive(list(result_lift)+modresults,
    177177                list(N)+primes);
    178178        }
     
    218218    ideal I = x9y2+x10, x2y7-y8;
    219219    modular("std", list(I));
     220}
     221
     222static proc chinrem_recursive(list modresults, list moduli)
     223{
     224    if (typeof(modresults[1]) != "list") {
     225        return(chinrem(modresults, moduli));
     226    }
     227    // if typeof(modresults[1]) == "list", then we assume
     228    // size(modresults[1]) == size(modresults[k])
     229    // for k = 2, ..., size(modresults)
     230    int n_sublists = size(modresults[1]);
     231    int i, j;
     232    list modresults_sublists;
     233    for (j = n_sublists; j > 0; j--) {
     234        modresults_sublists[j] = list();
     235        for (i = size(modresults); i > 0; i--) {
     236            modresults_sublists[j][i] = modresults[i][j];
     237        }
     238        task t(j) = "Modular::chinrem_recursive",
     239            list(modresults_sublists[j], moduli);
     240    }
     241    startTasks(t(1..n_sublists));
     242    waitAllTasks(t(1..n_sublists));
     243    list result;
     244    for (j = n_sublists; j > 0; j--) {
     245        result[j] = getResult(t(j));
     246        killTask(t(j));
     247    }
     248    return(result);
    220249}
    221250
     
    297326{
    298327    arg_type = typeof(farey_arg);
    299     if (arg_type != "bigint" && arg_type != "ideal"
    300         && arg_type != "module" && arg_type != "matrix") {
     328    if (arg_type != "bigint" && arg_type != "ideal" && arg_type != "module"
     329        && arg_type != "matrix" && arg_type != "list") {
    301330        ERROR("wrong input type");
     331    }
     332    int i;
     333    if (arg_type == "list") {
     334        int size_farey_arg = size(farey_arg);
     335        for (i = size_farey_arg; i > 0; i--) {
     336            task t(i) = "Modular::farey_parallel", list(farey_arg[i], farey_N);
     337        }
     338        startTasks(t(1..size_farey_arg));
     339        waitAllTasks(t(1..size_farey_arg));
     340        list result;
     341        for (i = size_farey_arg; i > 0; i--) {
     342            result[i] = getResult(t(i));
     343            killTask(t(i));
     344        }
     345        return(result);
    302346    }
    303347    if (arg_type == "bigint" || arg_type == "matrix") {
     
    309353    int chunks = par_range(size_arg);
    310354    intvec range;
    311     int i;
    312355    for (i = chunks; i > 0; i--) {
    313356        range = par_range(size_arg, i);
Note: See TracChangeset for help on using the changeset viewer.