I'm not entirely sure how to implement this though, if we don't want it to be the global behavior. I was considering just implementing it for the rank() function, but I'm assuming it processes the input into the function before it starts running the actual function, right? So it isn't just behavior I could set within the rank function. Would it be possible or desirable to make it so that matrix by scalar multiplication converts the scalar to an element of QQ? Or perhaps rank treats the entries of the matrix as members of QQ? The latter sounds best to me.
Also, with regard to is_prime, would it be possible/easy change the default behavior of is_prime to try to convert the input to an integer if it is a member of QQ and raising an error if it is unable to convert the input to an integer, and give an option/keyword to not do this conversion? Perhaps if the conversion is succesful, a warning could be raised that the conversion was made, in case the user actually did want to check for primality over QQ. Though, Volker Braun's suggestion also sounds good, but I'm not sure how helpful it would be to a beginner if they don't know what a field is. I might suggest a warning which comes up if the user enters an element of QQ that is equivalent to an integer that tells them to run ZZ(x).is_prime() instead of (x).is_prime, if they to check primality over the integers. However, I'm not sure how elegant this solution is. On Tuesday, March 27, 2018 at 2:07:41 AM UTC-5, Ralf Stephan wrote: > > Hello, > I thought I'd try Sage for a casual computation. I was interested in which > numbers of the form (2^n - (-1)^n)/3 are prime. I first tried out n=23: > > sage: (2^23+1)/3 > 2796203 > sage: _.is_prime() > False > sage: factor(2796203) > 2796203 > > It turns out that Rational.is_prime does not exist and the fallback gives > false answers. > > Then, I tried to print a list of primes of the above form, using the > global is_prime: > > sage: for n in range(1,100): > ....: if is_prime((2^n - (-1)^n)/3): > ....: print((2^n - (-1)^n)/3) > ....: > sage: > > No output. Turns out `is_prime(ZZ((2^n - (-1)^n)/3))` works. Really? How > long does Sage exist without a fix to that? This goes beyond "serious lack > of reviewers" and "dev shortage". > > There was always the notion that you shouldn't "team up" for ticket > review. I'm now breaking it. If YOU are interested in fixing the above or > similar problems please mail me. There are also about 25 calculus tickets > from me waiting for review. But probably noone is really interested in that > either. The algebraists can have their Sage back. Good job. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.