Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function to test whether or not some integer is a primitive root modulo n #6567

Closed
sagetrac-mvngu mannequin opened this issue Jul 20, 2009 · 16 comments
Closed

function to test whether or not some integer is a primitive root modulo n #6567

sagetrac-mvngu mannequin opened this issue Jul 20, 2009 · 16 comments

Comments

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jul 20, 2009

Currently, the function primitive_root() finds a primitive root modulo n. Ticket #6467 proposes to find all primitive roots modulo a fixed n. We should also implement a function to determine whether or not some integer is a primitive root modulo n. A good way is to do this without first having to generate all primitive roots mod n.

Apply attachment: 6567_2.patch

Depends on #12116

CC: @kcrisman

Component: number theory

Keywords: primitive roots

Author: David Roe

Reviewer: Julian Rueth, Simon Spicer

Merged: sage-5.8.beta3

Issue created by migration from https://trac.sagemath.org/ticket/6567

@sagetrac-mvngu sagetrac-mvngu mannequin added this to the sage-5.8 milestone Jul 20, 2009
@roed314
Copy link
Contributor

roed314 commented Oct 17, 2012

comment:2

Review anyone?

@roed314
Copy link
Contributor

roed314 commented Oct 17, 2012

Author: David Roe

@saraedum
Copy link
Member

comment:3

There is a problem in the docstring:

Traceback (most recent call last):
  File "/dev/shm/sage_testdir/integer_mod_10415.py", line 3096, in <module>
    runner=runner)
  File "/dev/shm/sage/local/bin/sagedoctest.py", line 54, in testmod_returning_runner
    runner=runner)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 1819, in testmod_returning_runner
    for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 839, in find
    self._find(tests, obj, name, module, source_lines, globs, {})
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 893, in _find
    globs, seen)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 881, in _find
    test = self._get_test(obj, name, module, globs, source_lines)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 965, in _get_test
    filename, lineno)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 594, in get_doctest
    return DocTest(self.get_examples(string, name), globs,
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 608, in get_examples
    return [x for x in self.parse(string, name)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 570, in parse
    self._parse_example(m, name, lineno)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 628, in _parse_example
    self._check_prompt_blank(source_lines, indent, name, lineno)
  File "/dev/shm/sage/local/bin/ncadoctest.py", line 715, in _check_prompt_blank
    line[indent:indent+3], line))
ValueError: line 27 of the docstring for __main__.example_32 lacks blank after ...: '            ....:     for k in range(Integer(1),Integer(4)):'

@saraedum
Copy link
Member

Reviewer: Julian Rueth

@roed314
Copy link
Contributor

roed314 commented Feb 27, 2013

comment:4

The doctesting error was due to depending on syntax only valid after #12415. Since I don't want to wait on that, I've updated the doctest (and also marked the dependency correctly).

@roed314
Copy link
Contributor

roed314 commented Feb 27, 2013

Dependencies: #12116

@kcrisman
Copy link
Member

comment:5
# self**(p**k*(p-1)//q) = 1 for some q 

Should that be k-1? I'd also put it "# now self..." just to make it clear

Everything else looks nice. I feel like I want to check the logic for numbers divisible by 2, 3, or 5 but where start > 5 a little more closely (getting late here) but if someone else does that first that is fine.

@roed314
Copy link
Contributor

roed314 commented Feb 27, 2013

Attachment: 6567.patch.gz

@roed314
Copy link
Contributor

roed314 commented Feb 27, 2013

comment:6

I'm not quite sure what you meant by the "# now self..." but I made some change along those lines. I'm also not sure why patchbot was giving me a failure in applying. Hopefully the new patch won't have the same problem.

@haikona
Copy link
Mannequin

haikona mannequin commented Feb 28, 2013

Attachment: 6567_2.patch.gz

Fixes single line in self.is_primitive_root() to make compatible with new 12116.patch

@haikona
Copy link
Mannequin

haikona mannequin commented Feb 28, 2013

Changed reviewer from Julian Rueth to Julian Rueth, Simon Spicer

@haikona
Copy link
Mannequin

haikona mannequin commented Feb 28, 2013

comment:7

Patch applies, but with the (proposed) change to #12116 - swapping the order integers returned by perfect_power() so that (a^b).perfect_power() returns (a,b) and not (b,a) - the code breaks on perfect powers or twice perfect powers. A simple single line change fixes this; I've uploaded a new patch with this fix. Line 1485 goes from

k, p = odd.perfect_power() 

to

p, k = odd.perfect_power() 

Everything else is good.

@roed314
Copy link
Contributor

roed314 commented Mar 1, 2013

comment:8

Fine with me.

@jdemeyer
Copy link

jdemeyer commented Mar 4, 2013

comment:9

Please clarify which patch(es) must be applied.

@roed314

This comment has been minimized.

@jdemeyer
Copy link

jdemeyer commented Mar 6, 2013

Merged: sage-5.8.beta3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants