Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
f02c2068
There was an error fetching the commit references. Please try again later.
Commit
f02c2068
authored
7 years ago
by
Daniel Simon
Browse files
Options
Downloads
Patches
Plain Diff
Draft of Double precision. TODO: double precision algorhitms, operators
parent
37f2d50d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TNL/Experimental/Arithmetics/Double.h
+56
-1
56 additions, 1 deletion
src/TNL/Experimental/Arithmetics/Double.h
src/TNL/Experimental/Arithmetics/Double_impl.h
+72
-1
72 additions, 1 deletion
src/TNL/Experimental/Arithmetics/Double_impl.h
with
128 additions
and
2 deletions
src/TNL/Experimental/Arithmetics/Double.h
+
56
−
1
View file @
f02c2068
...
...
@@ -3,4 +3,59 @@
* created: December 6, 2017 *
* author: Daniel Simon *
* mail: dansimon93@gmail.com *
***************************************************/
\ No newline at end of file
***************************************************/
namespace
TNL
{
template
<
class
T
>
class
Double
{
public:
T
data
[
2
];
Double
();
Double
(
const
Double
<
T
>&
value
);
explicit
Double
(
const
T
&
value
);
explicit
Double
(
int
value
);
Double
<
T
>&
operator
=
(
const
Double
<
T
>&
rhs
);
Double
<
T
>&
operator
-
();
Double
<
T
>&
operator
+
();
Double
<
T
>&
operator
+=
(
const
Double
<
T
>&
rhs
);
Double
<
T
>&
operator
-=
(
const
Double
<
T
>&
rhs
);
Double
<
T
>&
operator
*=
(
const
Double
<
T
>&
rhs
);
Double
<
T
>&
operator
/=
(
const
Double
<
T
>&
rhs
);
Double
<
T
>
operator
+
(
const
Double
<
T
>&
rhs
)
const
;
Double
<
T
>
operator
-
(
const
Double
<
T
>&
rhs
)
const
;
Double
<
T
>
operator
*
(
const
Double
<
T
>&
rhs
)
const
;
Double
<
T
>
operator
/
(
const
Double
<
T
>&
rhs
)
const
;
bool
operator
==
(
const
Double
<
T
>&
rhs
)
const
;
bool
operator
!=
(
const
Double
<
T
>&
rhs
)
const
;
bool
operator
<
(
const
Double
<
T
>&
rhs
)
const
;
bool
operator
>
(
const
Double
<
T
>&
rhs
)
const
;
bool
operator
>=
(
const
Double
<
T
>&
rhs
)
const
;
bool
operator
<=
(
const
Double
<
T
>&
rhs
)
const
;
explicit
operator
T
()
const
;
};
/// TODO
template
<
typename
T
>
void
zeroDouble
(
T
*
d
);
template
<
typename
T
>
void
twoSum
(
T
a
,
T
b
,
T
*
s
,
T
*
e
);
template
<
typename
T
>
void
quickTwoSum
(
T
a
,
T
b
,
T
*
s
,
T
*
e
);
template
<
typename
T
>
void
split
(
T
a
,
T
*
a_hi
,
T
*
a_lo
);
template
<
typename
T
>
void
twoProduct
(
T
a
,
T
b
,
T
*
p
,
T
*
e
);
template
<
typename
T
>
void
renormalize
(
T
*
a
,
T
*
b
);
template
<
typename
T
>
void
doubleAdd
(
const
T
*
a
,
const
T
*
b
,
T
*
s
);
template
<
typename
T
>
void
doubleMul
(
const
T
*
a
,
const
T
*
b
,
T
*
s
);
template
<
typename
T
>
void
printDouble
(
T
*
d
);
}
// namespace TNL
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/TNL/Experimental/Arithmetics/Double_impl.h
+
72
−
1
View file @
f02c2068
...
...
@@ -3,4 +3,75 @@
* created: December 6, 2017 *
* author: Daniel Simon *
* mail: dansimon93@gmail.com *
***************************************************/
\ No newline at end of file
***************************************************/
#include
<cmath>
#include
<cstdio>
#include
"Double.h"
namespace
TNL
{
template
<
class
T
>
Double
<
T
>::
Double
()
{
zeroDouble
(
data
);
}
template
<
class
T
>
Double
<
T
>::
Double
(
const
T
&
value
)
{
data
[
0
]
=
value
;
data
[
1
]
=
0
;
}
template
<
class
T
>
Double
<
T
>::
Double
(
int
value
)
{
data
[
0
]
=
(
T
)
value
;
data
[
1
]
=
0
;
}
template
<
class
T
>
Double
<
T
>::
Double
(
const
Double
<
T
>&
other
)
{
data
[
0
]
=
other
[
0
];
data
[
1
]
=
other
[
1
];
}
template
<
class
T
>
Double
<
T
>&
Double
<
T
>::
operator
=
(
const
Double
<
T
>&
rhs
)
{
data
[
0
]
=
rhs
[
0
];
data
[
1
]
=
rhs
[
1
];
return
*
this
;
}
template
<
class
T
>
Double
<
T
>
Double
<
T
>::
operator
+
(
const
Double
<
T
>&
rhs
)
const
{
Double
<
T
>
lhs
(
*
this
);
lhs
+=
rhs
;
return
qd
;
}
template
<
class
T
>
Double
<
T
>
Double
<
T
>::
operator
-
(
const
Double
<
T
>&
rhs
)
const
{
Double
<
T
>
lhs
(
*
this
);
lhs
+=
rhs
;
return
qd
;
}
template
<
class
T
>
Double
<
T
>
Double
<
T
>::
operator
*
(
const
Double
<
T
>&
rhs
)
const
{
Double
<
T
>
lhs
(
*
this
);
lhs
*=
rhs
;
return
qd
;
}
template
<
class
T
>
Double
<
T
>
Double
<
T
>::
operator
/
(
const
Double
<
T
>&
rhs
)
const
{
Double
<
T
>
lhs
(
*
this
);
lhs
/=
rhs
;
return
qd
;
}
/*
TODO COMPARISON OPERATORS
*/
}
// namespace TNL
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment