Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Add a few more constructors/conversions #18

Merged
merged 1 commit into from
Oct 3, 2016
Merged

Add a few more constructors/conversions #18

merged 1 commit into from
Oct 3, 2016

Conversation

timholy
Copy link
Member

@timholy timholy commented Oct 3, 2016

These are a couple of things I noticed while playing with this package in the course of working on JuliaLang/julia#18777. Mostly I just wanted to say thanks for the package, I learned a lot from it and it was very useful as I played with different strategies.

FYI: if we do need to develop a faster pure-software implementation of lerpi that julia PR, then I think the main trick would be a SplitNumber{T} type that has already been passed through splitprec. Seems like the easiest way to develop that would be here in this package, and then possibly move a subset of the machinery to base. If I go that route, want it?

@simonbyrne simonbyrne merged commit 8cd85d6 into JuliaMath:master Oct 3, 2016
@simonbyrne
Copy link
Member

Thanks, I'm glad it's useful, I mostly wrote it while learning about the stuff myself.

It does seem like a good place to test things like that. Another reference is the https://github.com/JuliaMath/Libm.jl/blob/master/src/double.jl, which @musm has been working on.

@musm
Copy link

musm commented Oct 3, 2016

If you only need a few extra bits of precision this is good https://github.com/JuliaMath/Libm.jl/blob/master/src/double.jl , however it is only inteded for use internally in Libm.Sleef , for example none of the results are normalized, which if fine for the intended use case, but if you have many intermediate calculations the errors can blow up.

The files in the repo below are a lot cleaner and include fma versions of the elementary functions:
division, multiplication, sqrt, addition
https://github.com/musm/Doubles.jl/blob/master/src/Doubles.jl ( a lot of the basics where inspired from @simonbyrne DoubleDoube.jl )
and all the results are normalized.

@dpsanders
Copy link
Collaborator

That looks great, @musm. Is this basically a drop-in replacement for DoubleDouble.jl, then?
I went to a talk on double-word arithmetic the other day by a PhD student working with one of the world experts (Jean-Michel Muller). They have proven error bounds and have a couple of new / simplified algorithms:

https://ieeexplore.ieee.org/document/7118139/

This is the state of the art for double-word algorithms as far as I understand.

@musm
Copy link

musm commented Oct 3, 2016

@dpsanders Interesting paper I'll have to take a closer look later.

My Doubles.jl package, employs several hacks to Julia's promotion machinery (since Julia is not sophisticated enough to handle this use case) to gain efficiency. The trick is that we do not promote user values such as x = 1.1 to Double(1.1,0.0) (which is wasteful since you end up doing computations with zero in the low bit field) You can read the notes in the repo. But the cool thing is that 1.1*Double(1.0) automatically does the right thing and does not do wasteful operations with the zero bitfield.

At this point it's a prototype, already many things work, but due to do the promotion machinery hack, we do not have many fallbacks, which have to be manually written (This isn't really a disadvantage because for these cases we can write more efficient code to ignore the zero bit field)

In any case, double arithmetic is a little too slow on non fma systems, so I have to rework libm.jl.

@timholy timholy deleted the pull-request/1bfc0d07 branch October 5, 2016 08:54
This was referenced May 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants