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

Implement all functions in #6148 except for 'pow' functions #8801

Closed
wants to merge 2 commits into from
Closed

Implement all functions in #6148 except for 'pow' functions #8801

wants to merge 2 commits into from

Conversation

jeffreyrogers
Copy link

Pretty much what the title says #6148 suggested adding several functions to Julia based on the IEEE-754 standard. All were possible to write with very brief, simple code. I didn't implement the pow functions, both because Julia provides exponentiation as an operator (rather than a function) and because some functionality will require #2976 to be completed first.

@@ -1 +1 @@
Subproject commit 5599b8cdbb369e1ab17d48ed7d9d60d5ee279a26
Subproject commit a12eb3329cd2c0224ef631ea062fa16d119da47c
Copy link
Contributor

Choose a reason for hiding this comment

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

this is going backwards, you don't want this included here - should put this back to 5599b8

submodules are annoying like this - next time you see a weird diff in a submodule, try doing git submodule update and it should go away

@tkelman
Copy link
Contributor

tkelman commented Oct 24, 2014

Thanks for the contribution. Looks like compound and rootn are using y in the signature but n in the calculation? New functions like this should have tests added, either in test/math.jl or a test file with a more specific name. While these are the basic generic implementations, it doesn't do much good to have them unless there are specialized more-accurate versions for common types like Float64. Some of these might be available in https://github.com/JuliaLang/openlibm but not yet exposed? Or that would be a natural place to add them if the specialized versions need to be implemented in assembly or C.

@jeffreyrogers
Copy link
Author

Yeah, you're right about compound and rootn. I can add tests, although I guess it won't do much good if they need specialized implementations. A quick glance at openlibm suggested they aren't implemented there, but I can probably write them. Assuming I (or someone else) does that, then you just have to use ccall in math.jl to expose them through Julia, right?

@kmsquire
Copy link
Member

Since some users use the system libm, it wouldn't be very useful to have
these only in libm.

On Friday, October 24, 2014, Jeffrey Rogers [email protected]
wrote:

Yeah, you're right about compound and rootn. I can add tests, although I
guess it won't do much good if they need specialized implementations. A
quick glance at openlibm suggested they aren't implemented there, but I can
probably write them. Assuming I (or someone else) does that, then you just
have to use ccall in math.jl to expose them through Julia, right?


Reply to this email directly or view it on GitHub
#8801 (comment).

@jeffreyrogers
Copy link
Author

Would implementing the functions in openlibm and falling back to the Julia versions if they aren't available be an acceptable way to handle that problem?

@JeffBezanson
Copy link
Member

The problem is that an implementation like log2(1+x) is not accurate enough to be useful. The reason these functions are specified in the standard is that they require special implementations that avoid computing 1+x.

@jeffreyrogers
Copy link
Author

Right, so assuming an accurate implementation is possible in openlibm, is it better to expose it even though some users won't be able to use the accurate implementation and will fall back to a pure Julia version or should it just be left out?

@JeffBezanson
Copy link
Member

I think it's better not to have it. If somebody understands these issues and specifically needs and uses log21p, there is no point in giving them the wrong answer.

@jeffreyrogers
Copy link
Author

Okay, that makes sense. I'll just close this issue then, since it doesn't look like there's much I can do.

@jeffreyrogers jeffreyrogers deleted the jdr/ieee-754 branch October 24, 2014 18:05
@tkelman
Copy link
Contributor

tkelman commented Oct 24, 2014

no point in giving them the wrong answer

Only for people who use system libm, right?

Maybe the best thing to do would be to try adding the specialized implementations to openlibm, and expose them with ccall via a package that specifically errors when it detects the user doesn't have a version of openlibm new enough to contain the specialized versions.

@kmsquire
Copy link
Member

If efficient C versions are to be coded up, it would probably be better to add them to https://github.com/JuliaLang/openspecfun. These were actually added to openlibm at one point, but then it was decided to attempt to maintain compatibility with system libm.

@tkelman
Copy link
Contributor

tkelman commented Oct 25, 2014

Oh yeah, duh, that is pretty much the point of having openspecfun be separate.

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.

4 participants