Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: declaring 'number'^'bigint'
PostPosted: Thu Jul 25, 2019 8:17 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Re: declaring 'number'^'bigint'
PostPosted: Fri Jul 26, 2019 5:00 pm 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
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;
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: declaring 'number'^'bigint'
PostPosted: Mon Sep 16, 2019 11:54 pm 
I was able to modify the files and get the desired result. Thank you for responding :o


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 10:54 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group