Changeset 7b4bfe6 in git for factory/fac_util.cc


Ignore:
Timestamp:
Jul 8, 1996, 10:22:02 AM (28 years ago)
Author:
Rüdiger Stobbe <stobbe@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
db4770670387300daebce8262e6dddb3e3ba4b7f
Parents:
f63dbca24fdad0fc65e8496a781d6830dafded8e
Message:
"New organization of the factorization stuff. Some functions moved from
fac_diophand.cc which no longer exists.
"


git-svn-id: file:///usr/local/Singular/svn/trunk@40 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/fac_util.cc

    rf63dbca r7b4bfe6  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fac_util.cc,v 1.1 1996-06-27 11:34:24 stobbe Exp $
     2// $Id: fac_util.cc,v 1.2 1996-07-08 08:22:02 stobbe Exp $
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.1  1996/06/27 11:34:24  stobbe
     7"New function dviremainder.
     8"
     9
    610Revision 1.0  1996/05/17 10:59:46  stobbe
    711Initial revision
     
    1115#include "assert.h"
    1216#include "cf_defs.h"
     17#include "canonicalform.h"
     18#include "cf_iter.h"
    1319#include "fac_util.h"
    1420
     
    144150
    145151CanonicalForm
     152maxCoeff( const CanonicalForm & f )
     153{
     154    if ( f.inCoeffDomain() )
     155        return abs( f );
     156    else {
     157        CanonicalForm M = 0, m;
     158        for ( CFIterator i = f; i.hasTerms(); i++ )
     159            if ( (m = maxCoeff( i.coeff() )) > M )
     160                M = m;
     161        return M;
     162    }
     163}
     164
     165
     166CanonicalForm
    146167mappksymmetric ( const CanonicalForm & f )
    147168{
     
    158179    return mod( f, PK );
    159180}
     181
     182void
     183extgcd ( const CanonicalForm & a, const CanonicalForm & b, CanonicalForm & S, CanonicalForm & T, const modpk & pk )
     184{
     185    int p = pk.getp(), k = pk.getk(), j;
     186    CanonicalForm amodp, bmodp, smodp, tmodp, s, t, sigma, tau, e;
     187    CanonicalForm modulus = p, sigmat, taut, q;
     188
     189    setCharacteristic( p );
     190    {
     191        amodp = mapinto( a ); bmodp = mapinto( b );
     192        (void)extgcd( amodp, bmodp, smodp, tmodp );
     193    }
     194    setCharacteristic( 0 );
     195    s = mapinto( smodp ); t = mapinto( tmodp );
     196
     197    for ( j = 1; j < k; j++ ) {
     198        e = ( 1 - s * a - t * b ) / modulus;
     199        setCharacteristic( p );
     200        {
     201            e = mapinto( e );
     202            sigmat = smodp * e;
     203            taut = tmodp * e;
     204            divrem( sigmat, bmodp, q, sigma );
     205            tau = taut + q * amodp;
     206        }
     207        setCharacteristic( 0 );
     208        s += mapinto( sigma ) * modulus;
     209        t += mapinto( tau ) * modulus;
     210        modulus *= p;
     211    }
     212    S = s; T = t;
     213}
     214
Note: See TracChangeset for help on using the changeset viewer.