Changeset 42281d6 in git


Ignore:
Timestamp:
Jul 6, 2011, 7:04:52 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
13f4949d39b811d9e4ba8e8cbff2c4565ce87187
Parents:
ec970ef2b3d7d5253124f91a7c731ac3c7c540c3
Message:
divisibility test


git-svn-id: file:///usr/local/Singular/svn/trunk@14328 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_algorithm.cc

    rec970e r42281d6  
    3030#include "cf_iter.h"
    3131#include "templates/ftmpl_functions.h"
     32#include "algext.h"
    3233
    3334void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
     
    385386//}}}
    386387
     388/// same as fdivides but handles zero divisors in Z_p[t]/(f)[x1,...,xn] for reducible f
     389bool
     390tryFdivides ( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm& M, bool& fail )
     391{
     392    fail= false;
     393    // trivial cases
     394    if ( g.isZero() )
     395        return true;
     396    else if ( f.isZero() )
     397        return false;
     398
     399    if (f.inCoeffDomain() || g.inCoeffDomain())
     400    {
     401        // if we are in a field all elements not equal to zero are units
     402        if ( f.inCoeffDomain() )
     403        {
     404            CanonicalForm inv;
     405            tryInvert (f, M, inv, fail);
     406            return !fail;
     407        }
     408        else
     409        {
     410            return false;
     411        }
     412    }
     413
     414    // we may assume now that both levels either equal LEVELBASE
     415    // or are greater zero
     416    int fLevel = f.level();
     417    int gLevel = g.level();
     418    if ( (gLevel > 0) && (fLevel == gLevel) )
     419    {
     420        if (degree( f ) > degree( g ))
     421          return false;
     422        bool dividestail= tryFdivides (f.tailcoeff(), g.tailcoeff(), M, fail);
     423
     424        if (fail || !dividestail)
     425          return false;
     426        bool dividesLC= tryFdivides (f.LC(),g.LC(), M, fail);
     427        if (fail || !dividesLC)
     428          return false;
     429        CanonicalForm q,r;
     430        bool divides= tryDivremt (g, f, q, r, M, fail);
     431        if (fail || !divides)
     432          return false;
     433        return r.isZero();
     434    }
     435    else if ( gLevel < fLevel )
     436    {
     437        // g is a coefficient w.r.t. f
     438        return false;
     439    }
     440    else
     441    {
     442        // either f is a coefficient w.r.t. polynomial g or both
     443        // f and g are from a base domain (should be Z or Z/p^n,
     444        // then)
     445        CanonicalForm q, r;
     446        bool divides= tryDivremt (g, f, q, r, M, fail);
     447        if (fail || !divides)
     448          return false;
     449        return r.isZero();
     450    }
     451}
     452
    387453//{{{ CanonicalForm maxNorm ( const CanonicalForm & f )
    388454//{{{ docu
  • factory/cf_algorithm.h

    rec970e r42281d6  
    4141
    4242bool fdivides ( const CanonicalForm & f, const CanonicalForm & g );
     43
     44bool tryFdivides ( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm& M, bool& fail );
    4345
    4446CanonicalForm maxNorm ( const CanonicalForm & f );
Note: See TracChangeset for help on using the changeset viewer.