Changeset df83c0 in git


Ignore:
Timestamp:
Nov 24, 1999, 1:29:38 PM (24 years ago)
Author:
Tim Wichmann <wichmann@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
015eaa982b5452b61c7e2510ba7ecfcfc9606d1a
Parents:
d47e6fd256e2e97a44cc9bae4b289a40732b3e98
Message:
* added fglmquot


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

Legend:

Unmodified
Added
Removed
  • Singular/fglm.cc

    rd47e6f rdf83c0  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fglm.cc,v 1.19 1999-11-15 17:19:59 obachman Exp $
     2// $Id: fglm.cc,v 1.20 1999-11-24 12:29:38 wichmann Exp $
    33
    44/****************************************
     
    4141    FglmNotReduced,
    4242    FglmNotZeroDim,
    43     FglmIncompatibleRings
     43    FglmIncompatibleRings,
     44    // for fglmquot:
     45    FglmPolyIsOne,
     46    FglmPolyIsZero
    4447};
    4548
     
    321324}
    322325
     326// fglmQuotProc: Calculate I:f with FGLM methods.
     327// Checks the input-data, and calls fglmquot (see fglmzero.cc).
     328// Returns the new groebnerbasis if I:f or 0 if an error occoured.
     329BOOLEAN
     330fglmQuotProc( leftv result, leftv first, leftv second )
     331{
     332    FglmState state = FglmOk;
     333
     334    //    STICKYPROT("quotstart\n");
     335    ideal sourceIdeal = IDIDEAL( (idhdl)first->data );
     336    poly quot = (poly)second->Data();
     337    ideal destIdeal = NULL;
     338
     339    state = fglmIdealcheck( sourceIdeal );
     340    if ( state == FglmOk ) {
     341      if ( quot == NULL ) state= FglmPolyIsZero;
     342      else if ( pIsConstant( quot ) ) state= FglmPolyIsOne;
     343    }
     344   
     345    if ( state == FglmOk ) {
     346      assumeStdFlag( first );
     347      if ( fglmquot( sourceIdeal, quot, destIdeal ) == FALSE )
     348        state= FglmNotReduced;
     349    }
     350
     351    switch (state) {
     352        case FglmOk:
     353            break;
     354        case FglmHasOne:
     355            destIdeal= idInit(1,1);
     356            (destIdeal->m)[0]= pOne();
     357            state= FglmOk;
     358            break;
     359        case FglmNotZeroDim:
     360            Werror( "The ideal %s has to be 0-dimensional", first->Name() );
     361            destIdeal= idInit(0,0);
     362            break;
     363        case FglmNotReduced:
     364            Werror( "The poly %s has to be reduced", second->Name() );
     365            destIdeal= idInit(0,0);
     366            break;
     367        case FglmPolyIsOne:
     368            int k;
     369            destIdeal= idInit( IDELEMS(sourceIdeal), 1 );
     370            for ( k= IDELEMS( sourceIdeal )-1; k >=0; k-- )
     371              (destIdeal->m)[k]= pCopy( (sourceIdeal->m)[k] );
     372            state= FglmOk;
     373            break;
     374        case FglmPolyIsZero:
     375            destIdeal= idInit(1,1);
     376            (destIdeal->m)[0]= pOne();
     377            state= FglmOk;
     378            break;
     379        default:
     380            destIdeal= idInit(1,1);
     381    }
     382
     383    result->rtyp = IDEAL_CMD;
     384    result->data= (void *)destIdeal;
     385    setFlag( result, FLAG_STD );
     386    // STICKYPROT("quotend\n");
     387    return (state != FglmOk);
     388} // fglmQuotProt
     389
    323390// The main function for finduni().
    324391// Checks the input-data, and calls FindUnivariateWrapper (see fglmzero.cc).
  • Singular/fglm.h

    rd47e6f rdf83c0  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fglm.h,v 1.11 1999-11-15 17:20:00 obachman Exp $
     2// $Id: fglm.h,v 1.12 1999-11-24 12:29:37 wichmann Exp $
    33
    44/****************************************
     
    6969fglmzero( idhdl sourceRingHdl, ideal & sourceIdeal, idhdl destRingHdl, ideal & destideal, BOOLEAN switchBack = TRUE, BOOLEAN deleteIdeal = FALSE );
    7070
     71BOOLEAN
     72fglmquot( ideal sourceIdeal, poly quot, ideal & destIdeal );
     73
    7174// fglmproc(...):
    72 // The procedure which has to be called from the interpreter.
     75// The procedure which has to be called from the interpreter for fglm.
    7376// first is the sourceRing, second is the given ideal in sourceRing.
    7477// Returns the groebnerbasis of the sourceIdeal in the currentRing.
     
    7780BOOLEAN
    7881fglmProc( leftv result, leftv first, leftv second );
     82
     83// fglmquotproc(...):
     84// The procedure which has to be called from the interpreter for fglmquot.
     85// first is the ideal I, second is the polynomial q. The polynomial must
     86// be reduced with respect to I.
     87// Returns the groebnerbasis of I:q in the currentRing.
     88// Checks, if the ideal is really a reduced groebner basis of a
     89// 0-dimensional Ideal and if q is really reduced.
     90//  Returns TRUE if an error occoured.
     91BOOLEAN
     92fglmQuotProc( leftv result, leftv first, leftv second );
    7993
    8094// FindUnivariatePolys (test)
  • Singular/fglmzero.cc

    rd47e6f rdf83c0  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fglmzero.cc,v 1.26 1999-11-15 17:20:03 obachman Exp $
     2// $Id: fglmzero.cc,v 1.27 1999-11-24 12:29:37 wichmann Exp $
    33
    44/****************************************
     
    3131#include "maps.h"
    3232#include "mmemory.h"
     33#include "kstd1.h" // for kNF (see fglmquot)
    3334#include "fglm.h"
    3435#include "fglmvec.h"
     
    540541                // This is the place where we can detect if the sourceIdeal
    541542                // is not reduced. In this case m is not in basis[]. Since basis[]
    542                 // is ordered this is then and only then the case, if basis[i]<m
     543                // is ordered this is the case, if and only if basis[i]<m
    543544                // and basis[j]>m for all j>i
    544545                _state= FALSE;
     
    584585}
    585586
    586 //     Calculates the defining Functionals for the ideal "theIdeal" and
    587 //     returns them in "l".
    588 //     The ideal has to be zero-dimensional and reduced and has to be a
    589 //     real subset of the polynomal ring.
    590 //     In any case it has to be zero-dimensional and minimal (check this
    591 //      via fglmIdealcheck). Any minimal but not reduced ideal is detected.
    592 //      In this case it returns FglmNotReduced.
    593 //     If the base domain is Q, the leading coefficients of the polys
    594 //     have to be in Z.
    595 //     returns TRUE if the result is valid, FALSE if theIdeal
    596 //      is not reduced.
    597 static BOOLEAN
    598 CalculateFunctionals( const ideal & theIdeal, idealFunctionals & l )
    599 {
    600     fglmSdata data( theIdeal );
     587void
     588internalCalculateFunctionals( const ideal & theIdeal, idealFunctionals & l,
     589                              fglmSdata & data )
     590{
    601591
    602592    // insert pOne() into basis and update the workingList:
     
    643633    l.endofConstruction();
    644634    STICKYPROT2( "\nvdim= %i\n", data.getBasisSize() );
     635    return;
     636}
     637
     638//     Calculates the defining Functionals for the ideal "theIdeal" and
     639//     returns them in "l".
     640//     The ideal has to be zero-dimensional and reduced and has to be a
     641//     real subset of the polynomal ring.
     642//     In any case it has to be zero-dimensional and minimal (check this
     643//      via fglmIdealcheck). Any minimal but not reduced ideal is detected.
     644//      In this case it returns FglmNotReduced.
     645//     If the base domain is Q, the leading coefficients of the polys
     646//     have to be in Z.
     647//     returns TRUE if the result is valid, FALSE if theIdeal
     648//      is not reduced.
     649static BOOLEAN
     650CalculateFunctionals( const ideal & theIdeal, idealFunctionals & l )
     651{
     652    fglmSdata data( theIdeal );
     653    internalCalculateFunctionals( theIdeal, l, data );
     654    return ( data.state() );
     655}
     656
     657static BOOLEAN
     658CalculateFunctionals( const ideal & theIdeal, idealFunctionals & l,
     659                      poly & p, fglmVector & v )
     660{
     661    fglmSdata data( theIdeal );
     662    internalCalculateFunctionals( theIdeal, l, data );
     663    //    STICKYPROT("Calculating vector rep\n");
     664    v = data.getVectorRep( p );
     665    // if ( v.isZero() )
     666    //   STICKYPROT("vectorrep is 0\n");
    645667    return ( data.state() );
    646668}
     
    765787fglmDdata::~fglmDdata()
    766788{
    767     fglmASSERT( dimen == basisSize, "Es wurden nicht alle BasisElemente gefunden!" );
     789  // STICKYPROT2("dimen= %i", dimen);
     790  // STICKYPROT2("basisSize= %i", basisSize);
     791  //    fglmASSERT( dimen == basisSize, "Es wurden nicht alle BasisElemente gefunden!" );
    768792    int k;
    769793#ifndef HAVE_EXPLICIT_CONSTR
    770794    delete [] gauss;
    771795#else
    772     for ( k= dimen; k > 0; k-- )
     796    // use basisSize instead of dimen because of fglmquot!
     797    for ( k= basisSize; k > 0; k-- )
    773798        gauss[k].~oldGaussElem();
    774799    Free( (ADDRESS)gauss, (dimen+1)*sizeof( oldGaussElem ) );
     
    776801    Free( (ADDRESS)isPivot, (dimen+1)*sizeof( BOOLEAN ) );
    777802    Free( (ADDRESS)perm, (dimen+1)*sizeof( int ) );
     803    // use basisSize instead of dimen because of fglmquot!
    778804    //. Remember: There is no poly in basis[0], thus k > 0
    779     for ( k= dimen; k > 0; k-- )
     805    for ( k= basisSize; k > 0; k-- )
    780806        pDelete1( basis + k );
    781807    Free( (ADDRESS)basis, (dimen+1)*sizeof( poly ) );
     
    9751001
    9761002static ideal
    977 GroebnerViaFunctionals( const idealFunctionals & l )
    978 // Calculates the groebnerBasis for the ideal which is defined by l.
     1003GroebnerViaFunctionals( const idealFunctionals & l,
     1004                        fglmVector iv = fglmVector() )
     1005// If iv is zero, calculates the groebnerBasis for the ideal which is
     1006// defined by l.
     1007// If iv is not zero, then the groebnerBasis if i:p is calculated where
     1008// i is defined by l and iv is the vector-representation of nf(p) wrt. i
    9791009// The dimension of l has to be finite.
    9801010// The result is in reduced form.
     
    9821012    fglmDdata data( l.dimen() );
    9831013
    984     // insert pOne() and update workinglist:
     1014    // insert pOne() and update workinglist according to iv:
     1015    fglmVector initv;
     1016    if ( iv.isZero() ) {
     1017      // STICKYPROT("initv is zero\n");
     1018      initv = fglmVector( l.dimen(), 1 );
     1019    }
     1020    else {
     1021      // STICKYPROT("initv is not zero\n");
     1022      initv = iv;
     1023    }
     1024     
    9851025    poly one = pOne();
    986     data.updateCandidates( one, fglmVector(l.dimen(), 1) );
     1026    data.updateCandidates( one, initv );
    9871027    number nOne = nInit( 1 );
    988     data.newBasisElem( one, fglmVector( l.dimen(), 1 ), fglmVector( 1, 1 ), nOne );
     1028    data.newBasisElem( one, initv, fglmVector( 1, 1 ), nOne );
    9891029    STICKYPROT( "." );
    9901030    while ( data.candidatesLeft() == TRUE ) {
     
    11131153
    11141154BOOLEAN
     1155fglmquot( ideal sourceIdeal, poly quot, ideal & destIdeal)
     1156{
     1157    BOOLEAN fglmok;
     1158    fglmVector v;
     1159
     1160    idealFunctionals L( 100, pVariables );
     1161    // STICKYPROT("calculating normal form\n");
     1162    // poly p = kNF( sourceIdeal, currRing->qideal, quot );
     1163    // STICKYPROT("calculating functionals\n");
     1164    fglmok = CalculateFunctionals( sourceIdeal, L, quot, v );
     1165    if ( fglmok == TRUE ) {
     1166      // STICKYPROT("calculating groebner basis\n");
     1167        destIdeal= GroebnerViaFunctionals( L, v );
     1168    }
     1169    return fglmok;
     1170}
     1171
     1172BOOLEAN
    11151173FindUnivariateWrapper( ideal source, ideal & destIdeal )
    11161174{
Note: See TracChangeset for help on using the changeset viewer.