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

Adding sin() function based on QD's implementation #1

Open
wants to merge 137 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
decdb4b
Commenting out Doxygen generation in CMakeLists.txt.
L30nardoSV Jan 23, 2024
5cee964
Starting to implement two<T> sin().
L30nardoSV Jan 23, 2024
08aa749
For single-precision: reduce the number of precised decimal digits do…
L30nardoSV Jan 23, 2024
56f722f
Adding implementation of nint().
L30nardoSV Jan 23, 2024
495a23a
Adding reference implementation.
L30nardoSV Jan 23, 2024
a976da8
Parameterizing nint()'s implementation + extra statements.
L30nardoSV Jan 23, 2024
4ebf104
Adding definition of <q>.
L30nardoSV Jan 23, 2024
97ca2b9
Adding definition of <t>.
L30nardoSV Jan 23, 2024
718f62d
Adding missing ;
L30nardoSV Jan 23, 2024
ec98814
Recalculation of <q>.
L30nardoSV Jan 23, 2024
fc9fd58
Definitions of <k> and <abs_k>.
L30nardoSV Jan 23, 2024
06b7948
Adding conditional possibly returning nan.
L30nardoSV Jan 23, 2024
6f0061b
Adding conditional (related to pi/16) possibly returning nan.
L30nardoSV Jan 23, 2024
5f7543d
Starting incorporating sin_taylor().
L30nardoSV Jan 23, 2024
f3d34f4
Adding prototype for sqr().
L30nardoSV Jan 23, 2024
b347a47
Adding implementation of two_sqr(). Missing implementation of split().
L30nardoSV Jan 23, 2024
959e99a
Adding split() function signature.
L30nardoSV Jan 23, 2024
3c8c66d
Adding split() implementation.
L30nardoSV Jan 23, 2024
bf73600
More implementation of sqr() untill call to quick_two_sum().
L30nardoSV Jan 23, 2024
91e42bb
Implementation of quick_two_sum().
L30nardoSV Jan 23, 2024
a868ea1
Completing sqr() implementation.
L30nardoSV Jan 23, 2024
e63594a
Extra statements.
L30nardoSV Jan 23, 2024
7e240cd
Completing preliminary implementation of sin_taylor().
L30nardoSV Jan 23, 2024
ce04319
Starting to incorporate cos_taylor() implementation.
L30nardoSV Jan 23, 2024
1cb051c
Minor fix.
L30nardoSV Jan 23, 2024
69d44d3
Adding implementation of mul_pwr2().
L30nardoSV Jan 23, 2024
f6e9e58
Completing implementation of cos_taylor().
L30nardoSV Jan 23, 2024
53f11cf
More of sin().
L30nardoSV Jan 23, 2024
8140ec2
Adding sin and cos tables for sin() implementation.
L30nardoSV Jan 23, 2024
0a3bd0d
Adding implementation of sincos_taylor().
L30nardoSV Jan 23, 2024
75d1293
Completing sin() implementation. It was not compiled yet.
L30nardoSV Jan 23, 2024
01817fa
Improve/remove comments.
L30nardoSV Jan 24, 2024
5ca0c17
Improving and correcting definitions of cos and sin tables.
L30nardoSV Jan 24, 2024
e7ba4f4
Fixing till split().
L30nardoSV Jan 24, 2024
78e1f10
Minor improvements.
L30nardoSV Jan 24, 2024
ce47dfe
Minor addition.
L30nardoSV Jan 24, 2024
c9dd711
Adding zeropointzero.
L30nardoSV Jan 24, 2024
fce6fd3
Adding missing return to sin_taylor() and cos_taylor().
L30nardoSV Jan 24, 2024
3c19973
Starting to add implementation of sqrt().
L30nardoSV Jan 24, 2024
1777f07
Addind dd_add().
L30nardoSV Jan 24, 2024
d98da80
Completing two_sum() implementation.
L30nardoSV Jan 24, 2024
e9939c8
Using ops for two<> types.
L30nardoSV Jan 24, 2024
057c25c
Using ops for two<> types.
L30nardoSV Jan 24, 2024
0e3e8cc
Commenting out std::error + fixing syntax.
L30nardoSV Jan 24, 2024
10b124f
Replacing most commented-out std::error with static_assert().
L30nardoSV Jan 24, 2024
060d44c
Remove <pair-arithmetic.test.cpp from test series.>
L30nardoSV Jan 24, 2024
d38ee32
Starting to add a very simple test function for sin().
L30nardoSV Jan 24, 2024
bb18240
Starting to add very simple test to sin()
L30nardoSV Jan 24, 2024
4d86992
Starting to call two<T> sin(). It fails compilation.
L30nardoSV Jan 24, 2024
1daf666
Starting to fix implementation using compiler info.
L30nardoSV Jan 25, 2024
33f420a
Creating the namespace qd and moving some functions into it.
L30nardoSV Jan 25, 2024
cb43c9f
Fixing namespace.
L30nardoSV Jan 25, 2024
d149699
Calling div<> with Accurate and FMA options enabled.
L30nardoSV Jan 25, 2024
96c6f0d
Fixing sub by adding mode (Accurate). Code compiles successfully so far.
L30nardoSV Jan 25, 2024
22f41ae
Enabling more compiling code.
L30nardoSV Jan 25, 2024
8bbd5fb
Enabling more compiling code.
L30nardoSV Jan 25, 2024
918d520
Enabling more compiling code.
L30nardoSV Jan 25, 2024
d43745f
Enabling more compiling code.
L30nardoSV Jan 25, 2024
679b266
Enabling more compiling code.
L30nardoSV Jan 25, 2024
3c0861e
Enabling more compiling code.
L30nardoSV Jan 25, 2024
57e85cf
Enabling more compiling code.
L30nardoSV Jan 25, 2024
144c5f3
Enabling more code. This requires a fix within sin_taylor() and cos_t…
L30nardoSV Jan 25, 2024
83a8c5d
Adding const type for pointer.
L30nardoSV Jan 25, 2024
372efdc
Starting to fix sin_taylor().
L30nardoSV Jan 25, 2024
c2df2cb
Starting to fix sin_taylor().
L30nardoSV Jan 25, 2024
b90c1d8
Improvements for sin_taylor().
L30nardoSV Jan 25, 2024
f4cc3f2
Improvements for sin_taylor().
L30nardoSV Jan 25, 2024
fe76153
Improvements for sin_taylor().
L30nardoSV Jan 25, 2024
e7da4fd
Improvements in cos_taylor().
L30nardoSV Jan 25, 2024
044981c
Improvements in cos_taylor().
L30nardoSV Jan 25, 2024
1116d84
Improvements in cos_taylor().
L30nardoSV Jan 25, 2024
46b7581
Improvements in cos_taylor().
L30nardoSV Jan 25, 2024
35a0b62
Improvements in cos_taylor().
L30nardoSV Jan 25, 2024
8f8c435
More fixes in sin().
L30nardoSV Jan 30, 2024
02e3009
More fixes in sin().
L30nardoSV Jan 30, 2024
2a3f6c9
More fixes in sin().
L30nardoSV Jan 30, 2024
74c0ff4
Partly fixing sincos_taylor().
L30nardoSV Jan 30, 2024
84e8642
Partly fixing sqrt().
L30nardoSV Jan 30, 2024
52795d4
Fixes in sqrt().
L30nardoSV Jan 30, 2024
e9e2159
More fixes in sqrt().
L30nardoSV Jan 30, 2024
32eceef
Fixing add().
L30nardoSV Jan 30, 2024
077eadc
Fixing sin().
L30nardoSV Jan 30, 2024
2f2c346
More fixes in sin().
L30nardoSV Jan 30, 2024
73c3976
More fixes in sin().
L30nardoSV Jan 30, 2024
1c907a5
More fixes in sin().
L30nardoSV Jan 30, 2024
e987e89
Completing simple SinTest().
L30nardoSV Jan 30, 2024
466aaa7
Additional hints for inspecting testing.
L30nardoSV Jan 30, 2024
b3ce7ef
Adding SinTest2 for specifically testing double-precision sin().
L30nardoSV Jan 30, 2024
7269ef5
Parameterizing returning type of nint().
L30nardoSV Jan 30, 2024
abec02f
Minor cleanup.
L30nardoSV Jan 30, 2024
1aa48f5
Cleaning up.
L30nardoSV Jan 30, 2024
8353d1c
Fixing return value.
L30nardoSV Jan 30, 2024
ce7b4d5
Uniform return value.
L30nardoSV Jan 30, 2024
34dd5f2
Adding print features to debug sin(). This changes are mirrowed from …
L30nardoSV Feb 1, 2024
ef196cf
More printing.
L30nardoSV Feb 1, 2024
ca8274c
Fixing error messages.
L30nardoSV Feb 1, 2024
23ab1e3
More printing.
L30nardoSV Feb 1, 2024
82a33c8
More printing.
L30nardoSV Feb 1, 2024
865bd26
More printing.
L30nardoSV Feb 1, 2024
61bdaf4
Fixing implementation of sin().
L30nardoSV Feb 2, 2024
33636c7
REplacing EXPECT_NEAR with EXPECT_FLOAT_EQ and EXPECt_DOUBLE_EQ.
L30nardoSV Feb 2, 2024
0a17138
Commenting out some helper code.
L30nardoSV Feb 2, 2024
e502837
Replacing std::cerr with static_assert in some cases.
L30nardoSV Feb 6, 2024
7b7fb91
Removing remaining std::cerr instances. Instead adding warning commen…
L30nardoSV Feb 6, 2024
dac3be1
Replacing calls to qd::quick_two_sum() with already implemented twofl…
L30nardoSV Feb 6, 2024
322ac49
Removing implementation of qd::quick_two_sum(). This is not needed as…
L30nardoSV Feb 6, 2024
e96936d
Replacing calls to qd::split() with already-implemented twofloat::alg…
L30nardoSV Feb 6, 2024
5301ded
Removing definition of qd::split(). This is not needed anymore as sam…
L30nardoSV Feb 6, 2024
3dd021e
Removing definition and replacing invocations of to_double(A) with A.…
L30nardoSV Feb 6, 2024
c29ad7b
Commenting out unnecessarily compute-intensive assignments to 0.0.
L30nardoSV Feb 6, 2024
28d95dd
Removing commented-out code from previous commit.
L30nardoSV Feb 6, 2024
97a9980
Replacing fp32/fp64_sin_table and cos_table with templated struct mem…
L30nardoSV Feb 7, 2024
29d8359
Moving inv_factor into templated struct.
L30nardoSV Feb 7, 2024
652ccf2
Templating 2pi constant.
L30nardoSV Feb 7, 2024
80d36af
Templating pi2.
L30nardoSV Feb 7, 2024
dcfc61f
Templating pi16.
L30nardoSV Feb 7, 2024
ed16c79
Templating nan.
L30nardoSV Feb 7, 2024
5d3de1c
Templating eps.
L30nardoSV Feb 7, 2024
6efcb93
Removing unnecessary constants.
L30nardoSV Feb 7, 2024
3b3ab43
Compacting code.
L30nardoSV Feb 7, 2024
e48dc0d
Renaming struct.
L30nardoSV Feb 7, 2024
3ffd66c
Defining and using templated variable pointfive.
L30nardoSV Feb 7, 2024
800b777
Defining and using templated variable twopointzero.
L30nardoSV Feb 7, 2024
aaf8057
Defining and using templated variable zeropointzero.
L30nardoSV Feb 7, 2024
9e1e0be
Defining and using templated variable onepointzero.
L30nardoSV Feb 7, 2024
8b940f4
Moving definition of nint() outside qd namespace. Note that nint() is…
L30nardoSV Feb 7, 2024
2d7c5e4
Moving definition of two_sqr() outside qd namespace.
L30nardoSV Feb 7, 2024
84ef266
Moving definition of two_sum() outside qd namespace.
L30nardoSV Feb 7, 2024
ab0c884
Additional comment.
L30nardoSV Feb 7, 2024
50b5eda
Moving definition of sqr() outside dd_real namespace.
L30nardoSV Feb 7, 2024
2421180
Moving definition of add() outside dd_real namespace. Note that such …
L30nardoSV Feb 7, 2024
608bbda
Minor removals.
L30nardoSV Feb 7, 2024
274696b
Cleaning up.
L30nardoSV Feb 7, 2024
59e215d
Parameterizing the mode and useFMA for sin().
L30nardoSV Feb 7, 2024
912281b
Minor cleanup.
L30nardoSV Feb 7, 2024
abe7664
More clarifications.
L30nardoSV Feb 7, 2024
f1811d8
Documenting with /// \brief as much as possible.
L30nardoSV Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding implementation of sincos_taylor().
L30nardoSV committed Jan 23, 2024
commit 0a3bd0d8ff76b1f61eec1273e95fdd299f9b9d0a
24 changes: 24 additions & 0 deletions include/libtwofloat/arithmetics/double-word-arithmetic.hpp
Original file line number Diff line number Diff line change
@@ -527,6 +527,30 @@ static two<T> cos_taylor(const two<T> &input) {
} while (i < n_inv_fact && std::abs(to_double(t)) > thresh);
}

template <typename T>
static void sincos_taylor(const two<T> &input, two<T> &sin_a, two<T> &cos_a) {

T zeropointzero, onepointzero;
if constexpr (std::is_same_v<T, float>) {
zeropointzero = 0.0f;
onepointzero = 1.0f
} else if constexpr (std::is_same_v<T, double>) {
zeropointzero = 0.0;
onepointzero = 1.0;
} else {
std::error("LSV: other types are unsupported"); // TODO: make sure std::error is best way to proceed here
}

if (input.is_zero()) {
sin_a = zeropointzero;
cos_a = onepointzero;
return;
}

sin_a = sin_taylor(input);
cos_a = sqrt(onepointzero - sqr(sin_a));
}

// Reference: QD / dd_real.cpp
template <typename T>
inline two<T> sin(const two<T> &input) {