![]() |
|
|
#1 |
|
Bemusing Prompter
"Danny"
Dec 2002
California
95616 Posts |
For the "P-1..." and "ECM..." options, users can input an expression of the form k * bn ± c. However, it requires the user to input values into four separate fields. It seems a bit clumsy in today's standards. Therefore, I'm proposing a feature that will automatically parse expressions of certain forms.
As a proof of concept, I've written a simple Python program that processes expressions of the form k * bn ± c and bn ± c (in which case k = 1). I don't imagine it being to hard to add a similar feature to Prime95. Code:
import re
def main():
# it's probably possible to use just one regular expression
pattern_full = "^(\d+)\s*\*\s*\d+\s*\^\s*\d+\s*[\+-]\s*\d+"
pattern_no_prefix = "(\d+)\s*\^\s*(\d+)\s*([\+-])\s*(\d+)"
v1 = 1
def print_vars(k = 1, b = 1, p = 1, c = 0):
out = "k = " + str(k) + ", b = " + str(b) + ", n = " + str(p) + ", c = " + str(c)
print out
while True:
raw_expr = raw_input("Enter expression (\"q\" to quit): ")
expr = raw_expr.strip()
if expr == "q":
break
f = re.findall(pattern_full, expr)
np = re.findall(pattern_no_prefix, expr)
if not f == []:
v1 = int(f[0])
if np == []:
print "Invalid expression"
else:
v2 = int(np[0][0])
v3 = int(np[0][1])
v4 = int(np[0][3])
if np[0][2] == "-":
v4 = -v4
print_vars(v1, v2, v3, v4)
if __name__ == "__main__":
main()
Code:
Enter expression ("q" to quit): 2^57885161-1
k = 1, b = 2, n = 57885161, c = -1
Enter expression ("q" to quit): 2^1024+1
k = 1, b = 2, n = 1024, c = 1
Enter expression ("q" to quit): 19249 *2^ 13018586 + 1
k = 19249, b = 2, n = 13018586, c = 1
Enter expression ("q" to quit): q
Last fiddled with by ixfd64 on 2013-02-15 at 00:44 |
|
|
|
|
|
#2 |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
11100001101012 Posts |
Good luck using regular expressions in C.
|
|
|
|
|
|
#3 |
|
"Mark"
Apr 2003
Between here and the
11·577 Posts |
If you want to PRP, then use pfgw. For P+1/P-1/ecm, use GMP-ECM with gwnum. In fact, isn't there a GPU version of GMP-ECM?
Last fiddled with by rogue on 2013-02-15 at 02:06 |
|
|
|
|
|
#4 | |
|
Banned
"Luigi"
Aug 2002
Team Italia
481510 Posts |
Quote:
- The number to test should have less than 1017 bits. - The number of curves to do is locked to reach the best GPU performance (512 curves on my GTX580, 224 on lower cards). Luigi) |
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A Fib expression with multiplication | MattcAnderson | Homework Help | 5 | 2016-11-01 08:16 |
| Testing an expression for primality | 1260 | Software | 17 | 2015-08-28 01:35 |
| regular expression help | ixfd64 | Programming | 2 | 2009-03-01 06:19 |
| Does Anyone Know how to Simplify the Following Expression? | jinydu | Puzzles | 9 | 2004-04-02 01:03 |
| Can I do manual tests? | clowns789 | NFSNET Discussion | 3 | 2003-07-11 17:07 |