Changeset db2e1c in git


Ignore:
Timestamp:
Apr 21, 2008, 1:23:12 PM (16 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
fd8c22d40aaba525d2d73c49f8b5c839fffbd1d1
Parents:
3ad53dd58ab62b367f6a39e871372997e9c519bd
Message:
*hannes: preimage via rTensor


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

Legend:

Unmodified
Added
Removed
  • kernel/maps.cc

    r3ad53dd rdb2e1c  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: maps.cc,v 1.6 2007-01-31 23:51:24 motsak Exp $ */
     4/* $Id: maps.cc,v 1.7 2008-04-21 11:23:11 Singular Exp $ */
    55/*
    66* ABSTRACT - the mapping of polynomials to other rings
     
    198198{
    199199  int i,j;
    200   int ordersize = rBlocks(currRing) + 1;
    201200  poly p,pp,q;
    202201  ideal temp1;
    203202  ideal temp2;
    204   int *orders = (int*) omAlloc0(sizeof(int)*(ordersize));
    205   int *block0 = (int*) omAlloc0(sizeof(int)*(ordersize));
    206   int *block1 = (int*) omAlloc0(sizeof(int)*(ordersize));
    207   int **wv = (int **) omAlloc0(ordersize * sizeof(int *));
    208203
    209204  int imagepvariables = theImageRing->N;
    210205  ring sourcering = currRing;
    211206  int N = pVariables+imagepvariables;
    212   char** names = (char**) omAlloc0(N*sizeof(char*));
    213 
    214   memcpy(names, currRing->names, currRing->N*sizeof(char*));
    215   memcpy(&(names[currRing->N]), theImageRing->names,
    216           (theImageRing->N*sizeof(char*)));
    217   sip_sring tmpR;
    218 
    219   //if (theImageRing->OrdSgn == 1)s
    220      orders[0] = ringorder_dp;
    221   //else orders[0] = ringorder_ls;
    222   block1[0] = imagepvariables;
    223   block0[0] = 1;
    224   /*
    225   *if (sourcering->order[blockmax])
    226   *{
    227   *  if (sourcering->OrdSgn == 1) orders[1] = ringorder_dp;
    228   *  else orders[1] = ringorder_ls;
    229   *  block1[1] = N;
    230   *}
    231   *else
    232   */
    233   for (i=0; i<ordersize - 1; i++)
    234   {
    235     orders[i+1] = sourcering->order[i];
    236     block0[i+1] = sourcering->block0[i]+imagepvariables;
    237     block1[i+1] = sourcering->block1[i]+imagepvariables;
    238     wv[i+1] = sourcering->wvhdl[i];
    239   }
    240   tmpR = *currRing;
    241   tmpR.N = N;
    242   tmpR.order = orders;
    243   tmpR.block0 = block0;
    244   tmpR.block1 = block1;
    245   tmpR.wvhdl = wv;
    246   tmpR.names = names;
    247   rComplete(&tmpR, 1);
    248   rTest(&tmpR);
     207
     208  ring tmpR;
     209  if (rTensor(theImageRing,sourcering,tmpR,FALSE,TRUE)!=1)
     210  {
     211     WerrorS("rTensor error");
     212     return NULL;
     213  }
    249214
    250215#ifdef HAVE_PLURAL
    251216  if (rIsPluralRing(theImageRing))
    252217  {
    253     rUnComplete(&tmpR);
    254     omFreeSize(orders, sizeof(int)*(ordersize));orders=NULL;
    255     omFreeSize(block0, sizeof(int)*(ordersize));block0=NULL;
    256     omFreeSize(block1, sizeof(int)*(ordersize));block1=NULL;
    257     omFreeSize(wv, sizeof(int*)*(ordersize)); wv=NULL;
    258     omFreeSize(names, (currRing->N)*sizeof(char*)); names=NULL;
    259     memset(&tmpR,0,sizeof(tmpR));
    260218    if ((rIsPluralRing(sourcering)) && (ncRingType(sourcering)!=nc_comm))
    261219    {
     
    263221      return NULL;
    264222    }   
    265     ring tmpR_ptr;
    266     if ( rSum(theImageRing, sourcering, tmpR_ptr ) !=1 )
    267     {
    268       /* something is wrong with the rings... */
    269       Werror("Error in rSum");
    270       return NULL;
    271     }
    272     memcpy(&tmpR,tmpR_ptr,sizeof(tmpR));
    273     // Action!
    274223  }
    275224  if (nSetMap(theImageRing) != nCopy)
     
    281230
    282231  // change to new ring
    283   rChangeCurrRing(&tmpR);
     232  rChangeCurrRing(tmpR);
    284233  if (id==NULL)
    285234    j = 0;
     
    334283    if (p!=NULL)
    335284    {
    336       q = pChangeSizeOfPoly(&tmpR, p,imagepvariables+1,N);
     285      q = pChangeSizeOfPoly(tmpR, p,imagepvariables+1,N);
    337286      if (j>=IDELEMS(temp1))
    338287      {
     
    344293    }
    345294  }
    346   id_Delete(&temp2, &tmpR);
     295  id_Delete(&temp2, tmpR);
    347296  idSkipZeroes(temp1);
    348   rUnComplete(&tmpR);
    349   if (orders!=NULL)
    350   {
    351     omFreeSize(orders, sizeof(int)*(ordersize));
    352     omFreeSize(block0, sizeof(int)*(ordersize));
    353     omFreeSize(block1, sizeof(int)*(ordersize));
    354     omFreeSize(wv, sizeof(int*)*(ordersize));
    355     omFreeSize(names, (currRing->N)*sizeof(char*));
    356   }
     297  rKill(tmpR);
    357298  return temp1;
    358299}
  • kernel/ring.cc

    r3ad53dd rdb2e1c  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.77 2008-03-19 17:44:11 Singular Exp $ */
     4/* $Id: ring.cc,v 1.78 2008-04-21 11:23:12 Singular Exp $ */
    55
    66/*
     
    724724/*2
    725725 *returns -1 for not compatible, (sum is undefined)
    726  *         0 for equal, (and sum)
    727726 *         1 for compatible (and sum)
    728727 */
    729 int rSum(ring r1, ring r2, ring &sum)
    730 {
    731   if (r1==r2)
    732   {
    733     sum=r1;
    734     r1->ref++;
    735     return 0;
    736   }
     728/* vartest: test for variable/paramter names
     729* dp_dp: for comm. rings: use block order dp,dp
     730*/
     731int rTensor(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp)
     732{
    737733  ring save=currRing;
    738734  ip_sring tmpR;
     
    746742      if (r1->parameter!=NULL)
    747743      {
    748         if (strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */
     744        if (!vartest || (strcmp(r1->parameter[0],r2->parameter[0])==0)) /* 1 par */
    749745        {
    750746          tmpR.parameter=(char **)omAllocBin(char_ptr_bin);
     
    767763          // HANNES: TODO: delete nSetChar
    768764          rChangeCurrRing(r1);
    769           if ((strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */
     765          if ((!vartest || (strcmp(r1->parameter[0],r2->parameter[0])==0)) /* 1 par */
    770766              && n_Equal(r1->minpoly,r2->minpoly, r1))
    771767          {
     
    787783        else
    788784        {
    789           if ((strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */
     785          if ((!vartest || (strcmp(r1->parameter[0],r2->parameter[0])==0)) /* 1 par */
    790786              && (rPar(r2)==1))
    791787          {
     
    806802        if (r2->minpoly!=NULL)
    807803        {
    808           if ((strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */
     804          if ((!vartest || (strcmp(r1->parameter[0],r2->parameter[0])==0)) /* 1 par */
    809805              && (rPar(r1)==1))
    810806          {
     
    832828          for(j=0;j<rPar(r2);j++)
    833829          {
    834             for(l=0;l<i;l++)
     830            if (vartest)
    835831            {
    836               if(strcmp(tmpR.parameter[l],r2->parameter[j])==0)
    837                 break;
     832              for(l=0;l<i;l++)
     833              {
     834                if(strcmp(tmpR.parameter[l],r2->parameter[j])==0)
     835                  break;
     836              }
    838837            }
     838            else
     839              l=i;
    839840            if (l==i)
    840841            {
     
    983984    else if ((r2->parameter!=NULL) && (strlen(r1->names[i])==1))
    984985    {
    985       for(j=0;j<rPar(r2);j++)
    986       {
    987         if (strcmp(r1->names[i],r2->parameter[j])==0)
    988         {
    989           b=FALSE;
    990           break;
     986      if (vartest)
     987      {
     988        for(j=0;j<rPar(r2);j++)
     989        {
     990          if (strcmp(r1->names[i],r2->parameter[j])==0)
     991          {
     992            b=FALSE;
     993            break;
     994          }
    991995        }
    992996      }
     
    10121016    else if ((r1->parameter!=NULL) && (strlen(r2->names[i])==1))
    10131017    {
    1014       for(j=0;j<rPar(r1);j++)
    1015       {
    1016         if (strcmp(r2->names[i],r1->parameter[j])==0)
    1017         {
    1018           b=FALSE;
    1019           break;
     1018      if (vartest)
     1019      {
     1020        for(j=0;j<rPar(r1);j++)
     1021        {
     1022          if (strcmp(r2->names[i],r1->parameter[j])==0)
     1023          {
     1024            b=FALSE;
     1025            break;
     1026          }
    10201027        }
    10211028      }
     
    10241031    if (b)
    10251032    {
    1026       for(j=0;j<r1->N;j++)
    1027       {
    1028         if (strcmp(r1->names[j],r2->names[i])==0)
    1029         {
    1030           b=FALSE;
    1031           break;
     1033      if (vartest)
     1034      {
     1035        for(j=0;j<r1->N;j++)
     1036        {
     1037          if (strcmp(r1->names[j],r2->names[i])==0)
     1038          {
     1039            b=FALSE;
     1040            break;
     1041          }
    10321042        }
    10331043      }
     
    13691379
    13701380/*2
     1381 *returns -1 for not compatible, (sum is undefined)
     1382 *         0 for equal, (and sum)
     1383 *         1 for compatible (and sum)
     1384 */
     1385int rSum(ring r1, ring r2, ring &sum)
     1386{
     1387  if (r1==r2)
     1388  {
     1389    sum=r1;
     1390    r1->ref++;
     1391    return 0;
     1392  }
     1393  return rTensor(r1,r2,sum,TRUE,FALSE);
     1394}
     1395
     1396/*2
    13711397 * create a copy of the ring r, which must be equivalent to currRing
    13721398 * used for qring definition,..
     
    35923618     i++;
    35933619  } while (1);
     3620  WarnS("re-creating ring with comps");
    35943621  last_block=i-1;
    35953622 
  • kernel/ring.h

    r3ad53dd rdb2e1c  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.27 2008-03-19 17:44:11 Singular Exp $ */
     9/* $Id: ring.h,v 1.28 2008-04-21 11:23:12 Singular Exp $ */
    1010
    1111/* includes */
     
    8080int    rIsExtension();
    8181int    rSum(ring r1, ring r2, ring &sum);
     82int rTensor(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp);
    8283
    8384BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1);
Note: See TracChangeset for help on using the changeset viewer.