Changeset 23ab77 in git for Singular/extra.cc


Ignore:
Timestamp:
Oct 8, 2009, 4:39:52 PM (15 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
1f6c7a1cb42b3480fe6e327a47a342174f605a38
Parents:
549b99bcc1f420029246897c1927cddd9002af2d
Message:
added extra system command for minor code


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

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r549b99 r23ab77  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.322 2009-10-08 10:11:57 seelisch Exp $ */
     4/* $Id: extra.cc,v 1.323 2009-10-08 14:39:52 seelisch Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    21912191      }
    21922192      else
    2193       if(strcmp(sys_cmd,"changeVars")==0)
    2194       {
    2195         /*
    2196         The following code changes the N variables names in currRing in
    2197         the following way: var(i) is replaced by f(i), 1 <= i <= N,
    2198         where f(j) is j written to the base of 26 with the digit '0'
    2199         written as 'a', '1' as 'b', ..., '25' as 'z'.
    2200         E.g. var(1) goes to f(1)='b', ..., var(25) goes to f(25)='z',
    2201              var(26) goes to f(26)='ba', etc.
    2202         The purpose of this rewriting is to eliminate indexed variables,
    2203         as they may cause problems when generating scripts for Magma,
    2204         Maple, or Macaulay2.
    2205         */
    2206         ring newRing = rCopy0(currRing);
    2207         int varN = newRing->N;
    2208         char* alphabet = "abcdefghijklmnopqrstuvwxyz";
    2209         char theName[10];
    2210         char tempChars[10];
    2211         int j; int k; int l;
    2212         for (int i = 1; i <= varN; i++)
    2213         {
    2214           k = i;
    2215           l = 9;
    2216           j = k % 26;
    2217           tempChars[l--] = alphabet[j];
    2218           k = (k - j) / 26;
    2219           while (k != 0)
     2193      if(strcmp(sys_cmd,"changeRing")==0)
     2194      {
     2195        if ((h->Typ() == INT_CMD) &&
     2196            (h->next->Typ() == INT_CMD))
     2197        {
     2198          const int fc     = (const int)(long)h->Data();
     2199          const int varN   = (const int)(long)h->next->Data();
    22202200          {
    2221             j = k % 26;
    2222             tempChars[l--] = alphabet[j];
    2223             k = (k - j) / 26;
     2201            /*
     2202            The following code creates a ring with characteristic fc, order dp and
     2203            varN variables with the following names: var(j) is j written to the
     2204            base of 26 with the digit '0' written as 'a', '1' as 'b', ..., and '25'
     2205            as 'z'.
     2206            I.e., var(1) has the name 'b', ..., var(25) the name 'z',
     2207                 var(26) the name 'ba', etc.
     2208            Afterwards, the new ring will become the current ring.
     2209            The purpose of this rewriting is to eliminate indexed variables,
     2210            as they may cause problems when generating scripts for Magma,
     2211            Maple, or Macaulay2.
     2212            */
     2213            ring newRing = (ring) omAlloc0Bin(sip_sring_bin);
     2214            newRing->ch = fc;
     2215            newRing->N = varN;
     2216            newRing->names = (char **) omAlloc0(varN * sizeof(char_ptr));
     2217            char* alphabet = "abcdefghijklmnopqrstuvwxyz";
     2218            char theName[10];
     2219            char tempChars[10];
     2220            int j; int k; int l;
     2221            for (int i = 1; i <= varN; i++)
     2222            {
     2223              k = i;
     2224              l = 9;
     2225              j = k % 26;
     2226              tempChars[l--] = alphabet[j];
     2227              k = (k - j) / 26;
     2228              while (k != 0)
     2229              {
     2230                j = k % 26;
     2231                tempChars[l--] = alphabet[j];
     2232                k = (k - j) / 26;
     2233              }
     2234              l++;
     2235              for (j = l; j < 10; j++) theName[j - l] = tempChars[j];
     2236              theName[10 - l] = '\0';
     2237              newRing->names[i - 1] = omStrDup(theName);
     2238            }
     2239            newRing->wvhdl = (int **)omAlloc0(2 * sizeof(int_ptr));
     2240            newRing->order = (int *)omAlloc(2* sizeof(int *));
     2241            newRing->block0 = (int *)omAlloc0(2 * sizeof(int *));
     2242            newRing->block1 = (int *)omAlloc0(2 * sizeof(int *));
     2243            newRing->order[0] = ringorder_dp;
     2244            newRing->block0[0] = 1;
     2245            newRing->block1[0] = varN;
     2246            newRing->order[1]  = 0;
     2247            newRing->OrdSgn    = 1;
     2248            rComplete(newRing);
     2249            res->rtyp = RING_CMD;
     2250            res->data = (void *)newRing;
     2251            return FALSE;
    22242252          }
    2225           l++;
    2226           for (j = l; j < 10; j++) theName[j - l] = tempChars[j];
    2227           theName[10 - l] = '\0';
    2228           newRing->names[i - 1] = omStrDup(theName);
    2229         }
    2230         rComplete(newRing);
    2231         currRing = newRing;
    2232         return FALSE;
     2253        } 
    22332254      }
    22342255      else
Note: See TracChangeset for help on using the changeset viewer.