diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2017-02-19 17:43:26 +0100 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2017-02-19 17:43:26 +0100 |
commit | 133ebfc83414c4aa0e8fce9f6f7b9d43e6774380 (patch) | |
tree | 572c3754bac2522328d3653766c0a2267843553c /src | |
parent | c248f900c036e1d1644e2cc744c45c94f61c5835 (diff) |
Added data-preparation function for the TRSV tests and special nan/inf checks in the error checking to make the tests pass
Diffstat (limited to 'src')
-rw-r--r-- | src/utilities/utilities.cpp | 9 | ||||
-rw-r--r-- | src/utilities/utilities.hpp | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/utilities/utilities.cpp b/src/utilities/utilities.cpp index fd198c0d..b2ed2f0c 100644 --- a/src/utilities/utilities.cpp +++ b/src/utilities/utilities.cpp @@ -18,6 +18,7 @@ #include <chrono> #include <random> #include <iomanip> +#include <cmath> namespace clblast { // ================================================================================================= @@ -118,6 +119,14 @@ double2 ConstantNegOne() { return {-1.0, 0.0}; } +// Returns the absolute value of a scalar +template <typename T> T AbsoluteValue(const T value) { return std::fabs(value); } +template float AbsoluteValue<float>(const float); +template double AbsoluteValue<double>(const double); +template <> half AbsoluteValue(const half value) { return FloatToHalf(std::fabs(HalfToFloat(value))); } +template <> float2 AbsoluteValue(const float2 value) { return std::abs(value); } +template <> double2 AbsoluteValue(const double2 value) { return std::abs(value); } + // ================================================================================================= // Implements the string conversion using std::to_string if possible diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp index 757f1b5e..2c13658b 100644 --- a/src/utilities/utilities.hpp +++ b/src/utilities/utilities.hpp @@ -114,6 +114,10 @@ T ConstantOne(); template <typename T> T ConstantNegOne(); +// Returns the absolute value of a scalar +template <typename T> +T AbsoluteValue(const T value); + // ================================================================================================= // Structure containing all possible arguments for test clients, including their default values |