Changeset 0612fd in git


Ignore:
Timestamp:
Jul 13, 2018, 11:59:46 AM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
7ddfab7159ae462f7e1d3d1c849fa46af8548999
Parents:
eb1f43df0bb54ca9ba07b328904464a259c147fa
Message:
unified (un)lukely/(UN)LIKELY -> (UN)LIKELY
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/syz4.cc

    reb1f43 r0612fd  
    2525    const int l = L->ncols-1;
    2626    int k;
    27     for (int j = R->N; j > 0; j--) {
    28         if (variables[j-1]) {
    29             for (k = l; k >= 0; k--) {
    30                 if (p_GetExp(L->m[k], j, R) > 0) {
     27    for (int j = R->N; j > 0; j--)
     28    {
     29        if (variables[j-1])
     30        {
     31            for (k = l; k >= 0; k--)
     32            {
     33                if (p_GetExp(L->m[k], j, R) > 0)
     34                {
    3135                    break;
    3236                }
    3337            }
    34             if (k < 0) {   // no break
     38            if (k < 0)
     39            {   // no break
    3540                variables[j-1] = false;
    3641            }
     
    4954    // variables[R->N] is true iff index == 1, that is, for the first step in
    5055    // the resolution
    51     if (unlikely(variables[R->N])) {
     56    if (UNLIKELY(variables[R->N]))
     57    {
    5258        return true;
    5359    }
    54     for (int j = R->N; j > 0; j--) {
    55         if (unlikely(variables[j-1] && p_GetExp(m, j, R) > 0)) {
     60    for (int j = R->N; j > 0; j--)
     61    {
     62        if (UNLIKELY(variables[j-1] && p_GetExp(m, j, R) > 0))
     63        {
    5664            return true;
    5765        }
     
    7886        = (unsigned int *)omAlloc0((L->rank+1)*sizeof(unsigned int));
    7987    unsigned long k = 0;
    80     while (k < n_elems) {
     88    while (k < n_elems)
     89    {
    8190        count[__p_GetComp(L->m[k], R)]++;
    8291        k++;
    8392    }
    84     for (int i = 0; i <= L->rank; i++) {
     93    for (int i = 0; i <= L->rank; i++)
     94    {
    8595        // do ++count[i] and use C[i][0].comp to save count[i]
    8696        C[i] = (lt_struct *)omalloc0((++count[i])*sizeof(lt_struct));
     
    90100    // the order of the elements in each C[i] matters if check_variables() is
    91101    // to be used
    92     while (k > 0) {
     102    while (k > 0)
     103    {
    93104        const poly a = L->m[k-1];
    94105        const unsigned long comp = __p_GetComp(a, R);
     
    112123    const lt_struct *v = hash_previous_module[__p_GetComp(t, r)];
    113124    unsigned long count = v[0].comp;
    114     if (unlikely(count == 1)) {
     125    if (UNLIKELY(count == 1))
     126    {
    115127        return NULL;
    116128    }
     
    119131    p_MemSum_LengthGeneral(q->exp, multiplier->exp, t->exp, r->ExpL_Size);
    120132    const unsigned long q_not_sev = ~p_GetShortExpVector(q, r);
    121     for(unsigned long i = 1; i < count; i++) {
    122         if (likely(v[i].sev & q_not_sev)
    123                 || unlikely(!(_p_LmDivisibleByNoComp(v[i].lt, q, r)))) {
     133    for(unsigned long i = 1; i < count; i++)
     134    {
     135        if (LIKELY(v[i].sev & q_not_sev)
     136                || UNLIKELY(!(_p_LmDivisibleByNoComp(v[i].lt, q, r))))
     137                {
    124138            continue;
    125139        }
     
    155169{
    156170    poly s = find_reducer(multiplier, term, hash_previous_module);
    157     if (s == NULL) {
     171    if (s == NULL)
     172    {
    158173        return NULL;
    159174    }
     
    161176    const int c = __p_GetComp(s, r) - 1;
    162177    poly t;
    163     if (use_cache) {
     178    if (use_cache)
     179    {
    164180        t = traverse_tail(s, c, previous_module, variables,
    165181                hash_previous_module);
     
    181197{
    182198    const poly tail = previous_module->m[comp]->next;
    183     if (unlikely(tail == NULL) || !check_variables(variables, multiplier)) {
     199    if (UNLIKELY(tail == NULL) || !check_variables(variables, multiplier))
     200    {
    184201        return NULL;
    185202    }
    186203    sBucket_pt sum = sBucketCreate(currRing);
    187     for (poly p = tail; p != NULL; p = pNext(p)) {
     204    for (poly p = tail; p != NULL; p = pNext(p))
     205    {
    188206        const poly rt = reduce_term(multiplier, p, previous_module, variables,
    189207                hash_previous_module, use_cache);
     
    221239{
    222240    const ring r = currRing;
    223     for (int i = 0; i < size; i++) {
     241    for (int i = 0; i < size; i++)
     242    {
    224243        cache_term *T = &(Cache[i]);
    225         for (cache_term::iterator itr = T->begin(); itr != T->end(); ++itr) {
     244        for (cache_term::iterator itr = T->begin(); itr != T->end(); ++itr)
     245        {
    226246            p_Delete(&(itr->second), r);
    227247            p_Delete(const_cast<poly*>(&(itr->first)), r);
     
    242262        const poly multiplier)
    243263{
    244     if (likely(itr->second == NULL)) {
     264    if (LIKELY(itr->second == NULL))
     265    {
    245266        return NULL;
    246267    }
    247268    const ring r = currRing;
    248269    poly p = p_Copy(itr->second, r);
    249     if (likely(!n_Equal(pGetCoeff(multiplier), pGetCoeff(itr->first), r))) {
     270    if (LIKELY(!n_Equal(pGetCoeff(multiplier), pGetCoeff(itr->first), r)))
     271    {
    250272        number n = n_Div(pGetCoeff(multiplier), pGetCoeff(itr->first), r);
    251273        p = p_Mult_nn(p, n, r);
     
    261283    cache_term *T = &(Cache[comp]);
    262284    cache_term::const_iterator itr = T->find(multiplier);
    263     if (likely(itr != T->end())) {
     285    if (LIKELY(itr != T->end()))
     286    {
    264287        return get_from_cache_term(itr, multiplier);
    265288    }
     
    283306            hash_previous_module, use_cache);
    284307    poly t2;
    285     if (use_cache) {
     308    if (use_cache)
     309    {
    286310        t2 = traverse_tail(a->next, __p_GetComp(a->next, R)-1,
    287311                previous_module, variables, hash_previous_module);
     
    306330    int i, j;
    307331    int k = id->ncols-1;
    308     for (i = k; i >= 0; i--) {
    309         for (j = k; j > i; j--) {
    310             if (id->m[j] != NULL) {
    311                 if (p_DivisibleBy(id->m[i], id->m[j], r)) {
     332    for (i = k; i >= 0; i--)
     333    {
     334        for (j = k; j > i; j--)
     335        {
     336            if (id->m[j] != NULL)
     337            {
     338                if (p_DivisibleBy(id->m[i], id->m[j], r))
     339                {
    312340                    p_Delete(&id->m[j], r);
    313341                }
    314                 else if (p_DivisibleBy(id->m[j], id->m[i], r)) {
     342                else if (p_DivisibleBy(id->m[j], id->m[i], r))
     343                {
    315344                    p_Delete(&id->m[i], r);
    316345                    break;
     
    334363    pSetCoeff0(head, n_Init(1, r->cf));
    335364    long exp_i, exp_j, lcm;
    336     for (int k = (int)r->N; k > 0; k--) {
     365    for (int k = (int)r->N; k > 0; k--)
     366    {
    337367        exp_i = p_GetExp(f_i, k, r);
    338368        exp_j = p_GetExp(f_j, k, r);
     
    360390                r->cf));
    361391    long exp_i, exp_j, lcm;
    362     for (int k = (int)r->N; k > 0; k--) {
     392    for (int k = (int)r->N; k > 0; k--)
     393    {
    363394        exp_i = p_GetExp(f_i, k, r);
    364395        exp_j = p_GetExp(f_j, k, r);
     
    389420    unsigned long comp = __p_GetComp(G->m[i], r);
    390421    int ncols = 0;
    391     for (int j = i-1; j >= 0; j--) {
     422    for (int j = i-1; j >= 0; j--)
     423    {
    392424        if (__p_GetComp(G->m[j], r) == comp) ncols++;
    393425    }
    394     if (ncols > 0) {
     426    if (ncols > 0)
     427    {
    395428        M_i = idInit(ncols, G->ncols);
    396429        int k = ncols-1;
    397         for (int j = i-1; j >= 0; j--) {
    398             if (__p_GetComp(G->m[j], r) == comp) {
     430        for (int j = i-1; j >= 0; j--)
     431        {
     432            if (__p_GetComp(G->m[j], r) == comp)
     433            {
    399434                M_i->m[k] = syzHead(G, i, j);
    400435                k--;
     
    422457    index++;
    423458    int ncols = i-index;
    424     if (ncols > 0) {
     459    if (ncols > 0)
     460    {
    425461        M_i = idInit(ncols, G->ncols);
    426         for (int j = ncols-1; j >= 0; j--) {
     462        for (int j = ncols-1; j >= 0; j--)
     463        {
    427464            M_i->m[j] = syzHead(G, i, j+index);
    428465        }
     
    439476{
    440477    int ncols = 0;
    441     for (int i = size-1; i >= 0; i--) {
    442         if (M[i] != NULL) {
     478    for (int i = size-1; i >= 0; i--)
     479    {
     480        if (M[i] != NULL)
     481        {
    443482            ncols += M[i]->ncols;
    444483        }
     
    447486    ideal result = idInit(ncols, rank);
    448487    int k = ncols-1;
    449     for (int i = size-1; i >= 0; i--) {
    450         if (M[i] != NULL) {
    451             for (int j = M[i]->ncols-1; j >= 0; j--) {
     488    for (int i = size-1; i >= 0; i--)
     489    {
     490        if (M[i] != NULL)
     491        {
     492            for (int j = M[i]->ncols-1; j >= 0; j--)
     493            {
    452494                result->m[k] = M[i]->m[j];
    453495                k--;
     
    482524    p_GetExpV(p_a, exp_a, r);
    483525    p_GetExpV(p_b, exp_b, r);
    484     for (int i = r->N; i > 0; i--) {
     526    for (int i = r->N; i > 0; i--)
     527    {
    485528        cmp = (exp_a[i] > exp_b[i]) - (exp_a[i] < exp_b[i]);
    486         if (cmp != 0) {
     529        if (cmp != 0)
     530        {
    487531            return cmp;
    488532        }
     
    498542    if ((cmp = compare_comp(p_a, p_b))
    499543            || (cmp = compare_deg(p_a, p_b))
    500             || (cmp = compare_lex(p_a, p_b))) {
     544            || (cmp = compare_lex(p_a, p_b)))
     545            {
    501546        return cmp;
    502547    }
     
    512557{
    513558    ideal *M = (ideal *)omalloc((G->ncols-1)*sizeof(ideal));
    514     for (int i = G->ncols-2; i >= 0; i--) {
     559    for (int i = G->ncols-2; i >= 0; i--)
     560    {
    515561        M[i] = syzM_i(G, i+1, syzHead);
    516562    }
    517563    ideal frame = idConcat(M, G->ncols-1, G->ncols);
    518     for (int i = G->ncols-2; i >= 0; i--) {
    519         if (M[i] != NULL) {
     564    for (int i = G->ncols-2; i >= 0; i--)
     565    {
     566        if (M[i] != NULL)
     567        {
    520568            omFreeSize(M[i]->m, M[i]->ncols*sizeof(poly));
    521569            omFreeBin(M[i], sip_sideal_bin);
     
    533581        const std::vector<bool> &variables, const bool use_cache)
    534582{
    535     if (use_cache) {
     583    if (use_cache)
     584    {
    536585        initialize_cache(res[index-1]->ncols);
    537586    }
     
    539588        = (lt_struct **)omAlloc((res[index-1]->rank+1)*sizeof(lt_struct *));
    540589    initialize_hash(hash_previous_module, res[index-1]);
    541     for (int j = res[index]->ncols-1; j >= 0; j--) {
     590    for (int j = res[index]->ncols-1; j >= 0; j--)
     591    {
    542592        res[index]->m[j]->next->next = lift_ext_LT(res[index]->m[j],
    543593                res[index-1], variables, hash_previous_module, use_cache);
    544594    }
    545     for (int i = 0; i <= res[index-1]->rank; i++) {
     595    for (int i = 0; i <= res[index-1]->rank; i++)
     596    {
    546597        omfree(hash_previous_module[i]);
    547598    }
    548599    omFree(hash_previous_module);
    549     if (use_cache) {
     600    if (use_cache)
     601    {
    550602        delete_cache(res[index-1]->ncols);
    551603    }
     
    559611{
    560612    const ring R = currRing;
    561     for (int j = R->N; j > 0; j--) {
    562         if (!variables[j-1] && p_GetExp(m, j, R) > 0) {
     613    for (int j = R->N; j > 0; j--)
     614    {
     615        if (!variables[j-1] && p_GetExp(m, j, R) > 0)
     616        {
    563617            return true;
    564618        }
     
    574628    const std::vector<bool> &variables)
    575629{
    576     for (int i = 0; i < res[index]->ncols; i++) {
     630    for (int i = 0; i < res[index]->ncols; i++)
     631    {
    577632        poly p_iter = res[index]->m[i]->next;
    578         if (p_iter != NULL) {
    579             while (p_iter->next != NULL) {
    580                 if (contains_unused_variable(p_iter->next, variables)) {
     633        if (p_iter != NULL)
     634        {
     635            while (p_iter->next != NULL)
     636            {
     637                if (contains_unused_variable(p_iter->next, variables))
     638                {
    581639                    pLmDelete(&p_iter->next);
    582640                } else {
     
    591649{
    592650    const ring r = currRing;
    593     for (int i = 0; i < res[index]->ncols; i++) {
    594         if (res[index]->m[i] != NULL) {
     651    for (int i = 0; i < res[index]->ncols; i++)
     652    {
     653        if (res[index]->m[i] != NULL)
     654        {
    595655            p_Delete(&(res[index]->m[i]->next), r);
    596656        }
     
    608668{
    609669    int index = 1;
    610     while (!idIs0(res[index])) {
    611         if (do_lifting) {
     670    while (!idIs0(res[index]))
     671    {
     672        if (do_lifting)
     673        {
    612674            computeLiftings(res, index, variables, use_cache);
    613             if (single_module) {
     675            if (single_module)
     676            {
    614677                delete_tails(res, index-1);
    615678            }
    616679            // we don't know if the input is a reduced SB:
    617             if (index == 1) {
     680            if (index == 1)
     681            {
    618682                variables[currRing->N] = false;
    619683            }
    620684            update_variables(variables, res[index]);
    621             if (use_tensor_trick) {
     685            if (use_tensor_trick)
     686            {
    622687                delete_variables(res, index, variables);
    623688            }
     
    639704        const bool use_tensor_trick)
    640705{
    641     if (idIs0(res[0])) {
     706    if (idIs0(res[0]))
     707    {
    642708        return 1;
    643709    }
    644710    std::vector<bool> variables;
    645711    variables.resize(currRing->N+1, true);
    646     if (do_lifting) {
     712    if (do_lifting)
     713    {
    647714        update_variables(variables, res[0]);
    648         if (use_tensor_trick) {
     715        if (use_tensor_trick)
     716        {
    649717            delete_variables(res, 0, variables);
    650718        }
    651719    }
    652720    int index = 0;
    653     if (max_index > 0) {
     721    if (max_index > 0)
     722    {
    654723        res[1] = computeFrame(res[0], syzM_i_unsorted, syzHead);
    655724        index = computeResolution_iteration(res, max_index, syzHead,
     
    664733        bool *single_module_ptr, const char *method)
    665734{
    666     if (strcmp(method, "complete") == 0) {   // default
     735    if (strcmp(method, "complete") == 0)
     736    {   // default
    667737        *syzHead_ptr = syzHeadExtFrame;
    668738        *do_lifting_ptr = true;
    669739        *single_module_ptr = false;
    670740    }
    671     else if (strcmp(method, "frame") == 0) {
     741    else if (strcmp(method, "frame") == 0)
     742    {
    672743        *syzHead_ptr = syzHeadFrame;
    673744        *do_lifting_ptr = false;
    674745        *single_module_ptr = false;
    675746    }
    676     else if (strcmp(method, "extended frame") == 0) {
     747    else if (strcmp(method, "extended frame") == 0)
     748    {
    677749        *syzHead_ptr = syzHeadExtFrame;
    678750        *do_lifting_ptr = false;
    679751        *single_module_ptr = false;
    680752    }
    681     else if (strcmp(method, "single module") == 0) {
     753    else if (strcmp(method, "single module") == 0)
     754    {
    682755        *syzHead_ptr = syzHeadExtFrame;
    683756        *do_lifting_ptr = true;
     
    720793    poly p, q;
    721794    int index = (single_module ? length-1 : 1);
    722     while (index < length && !idIs0(res[index])) {
    723         for (int j = res[index]->ncols-1; j >= 0; j--) {
     795    while (index < length && !idIs0(res[index]))
     796    {
     797        for (int j = res[index]->ncols-1; j >= 0; j--)
     798        {
    724799            insert_first_term(res[index]->m[j]->next, p, q, R);
    725800            insert_first_term(res[index]->m[j], p, q, R);
     
    751826    syStrategy result = (syStrategy)omAlloc0(sizeof(ssyStrategy));
    752827    resolvente res = (resolvente)omAlloc0((length+1)*sizeof(ideal));
    753     if (strcmp(method, "frame") != 0) {
     828    if (strcmp(method, "frame") != 0)
     829    {
    754830        res[0] = id_Copy(arg, currRing);
    755     } else {
     831    }
     832    else
     833    {
    756834        res[0] = id_Head(arg, currRing);
    757835    }
     
    762840    int new_length = computeResolution(res, length-1, syzHead, do_lifting,
    763841            single_module, use_cache, use_tensor_trick);
    764     if (new_length < length) {
     842    if (new_length < length)
     843    {
    765844        res = (resolvente)omReallocSize(res, (length+1)*sizeof(ideal),
    766845                (new_length+1)*sizeof(ideal));
    767846    }
    768     if (strcmp(method, "frame") != 0) {
     847    if (strcmp(method, "frame") != 0)
     848    {
    769849        insert_ext_induced_LTs(res, new_length, single_module);
    770850    }
  • libpolys/misc/auxiliary.h

    reb1f43 r0612fd  
    412412
    413413#ifdef __GNUC__
    414 #define likely(X)   (__builtin_expect(!!(X), 1))
    415 #define unlikely(X) (__builtin_expect(!!(X), 0))
    416 #else
    417 #define likely(X)   (X)
    418 #define unlikely(X) (X)
    419 #endif
    420 
    421 #define LIKELY   likely
    422 #define UNLIKELY unlikely
    423 
     414#define LIKELY(X)   (__builtin_expect(!!(X), 1))
     415#define UNLIKELY(X) (__builtin_expect(!!(X), 0))
     416#else
     417#define LIKELY(X)   (X)
     418#define UNLIKELY(X) (X)
     419#endif
    424420
    425421#endif
Note: See TracChangeset for help on using the changeset viewer.