Singular
https://www.singular.uni-kl.de/forum/

declaring 'number'^'bigint'
https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2859
Page 1 of 1

Author:  vkrao100 [ Thu Jul 25, 2019 8:17 pm ]
Post subject:  declaring 'number'^'bigint'

Dear forum members,

I am looking to declare a number whose exponent can be a bigint instead of int (required for my experiments).
for ex: number beta = (alpha)^(2^33).
I have worked around the Singular source code to allow exponents up to (2^63)-1.

Understandably, Singular complains about the following error due to its limitations on number declaration:

`number` ^ `bigint` failed
expected `number` ^ `int`

I am working over a polynomial ring with variables whose coefficients are in the finite field F_q (q=2^k extension) and variables take values in F_2.
I also saw the feature to typecast a given 'number' to 'bigint' as shown in the manual in bigint declaration (Manual/4-0-3/sing_74.htm#SEC113), but Singular errors out saying it cannot typecast a number to bigint.

So, my question is:
1. Is there a restriction on typecasting a number to bigint? The manual clearly says that a number can be typecasted to bigint.
2. If this typecasting cannot be done, Is there a way around to declare a number^bigint by altering some part of the source code?
3. If 1. and 2. are not feasible, is there any other way to tackle this problem as it is a must-do experiment?

Appreciate all the help I can get on this.

thanks in advance,
-Vikas

Author:  hannes [ Fri Jul 26, 2019 5:00 pm ]
Post subject:  Re: declaring 'number'^'bigint'

a type cast number -> bigint is possible:
number n=....;
bigint b=bigint(n);

To implement number^bigint one has to do:
- implement the routine to compute it using n_Power, n_Mult, n_Delete,
for the operations with the number,
and n_MPZ(expoent,b,coeffs_BIGINT) to convert the bigint b to an mpz_t number
(on the C/C++ side, both number and bigint have the type number)
- add a line to Singular/table.h
,{D(jjPOWER_N_B), '^', NUMBER_CMD, NUMBER_CMD, BIGINT_CMD, ALLOW_NC | ALLOW_RING}
- add jjPOWER_N_B so Singular/iparith.cc:
static BOOLEAN jjPOWER_N_B(leftv res, leftv u, leftv v)
{
number e=(number)v->Data();
number n=(number)u->Data();
number r=n_Power_bigint(n,ei,currRing);
res->data=(char*)r;
return FALSE;
}

Author:  vkrao100 [ Mon Sep 16, 2019 11:54 pm ]
Post subject:  Re: declaring 'number'^'bigint'

I was able to modify the files and get the desired result. Thank you for responding :o

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/