Tuukka Toivonen on Thu, 30 May 2002 12:32:10 +0300 (EEST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
detecing non quadratic residue in sqrt/trapping errors |
I have a line in my Pari function similar to f(c) = { x = sqrt(c); ... something more ... } c can be, for example, an integer modulo p. It either has or has not the solution. If there isn't a solution, pari says "non-quadratic residue in gsqrt" and halts the function. I want to have instead a test, so that if the square root doesn't exist, the function does something else instead of halting. So, effectively, x = sqrt(c) if(error happened, do something else, else no error ); Is it possible to trap errors in Pari somehow? I'd like to let the function handle also reals and complex numbers, so I'd like to assume as little as possible about the variable type. I'm writing a function to compute square roots from a number of the form Mod(a,p) + Mod(b,p)*I