MCPcopy Create free account
hub / github.com/Singular/Singular / rSubring

Function rSubring

Singular/ipshell.cc:6011–6171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6009}
6010
6011ring rSubring(ring org_ring, sleftv* rv)
6012{
6013 ring R = rCopy0(org_ring);
6014 int *perm=(int *)omAlloc0((org_ring->N+1)*sizeof(int));
6015 int n = rBlocks(org_ring), i=0, j;
6016
6017 /* names and number of variables-------------------------------------*/
6018 {
6019 int l=rv->listLength();
6020 if (l>MAX_SHORT)
6021 {
6022 Werror("too many ring variables(%d), max is %d",l,MAX_SHORT);
6023 goto rInitError;
6024 }
6025 R->N = l; /*rv->listLength();*/
6026 }
6027 omFree(R->names);
6028 R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
6029 if (rSleftvList2StringArray(rv, R->names))
6030 {
6031 WerrorS("name of ring variable expected");
6032 goto rInitError;
6033 }
6034
6035 /* check names for subring in org_ring ------------------------- */
6036 {
6037 i=0;
6038
6039 for(j=0;j<R->N;j++)
6040 {
6041 for(;i<org_ring->N;i++)
6042 {
6043 if (strcmp(org_ring->names[i],R->names[j])==0)
6044 {
6045 perm[i+1]=j+1;
6046 break;
6047 }
6048 }
6049 if (i>org_ring->N)
6050 {
6051 Werror("variable %d (%s) not in basering",j+1,R->names[j]);
6052 break;
6053 }
6054 }
6055 }
6056 //Print("perm=");
6057 //for(i=1;i<org_ring->N;i++) Print("v%d -> v%d\n",i,perm[i]);
6058 /* ordering -------------------------------------------------------------*/
6059
6060 for(i=0;i<n;i++)
6061 {
6062 int min_var=-1;
6063 int max_var=-1;
6064 for(j=R->block0[i];j<=R->block1[i];j++)
6065 {
6066 if (perm[j]>0)
6067 {
6068 if (min_var==-1) min_var=perm[j];

Callers 1

jjEXTENDED_SYSTEMFunction · 0.85

Calls 10

rCopy0Function · 0.85
omAlloc0Function · 0.85
rBlocksFunction · 0.85
WerrorFunction · 0.85
rSleftvList2StringArrayFunction · 0.85
WerrorSFunction · 0.85
rCompleteFunction · 0.85
rDeleteFunction · 0.85
listLengthMethod · 0.80
CleanUpMethod · 0.80

Tested by

no test coverage detected