10#include <qgenericmatrix.h>
71template<
int N,
int M,
typename T,
typename... Args>
76 static_assert(
sizeof...(args) == N * M,
"Invalid number of arguments.");
77 const T valueArray[] = {args...};
81SquareMatrix3 createSquareMatrix3(
double r0c0,
double r0c1,
double r0c2,
double r1c0,
double r1c1,
double r1c2,
double r2c0,
double r2c1,
double r2c2);
83Trio createTrio(
double first,
double second,
double third);
85int decimalPlaces(
const int rangeMax,
const int significantFigures);
87std::optional<SquareMatrix3> inverseMatrix(
const SquareMatrix3 &matrix);
97[[nodiscard]]
constexpr bool isInRange(
const T &low,
const T &x,
const T &high)
106 (low <= x) && (x <= high)
119[[nodiscard]]
constexpr bool isOdd(
const T &number)
121 static_assert(std::is_integral_v<T>,
122 "Template isOdd() only works with integer types.");
124 return static_cast<bool>(
number % two);
151[[nodiscard]]
constexpr bool isNearlyEqual(T a, T b, T epsilon)
154 std::is_floating_point<T>::value,
155 "Template isNearlyEqual(T a, T b, T epsilon) only works with floating point types");
158 const auto actualEpsilon =
159 qMax(std::numeric_limits<T>::epsilon(), epsilon);
161 if ((a == b) && (!std::isnan(epsilon))) {
167 const auto norm = qMin<T>(
169 std::numeric_limits<T>::max());
170 return std::abs(a - b) < std::max(actualEpsilon, actualEpsilon * norm);
187template<
typename A,
typename B>
188[[nodiscard]]
constexpr bool isNearlyEqual(A a, B b)
191 std::is_floating_point<A>::value,
192 "Template isNearlyEqual(A a, B b) only works with floating point types");
194 std::is_floating_point<B>::value,
195 "Template isNearlyEqual(A a, B b) only works with floating point types");
218 constexpr auto factor = 100;
222 if constexpr (
sizeof(A) >
sizeof(B)) {
223 return PerceptualColor::isNearlyEqual<A>(
226 static_cast<A
>(std::numeric_limits<B>::epsilon() * factor));
228 return PerceptualColor::isNearlyEqual<B>(
231 static_cast<B
>(std::numeric_limits<A>::epsilon() * factor));
252T normalizedAngle360(T value)
255 std::is_floating_point<T>::value,
256 "Template normalizeAngle360() only works with floating point types");
258 constexpr T max = 360;
259 qreal temp = fmod(value, max);
280void normalizePolar360(T &radius, T &angleDegree)
284 angleDegree = normalizedAngle360(angleDegree + 180);
286 angleDegree = normalizedAngle360(angleDegree);
299[[nodiscard]]
constexpr T roundToDigits(T value,
int precision)
302 std::is_floating_point<T>::value,
303 "Template roundToDigits() only works with floating point types");
304 const T multiplier = std::pow(
308 return std::round(value * multiplier) / multiplier;
KIOCORE_EXPORT QString number(KIO::filesize_t size)
The namespace of this library.
int decimalPlaces(const int rangeMax, const int significantFigures)
Calculates the required number of decimals to achieve the requested number of significant figures wit...