Changeset b39bc1f in git for kernel/gring.cc


Ignore:
Timestamp:
Oct 18, 2004, 8:57:07 PM (20 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
bc36a0348925ea3732666805bd1ad0d87c9223e3
Parents:
a63c242b49717f7a64c2432c5f75c71fc335ebdf
Message:
*levandov: new commands oppose, opposite and envelope are available


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

Legend:

Unmodified
Added
Removed
  • kernel/gring.cc

    ra63c24 rb39bc1f  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: gring.cc,v 1.15 2004-10-13 10:50:37 levandov Exp $
     9 *  Version: $Id: gring.cc,v 1.16 2004-10-18 18:57:06 levandov Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    23052305}
    23062306
    2307 poly p_Oppose(ring Rop, poly p)
    2308 {
    2309   /* TODO check Rop == rOpposite(currRing) */
    2310   /* the same basefield, same number of variables */
    2311 
     2307poly pOppose(ring Rop, poly p)
     2308  /* opposes a vector p from Rop to currRing */
     2309{
    23122310  /* the simplest case:*/
    2313   if (Rop==currRing) return pCopy(p); // ok
    2314   nMapFunc nMap=nSetMap(Rop);
     2311  if (  Rop == currRing )  return(pCopy(p));
     2312  /* check Rop == rOpposite(currRing) */
     2313  if ( !rIsLikeOpposite(currRing, Rop) )
     2314  {
     2315    WarnS("an opposite ring should be used");
     2316    return NULL;
     2317  }
     2318  /* nMapFunc nMap = nSetMap(Rop);*/
     2319  /* since we know that basefields coinside! */
    23152320  int *perm=(int *)omAlloc0((Rop->N+1)*sizeof(int));
    2316   /* we know perm exactly */
     2321  if (!p_IsConstantPoly(p, Rop))
     2322  {
     2323    /* we know perm exactly */
     2324    int i;
     2325    for(i=1; i<=Rop->N; i++)
     2326    {
     2327      perm[i] = Rop->N+1-i;
     2328    }
     2329  }
     2330  poly res = pPermPoly(p, perm, Rop, nCopy);
     2331  omFreeSize((ADDRESS)perm,(Rop->N+1)*sizeof(int));
     2332  return res;
     2333}
     2334
     2335ideal idOppose(ring Rop, ideal I)
     2336  /* opposes a module I from Rop to currRing */
     2337{
     2338  /* the simplest case:*/
     2339  if ( Rop == currRing ) return idCopy(I);
     2340  /* check Rop == rOpposite(currRing) */
     2341  if (!rIsLikeOpposite(currRing, Rop))
     2342  {
     2343    WarnS("an opposite ring should be used");
     2344    return NULL;
     2345  }
    23172346  int i;
    2318   for(i=1; i<=Rop->N; i++)
    2319   {
    2320     perm[i] = Rop->N+1-i;
    2321   }
    2322   /*  int *par_perm=NULL; */
    2323   poly res = pPermPoly(p, perm, Rop, nMap);
    2324   omFreeSize((ADDRESS)perm,(Rop->N+1)*sizeof(int));
    2325   //omFreeSize((ADDRESS)par_perm,rPar(r)*sizeof(int));
    2326   return res;
    2327 }
    2328 
    2329 
    2330 #endif
     2347  ideal idOp = idInit(I->ncols, I->rank);
     2348  for (i=0; i< (I->ncols)*(I->nrows); i++)
     2349  {
     2350    idOp->m[i] = pOppose(Rop,I->m[i]);
     2351  }
     2352  idTest(idOp);
     2353  return idOp;
     2354}
     2355
     2356BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
     2357  /* checks whether rings rBase and rCandidate */
     2358  /* could be opposite to each other */
     2359  /* returns TRUE if it is so */
     2360{
     2361  /* the same basefield */
     2362  int diagnose = TRUE;
     2363  ring save = currRing;
     2364  rChangeCurrRing(rBase);
     2365  nMapFunc nMap = nSetMap(rCandidate);
     2366  if (nMap != nCopy) diagnose = FALSE;
     2367  rChangeCurrRing(save);
     2368  /* same number of variables */
     2369  if (rBase->N != rCandidate->N) diagnose = FALSE;
     2370  /* nc and comm ring */
     2371  if ( rIsPluralRing(rBase) != rIsPluralRing(rCandidate) ) diagnose = FALSE;
     2372  /* TODO: varnames are e->E etc */
     2373  return diagnose;
     2374}
     2375
     2376#endif
Note: See TracChangeset for help on using the changeset viewer.