Changeset e4eea0e in git


Ignore:
Timestamp:
Jul 19, 1997, 10:09:28 AM (27 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
66e0d201fa56526ea7c5fe49c469ed956b42d2db
Parents:
fb8518fe473cb4484cb222f067d3ccdaf909d892
Message:
	* cf_ops.cc (resultant): assertion added
	(resultant): new variable flipFactor
	(resultant): handling of trivial cases fixed
	(resultant): some other minor bug fixes

	* cf_ops.cc (resultant): doc fix


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

Legend:

Unmodified
Added
Removed
  • factory/cf_ops.cc

    rfb8518f re4eea0e  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_ops.cc,v 1.2 1997-06-19 12:24:13 schmidt Exp $ */
     2/* $Id: cf_ops.cc,v 1.3 1997-07-19 08:09:28 schmidt Exp $ */
    33
    44#include <config.h>
     
    203203}
    204204
    205 CanonicalForm
    206 resultant( const CanonicalForm & f, const CanonicalForm& g, const Variable & x )
     205//{{{ CanonicalForm resultant( const CanonicalForm & f, const CanonicalForm & g, const Variable & x )
     206//{{{ docu
     207//
     208// resultant() - return resultant of f and g with respect to x.
     209//
     210// We calculate the resultant using a subresultant PSR.
     211//
     212// flipFactor: Res(f, g) = flipFactor * Res(g, f)
     213// F, G: f and g with x as main variable
     214// pi, pi1, pi2: used to compute PSR
     215// delta:
     216// bi, Hi:
     217//
     218//}}}
     219CanonicalForm
     220resultant( const CanonicalForm & f, const CanonicalForm & g, const Variable & x )
    207221{
    208222    CanonicalForm Hi, bi, pi, pi1, pi2, F, G;
    209     int delta;
    210     Variable v = f.mvar();
    211 
    212     if ( f.mvar() < x || g.mvar() < x )
    213         return 1;
    214 
     223    int delta, flipFactor;
     224    Variable v;
     225
     226    ASSERT( x.level() > 0, "cannot calculate resultant in respect to algebraic variables" );
     227
     228    // some checks on triviality.  We will not use degree( v )
     229    // here because this may involve variable swapping.
     230    if ( f.isZero() || g.isZero() )
     231        return 0;
     232    if ( f.mvar() < x )
     233        return power( f, g.degree( x ) );
     234    if ( g.mvar() < x )
     235        return power( g, f.degree( x ) );
     236
     237    // make x main variale
    215238    if ( f.mvar() > x || g.mvar() > x ) {
    216239        if ( f.mvar() > g.mvar() )
     
    226249        G = g;
    227250    }
    228     if ( F.degree( v ) < 1 || G.degree( v ) < 1 )
    229         return 1;
    230 
    231     if ( f.degree( v ) >= g.degree( v ) ) {
     251    // at this point, we have to calculate resultant( F, G, v )
     252    // where v is equal to or greater than the main variables
     253    // of F and G
     254
     255    // trivial case: F or G in R.  Swapping will not occur
     256    // when calling degree( v ).
     257    if ( F.degree( v ) < 1 )
     258        return power( f, G.degree( v ) );
     259    if ( G.degree( v ) < 1 )
     260        return power( g, F.degree( v ) );
     261
     262    // start the pseudo remainder sequence
     263    if ( F.degree( v ) >= G.degree( v ) ) {
    232264        pi = F; pi1 = G;
    233     }
    234     else {
     265        flipFactor = 1;
     266    }
     267    else {
     268        if ( (F.degree( v ) * G.degree( v )) % 2 )
     269            flipFactor = -1;
     270        else
     271            flipFactor = 1;
    235272        pi = G; pi1 = F;
    236273    }
     274
    237275    delta = degree( pi, v ) - degree( pi1, v );
    238276    Hi = power( LC( pi1, v ), delta );
     277
     278    // Ist hier nicht if und else zweig vertauscht ???
    239279    if ( (delta+1) % 2 )
    240280        bi = 1;
    241281    else
    242282        bi = -1;
     283
     284    // Ist pi1.isZero vielleich schneller ???
    243285    while ( degree( pi1, v ) >= 0 ) {
    244286        pi2 = psr( pi, pi1, v );
     
    247289        if ( degree( pi1, v ) >= 0 ) {
    248290            delta = degree( pi, v ) - degree( pi1, v );
     291
     292            // Ist hier nicht if und else zweig vertauscht ???
    249293            if ( (delta+1) % 2 )
    250294                bi = LC( pi, v ) * power( Hi, delta );
    251295            else
    252296                bi = -LC( pi, v ) * power( Hi, delta );
     297
     298            // Was ist f"ur delta == 0 ???
    253299            Hi = power( LC( pi1, v ), delta ) / power( Hi, delta-1 );
    254300        }
    255301    }
     302
     303    // f and g have non-trivial common divisor
     304    // if ( degree( pi, v ) > 0 )
     305    // return 0;
     306
     307    // undo variable swap
    256308    if ( v == x )
    257         return Hi;
    258     else
    259         return swapvar( Hi, v, x );
    260 }
    261 
     309        // Gibt man hier nicht den letzten Rest der PSR zur"uck
     310        // und nicht den Korrekturterm Hi ???
     311        return Hi * flipFactor;
     312    else
     313        return swapvar( Hi, v, x ) * flipFactor;
     314}
     315//}}}
    262316
    263317static CanonicalForm
Note: See TracChangeset for help on using the changeset viewer.