| #pragma once |
| |
| #ifndef TMATH_UTIL_H |
| #define TMATH_UTIL_H |
| |
| |
| #include "texception.h" |
| |
| #include <numeric> |
| |
| #ifndef __sgi |
| #include <cmath> |
| #else |
| #include <math.h> |
| #endif |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TNZCORE_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| enum TMathError { |
| INFINITE_SOLUTIONS = -1 |
| }; |
| |
| |
| |
| class DVAPI TMathException : public TException |
| { |
| TString m_msg; |
| |
| public: |
| TMathException(std::string msg); |
| virtual ~TMathException() {} |
| virtual TString getMessage() const { return m_msg; } |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI void tLUDecomposition(double *A, int n, int *indx, double &d); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI void tbackSubstitution(double *A, int n, int *indx, double *b); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI void tsolveSistem(double *A, int n, double *res); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| inline void tsolveSistem(std::vector<double> &A, std::vector<double> &res) |
| { |
| assert(res.size() * res.size() == A.size()); |
| tsolveSistem(&A[0], res.size(), &res[0]); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI double tdet(double *A, int n); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI double tdet(double *LUa, int n, double d); |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI int rootFinding(const std::vector<double> &poly, std::vector<double> &sol); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| inline bool isAlmostZero(double val, double eps = TConsts::epsilon) |
| { |
| return -eps < val && val < eps; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI int numberOfRootsInInterval(int order, const double *polyH, double min, double max); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI double cubicRoot(double a, double b, double c, double d); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| DVAPI double quadraticRoot(double a, double b, double c); |
| |
| |
| |
| #endif |
| |
| |
| |