Opened 13 years ago

Closed 9 years ago

# charstr(basering), string(basering) for coefficien ring

Reported by: Owned by: gorzel hannes minor 3-1-2 and higher singular-kernel 3-1-1

### Description

For coefficients rings i.e. integer,n the commands

string(r); and charstr(r); should return integer,char(basering)

Otherwise the standard method of creating new rings by exucute from string(basering) does not work.

charstr, string(basering); should give the same as ringlist

Example:

``` string S;

ring r0dp = (0,t),(x,y),dp;    // OK here
string(basering);
charstr(basering);
S = "ring rnew = ("+charstr(basering)+"),("+ varstr(basering) +"),"+"lp;";
S;
execute(S);
basering;

// ----------------------------------------------------

ring rZ = integer,(x,y),dp;  // OK (integer),(x,y),(dp(2),C)
string(basering);

charstr(basering);  // integer

S = "ring rnew = ("+charstr(basering)+"),("+ varstr(basering) +"),"+"lp;";
S;
execute(S);
basering;

// ----------------------------------------------------

ring rZ8 = (integer,8),(x,y),dp;   //  BUG  her
string(basering);

charstr(basering);    // "coefficient ring"   should be  "integer,8"
S = "ring rnew = ("+charstr(basering)+"),("+ varstr(basering) +"),"+"lp;";
S;   // ring rnew = (coefficient ring),(x,y),lp;
/*
> execute(S);
? error occurred in or before STDIN line 37: `ring rnew =  (coefficient ring),(x,y),lp;`
? expected ring-expression. type 'help ring;'
? last reserved name was `ring`
skipping text from `)`
*/
basering;    // unchanged
//   coeff. ring is : Z/8
//   number of vars : 2
//        block   1 : ordering dp
//                  : names    x y
//        block   2 : ordering C

ringlist(basering);    // This is OK
/*
[1]:
[1]:
integer
[2]:
[1]:
8
[2]:
1
*/
```

### comment:1 Changed 9 years ago by kroeker@…

is fixed meanwhile.

needs corresponding test before closing as fixed

### comment:2 follow-up:  3 Changed 9 years ago by kroeker@…

` charstr(basering) ` and ` string(basering) ` incorrect at least for following examples:

```ring r = (real,50),(x,y,z),dp;
string(basering); //= "(real),(x,y,z),dp;"

ring r = (real,10,50),(x,y,z),dp;
string(basering); // ="(real),(x,y,z),dp;"
```

### comment:3 in reply to:  2 Changed 9 years ago by kroeker@…

Replying to kroeker@…: invalid comment, I'm probably too exhausted today Correction: the case for reals is fixed in Spielwiese, but for complex numbers there is still a bug:

``` def S;
ring cR1050 = (complex,10,50),(x,y),dp;
basering;

charstr(basering);    //   complex,10,i  // Wrong, should be (complex,10,50,i)
S = "ring cR1050new = ("+charstr(basering)+"),("+ varstr(basering) +"),"+"lp;";
S;    // ring cR1050new = (complex,10,i),(x,y),lp; // wrong!

execute(S);
basering;
```

### comment:4 Changed 9 years ago by gorzel

Mostly Ok with one exception if char = 2:

'coefficient ring' has been changed to 'integer' also for these cases Z/(n{m} \ Z) But if n == 2 then the charstr and string(basering) give 3 instead of 2 m

```> ring r6int = (integer,6,3),x,dp;
> string(basering);
(integer,6^3),(x),(dp(1),C)   // OK
> charstr(basering);
integer,6^3

> ring r5int = (integer,5,3),x,dp;  // OK with prime  > 2,  as base
> string(basering);
(integer,5^3),(x),(dp(1),C)
> charstr(basering);
integer,5^3

> ring r2int = (integer,2,3),x,dp;  // wrong here
> string(basering);
(integer,3),(x),(dp(1),C)
> charstr(basering);
integer,3
```

It will be correctly calculated mod 8, but which representatives are choosen?

```> number(5);
-3
> number(4);
4
> number(6);
-2
> number(7);
-1
> number(8);
0
> number(9);
1
```

Compare with Z/53. There are the representatives are non-negative.

```> setring r5int;
> basering;
//   coeff. ring is : Z/5^3
//   number of vars : 1
//        block   1 : ordering dp
//                  : names    x
//        block   2 : ordering C
> number(126);
1
> number(124);
124
> number(123);
123
```

### comment:5 Changed 9 years ago by hannes

Resolution: → fixed new → closed

fixed in master and spielwiese

Note: See TracTickets for help on using tickets.