floating point arithmetics computing in quadruple precision

I try to use quadruple precision using the well know "double double" approach. Many operations seems correct however some results are wrong. To operate correctly it is necessary to avoid access 80bits register. Is it the case when running Matlab. Furthermore it would be very useful to use FMA operations which are available for AMD and Intel processors (FMA3). How to use these functions within Matlab.
Among strange results I cannot compute 1/6 with 31 correct digits. Perhaps because using double precision 6*(1/6)=1 exactly although 1/6 = 1.666666666666667e-01!!
Best regards

9 件のコメント

Walter Roberson
Walter Roberson 2021 年 6 月 25 日
How are you using double double? Could you give a sample code segment in which you do a quadruple precision operation?
Alain Barraud
Alain Barraud 2021 年 6 月 25 日
See the attached files for basic operations
Alain
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
Interesting.
You have an oddity in division. You have
[chi,clo]=FastToSum(th,tl);
Notice this is not FastTwoSum
Alain Barraud
Alain Barraud 2021 年 6 月 25 日
the other files to compute quadruple division
alain
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
編集済み: Walter Roberson 2021 年 6 月 25 日
The only operation that I recall as being documented as using the 80 bit operations, is division of 64 bit integers, which is documented as involving conversion to 80 bit doubles.... somewhere. Ah, not exactly; https://www.mathworks.com/help/matlab/matlab_prog/integers.html
Alain Barraud
Alain Barraud 2021 年 6 月 25 日
Yes I know fp128 class but it seems unpublished. About FastToSum it is a typo error I have both function and I have renamed some of them to have their standard name.
If floating point operations does not use 80bits registers the basic double double operations would run correctly.
and FMA ?
Aain
Alain Barraud
Alain Barraud 2021 年 6 月 25 日
I'll look at your ref, I know xsum. It seems that the cleve code is available today. In the past it says that it was too slow to be useful.
Thanks a lot for your answers
alain
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
Linking this for further reading when I am less tired

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2021 年 6 月 25 日

0 投票

In Matlab 6.5 you could control the usage of the 80 bit registers:
% [UNTESTED in modern Matlab versions]
system_dependent('setprecision', 64) % Enable 80 bit registers
system_dependent('setprecision', 53) % Disable
At least on Intel CPUs using 64 bit registers was the default. I've experimented with this for XSum and a stable ACOS algorithm.
This might work also:
feature('SetPrecision', 64) % [UNTESTED in modern Matlab versions]

3 件のコメント

Alain Barraud
Alain Barraud 2021 年 6 月 25 日
r=feature('SetPrecision') gives 53 the situation by default (last matlab release)
feature('SetPrecision',64) set precision to 64 i.e. 80 bits register used
r=feature('SetPrecision') now gives 64
I don't understand why my double double does not work correctly.
alain
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
Current MATLAB still accepts setprecision for system_dependent() and feature() . Whether it matters is a different question.
If I recall correctly, setprecision had no effect on calculations that were punted over to the high-speed libraries.. and also IIRC, the precision was reset at unpredicable times (because it was a change to the FCW and MATLAB assumed it was not necessary to preserve the FCW.)
Alain Barraud
Alain Barraud 2021 年 6 月 26 日
OK thanks

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

製品

リリース

R2021a

質問済み:

2021 年 6 月 25 日

コメント済み:

2021 年 6 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by