Skip to content

changed seed to make nth-root usable #189

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

Merged
merged 2 commits into from
Apr 6, 2019

Conversation

czurnieden
Copy link
Contributor

Old implementation made it unusable, especially for tests for (perfect) power which test all prime indices up to log_2(n). This patch does not change the API. It increases the binary size by ca. 450 bytes, about 16%.

@sjaeckel sjaeckel requested a review from minad April 2, 2019 21:33
Copy link
Member

@sjaeckel sjaeckel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good besides that one comment

@sjaeckel sjaeckel added this to the v1.1.1 milestone Apr 2, 2019
@sjaeckel
Copy link
Member

sjaeckel commented Apr 4, 2019

While rebasing I took the liberty to take the #190 (comment) of @minad into account

* 7695055368100873513971520489282333897557005032980617084180385070\
* 39530690836861445204045548919181252491201760744537260787 x
*/
"4n9cbk886QtLQmofprid3l2Q0GD8Yv979Lh8BdZkFE8g2pDUUSMBET/+M/YFyVZ3mBp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you writing the numbers in base64 and add them in decimal as a comment? Either write them only in base64 or just write them in decimal which I would prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you writing the numbers in base64 and add them in decimal as a comment?

For the same reason I left the tracing puts("DDD") in it ;-)

I calculated them in Pari/gp and converted them later with an external program to shorten the code lines. It was just a list that I ticked off (the little "x" at the end of the decimal numbers is that tick), not meant as a translation.

[...] or just write them in decimal which I would prefer.

I just don't like the overly long lines (not every compiler accepts string constants in multiple parts). OCD maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but you can also split the decimal constants?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wat? I didn't read. Not every compiler supports multiple string constants?! Those are unsupported. I hardly believe that tommath would compile with such a thing since it is quite common practice to stringize and concatenate in macros.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not every compiler supports multiple string constants?

No, " multiple string constants " is not the right nomenclature, I mean things like this, taking printf as an example

printf( "this shall mimic a %s long "
          "line, cut in %c\n", "very", '2');

I vividly remember all the curses I uttered, although it was a long time ago. Nevertheless:

Those [compilers] are unsupported.

The documentation has no restrictions in that regard. It includes the old Borland C compiler and even MSVC is supported. We should set some strict limits, e.g (versions #s arbitrary): GCC > 3, clang > 3.5, MSVC > 2012, icc > 19 and so on (mingw, djgpp, …), document them and test them. The exact version #s are open for discussion, of course. But not here, I think it deservers its own thread, pardon, issue.

Copy link
Member

@minad minad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@czurnieden Could you describe a bit more clearly what issue is being solved here? Is there a convergence problem with the old seed?

demo/test.c Outdated
@@ -1284,7 +1284,8 @@ static int test_mp_incr(void)
goto LTM_ERR;
}
a.sign = MP_ZPOS;
if (mp_cmp_d(&a, MP_MASK) != MP_EQ) {puts("DDD");
if (mp_cmp_d(&a, MP_MASK) != MP_EQ) {
puts("DDD");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DDD

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DDDaumen hoch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To paraphrase @sjaeckel : I should have gone to bed a long time before that! ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DDDaumen hoch

@czurnieden
Copy link
Contributor Author

Could you describe a bit more clearly what issue is being solved here? Is there a convergence problem with the old seed?

The old seed makes it abysmally slow. It is just not usable with that seed. See this "paper" for some illustrated details.

@czurnieden
Copy link
Contributor Author

Uhm, can somebody here tell me what Travis was about to tell me but didn't?

@sjaeckel
Copy link
Member

sjaeckel commented Apr 4, 2019

Uhm, can somebody here tell me what Travis was about to tell me but didn't?

oops is your confusion caused by me canceling the build job? :)

@czurnieden
Copy link
Contributor Author

czurnieden commented Apr 4, 2019

oops is your confusion caused by me canceling the build job? :)

Well, as someone who broke the build not only once… ;-)

What is it "Conflicting files demo/test.c"? Ah, I see, have already resolved it while applying @minad 's suggestions, just waiting for the local tests to finish to push it.

EDIT: The program used to convert the numbers used in teh test for n-root is at https://gist.github.com/czurnieden/b55b09f768fb45db58f3b65b07b2f7b1 now

@czurnieden
Copy link
Contributor Author

@minad

Could you describe a bit more clearly what issue is being solved here?

A concrete example is #201

timings of the isolated mp_expt test which checks the result of mp_expt by checking the root.

with orig. n-root: killed after 75 minutes
with bugfix-n-root: 2.5 seconds
with spaceforspeed[1]: 0.35 seconds

[1] found a bug in that version, fix not yet pushed but used in that test

@sjaeckel
Copy link
Member

sjaeckel commented Apr 6, 2019

as you're online @czurnieden I'd say we start with this branch to be rebased and then merged next ...or #204 ...whoever is faster

@sjaeckel
Copy link
Member

sjaeckel commented Apr 6, 2019

can you please squash those fixup commits together and force-push?

the "workaround" commit should stay so it can be reverted in #207

@czurnieden
Copy link
Contributor Author

those fixup commits together

@sjaeckel Argh, only the fixes you said. Sorry, squashed too much, I'm afraid.

@sjaeckel
Copy link
Member

sjaeckel commented Apr 6, 2019

@sjaeckel Argh, only the fixes you said. Sorry, squashed too much, I'm afraid.

perfect like that

@sjaeckel sjaeckel merged commit ec4149d into libtom:develop Apr 6, 2019
@czurnieden czurnieden deleted the bugfix-n-root branch April 7, 2019 20:49
@sjaeckel sjaeckel removed this from the v1.1.1 milestone Sep 9, 2019
@sjaeckel sjaeckel added this to the next milestone Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants