Changeset e28e6d in git for factory


Ignore:
Timestamp:
Jul 6, 2011, 10:31:05 AM (13 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '6e5adcba05493683b94648c659a729c189812c77')
Children:
ec970ef2b3d7d5253124f91a7c731ac3c7c540c3
Parents:
276c3f35a3633a214a6c43c7426a9f3e9609bd35
Message:
towards better arithmetic in Z_p[x]/(f) for reducible f 


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

Legend:

Unmodified
Added
Removed
  • factory/canonicalform.cc

    r276c3f re28e6d  
    791791}
    792792
     793//same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible
     794CanonicalForm &
     795CanonicalForm::tryDiv ( const CanonicalForm & cf, const CanonicalForm& M, bool& fail )
     796{
     797    ASSERT (getCharacteristic() > 0, "expected positive characteristic");
     798    ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
     799    fail= false;
     800    int what = is_imm( value );
     801    if ( what ) {
     802        ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
     803        if ( (what = is_imm( cf.value )) == FFMARK )
     804            value = imm_div_p( value, cf.value );
     805        else  if ( what == GFMARK )
     806            value = imm_div_gf( value, cf.value );
     807        else {
     808            InternalCF * dummy = cf.value->copyObject();
     809            value = dummy->divcoeff( value, true );
     810        }
     811    }
     812    else  if ( is_imm( cf.value ) )
     813        value = value->tryDivcoeff (cf.value, false, M, fail);
     814    else  if ( value->level() == cf.value->level() ) {
     815        if ( value->levelcoeff() == cf.value->levelcoeff() )
     816            value = value->tryDivsame( cf.value, M, fail );
     817        else  if ( value->levelcoeff() > cf.value->levelcoeff() )
     818            value = value->tryDivcoeff( cf.value, false, M, fail );
     819        else {
     820            InternalCF * dummy = cf.value->copyObject();
     821            dummy = dummy->tryDivcoeff( value, true, M, fail );
     822            if ( value->deleteObject() ) delete value;
     823            value = dummy;
     824        }
     825    }
     826    else  if ( level() > cf.level() )
     827        value = value->tryDivcoeff( cf.value, false, M, fail );
     828    else {
     829        InternalCF * dummy = cf.value->copyObject();
     830        dummy = dummy->tryDivcoeff( value, true, M, fail );
     831        if ( value->deleteObject() ) delete value;
     832        value = dummy;
     833    }
     834    return *this;
     835}
     836
    793837CanonicalForm &
    794838CanonicalForm::operator %= ( const CanonicalForm & cf )
     
    949993    return result;
    950994}
     995
     996//same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible
     997bool
     998tryDivremt ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const CanonicalForm& M, bool& fail )
     999{
     1000    ASSERT (getCharacteristic() > 0, "expected positive characteristic");
     1001    ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
     1002    fail= false;
     1003    InternalCF * qq = 0, * rr = 0;
     1004    int what = is_imm( f.value );
     1005    bool result = true;
     1006    if ( what )
     1007        if ( is_imm( g.value ) ) {
     1008            if ( what == FFMARK )
     1009                imm_divrem_p( f.value, g.value, qq, rr );
     1010            else  if ( what == GFMARK )
     1011                imm_divrem_gf( f.value, g.value, qq, rr );
     1012        }
     1013        else
     1014            result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
     1015    else  if ( (what=is_imm( g.value )) )
     1016        result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
     1017    else  if ( f.value->level() == g.value->level() )
     1018        if ( f.value->levelcoeff() == g.value->levelcoeff() )
     1019            result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
     1020        else  if ( f.value->levelcoeff() > g.value->levelcoeff() )
     1021            result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
     1022        else
     1023            result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
     1024    else  if ( f.value->level() > g.value->level() )
     1025        result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
     1026    else
     1027        result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
     1028    if (fail)
     1029    {
     1030      q= 0;
     1031      r= 0;
     1032      return false;
     1033    }
     1034    if ( result ) {
     1035        ASSERT( qq != 0 && rr != 0, "error in divrem" );
     1036        q = CanonicalForm( qq );
     1037        r = CanonicalForm( rr );
     1038        q= reduce (q, M);
     1039        r= reduce (r, M);
     1040    }
     1041    else {
     1042        q = 0; r = 0;
     1043    }
     1044    return result;
     1045}
     1046
    9511047//}}}
    9521048
  • factory/canonicalform.h

    r276c3f re28e6d  
    131131    CanonicalForm& operator %= ( const CanonicalForm& );
    132132    CanonicalForm& div ( const CanonicalForm& );
     133    CanonicalForm& tryDiv (const CanonicalForm&, const CanonicalForm&, bool& );
    133134    CanonicalForm& mod ( const CanonicalForm& );
    134135
     
    157158    friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
    158159    friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
     160    friend bool tryDivremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm&, const CanonicalForm&, bool& );
    159161
    160162    friend CanonicalForm bgcd ( const CanonicalForm &, const CanonicalForm & );
  • factory/int_cf.cc

    r276c3f re28e6d  
    173173    return 0;
    174174}
     175
     176InternalCF*
     177InternalCF::tryMulsame( InternalCF* F, const CanonicalForm& M)
     178{
     179    ASSERT1( 0, "tryMulsame() not implemented for class %s", this->classname() );
     180    return 0;
     181}
     182
     183InternalCF*
     184InternalCF::tryInvert ( const CanonicalForm& M, bool& fail)
     185{
     186    ASSERT1( 0, "tryInvert() not implemented for class %s", this->classname() );
     187    return 0;
     188}
     189
     190bool
     191InternalCF::tryDivremsamet ( InternalCF* F, InternalCF*& S, InternalCF*& T, const CanonicalForm& M, bool& fail)
     192{
     193    ASSERT1( 0, "tryDivremsamet() not implemented for class %s", this->classname() );
     194    return 0;
     195}
     196
     197bool
     198InternalCF::tryDivremcoefft ( InternalCF* F, InternalCF*& S, InternalCF*& T, bool invert, const CanonicalForm& M, bool& fail)
     199{
     200    ASSERT1( 0, "tryDivremcoefft() not implemented for class %s", this->classname() );
     201    return 0;
     202}
     203
     204InternalCF*
     205InternalCF::tryDivsame ( InternalCF* F, const CanonicalForm& M, bool& fail)
     206{
     207    ASSERT1( 0, "tryDivsame() not implemented for class %s", this->classname() );
     208    return 0;
     209}
     210
     211InternalCF*
     212InternalCF::tryDivcoeff ( InternalCF* F, bool invert, const CanonicalForm& M, bool& fail)
     213{
     214    ASSERT1( 0, "tryDivcoeff() not implemented for class %s", this->classname() );
     215    return 0;
     216}
     217
     218InternalCF*
     219InternalCF::tryDividecoeff ( InternalCF* F, bool invert, const CanonicalForm& M, bool& fail)
     220{
     221    ASSERT1( 0, "tryDividecoeff() not implemented for class %s", this->classname() );
     222    return 0;
     223}
  • factory/int_cf.h

    r276c3f re28e6d  
    6868    virtual InternalCF* neg() PVIRT_INTCF("neg");
    6969    virtual InternalCF* invert(); // semantically const, changes refCount
     70    virtual InternalCF* tryInvert( const CanonicalForm&, bool& );
    7071    virtual int comparesame ( InternalCF * ) PVIRT_INT("comparesame");
    7172    virtual int comparecoeff ( InternalCF * ) PVIRT_INT("comparecoeff");
     
    7475    virtual InternalCF* subsame( InternalCF* ) PVIRT_INTCF("subsame");
    7576    virtual InternalCF* mulsame( InternalCF* ) PVIRT_INTCF("mulsame");
     77    virtual InternalCF* tryMulsame( InternalCF*, const CanonicalForm& );
    7678    virtual InternalCF* dividesame( InternalCF* ) PVIRT_INTCF("dividesame");
    7779    virtual InternalCF* modulosame( InternalCF* ) PVIRT_INTCF("modulosame");
    7880    virtual InternalCF* divsame( InternalCF* ) PVIRT_INTCF("divsame");
     81    virtual InternalCF* tryDivsame ( InternalCF* , const CanonicalForm&, bool& );
    7982    virtual InternalCF* modsame( InternalCF* ) PVIRT_INTCF("modsame");
    8083    virtual void divremsame( InternalCF*, InternalCF*&, InternalCF*& ) PVIRT_VOID("divremsame");
    8184    virtual bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& ) PVIRT_BOOL("divremsamet");
     85    virtual bool tryDivremsamet ( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& );
    8286
    8387    virtual InternalCF* addcoeff( InternalCF* ) PVIRT_INTCF("addcoeff");
     
    8589    virtual InternalCF* mulcoeff( InternalCF* ) PVIRT_INTCF("mulcoeff");
    8690    virtual InternalCF* dividecoeff( InternalCF*, bool ) PVIRT_INTCF("dividecoeff");
     91    virtual InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
    8792    virtual InternalCF* modulocoeff( InternalCF*, bool ) PVIRT_INTCF("dividecoeff");
    8893    virtual InternalCF* divcoeff( InternalCF*, bool ) PVIRT_INTCF("divcoeff");
     94    virtual InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
    8995    virtual InternalCF* modcoeff( InternalCF*, bool ) PVIRT_INTCF("modcoeff");
    9096    virtual void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool ) PVIRT_VOID("divremcoeff");
    9197    virtual bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool ) PVIRT_BOOL("divremcoefft");
     98    virtual bool tryDivremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& );
    9299
    93100    virtual InternalCF * bgcdsame ( const InternalCF * const ) const;
Note: See TracChangeset for help on using the changeset viewer.