4.06.2013 - Version 0.3.4 - PIOBJECT() macro, ethernet improvement, documentation based on Doxygen
This commit is contained in:
28
pimath.h
28
pimath.h
@@ -96,16 +96,18 @@ inline double fromDb(double val) {return pow(10., val / 10.);}
|
||||
inline double toRad(double deg) {return deg * M_PI_180;}
|
||||
inline double toDeg(double rad) {return rad * M_180_PI;}
|
||||
|
||||
inline PIVector<double> abs(const PIVector<complexd> &v) {
|
||||
inline PIVector<double> abs(const PIVector<complexd> & v) {
|
||||
PIVector<double> result;
|
||||
result.resize(v.size());
|
||||
for(uint i=0; i<v.size(); i++) result[i] = abs(v.at(i));
|
||||
for (uint i = 0; i < v.size(); i++)
|
||||
result[i] = abs(v[i]);
|
||||
return result;
|
||||
}
|
||||
inline PIVector<double> abs(const PIVector<double> &v) {
|
||||
inline PIVector<double> abs(const PIVector<double> & v) {
|
||||
PIVector<double> result;
|
||||
result.resize(v.size());
|
||||
for(uint i=0; i<v.size(); i++) result[i] = abs(v.at(i));
|
||||
for (uint i = 0; i < v.size(); i++)
|
||||
result[i] = abs(v[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -117,7 +119,7 @@ class PIMathMatrixT;
|
||||
#define PIMV_FOR(v, s) for (uint v = s; v < Size; ++v)
|
||||
|
||||
template<uint Size, typename Type = double>
|
||||
class PIMathVectorT {
|
||||
class PIP_EXPORT PIMathVectorT {
|
||||
typedef PIMathVectorT<Size, Type> _CVector;
|
||||
public:
|
||||
PIMathVectorT() {resize(Size);}
|
||||
@@ -139,7 +141,7 @@ public:
|
||||
Type angleCos(const _CVector & v) const {Type tv = v.length() * length(); return (tv == Type(0) ? Type(0) : ((*this) ^ v) / tv);}
|
||||
Type angleSin(const _CVector & v) const {Type tv = angleCos(v); return sqrt(Type(1) - tv * tv);}
|
||||
Type angleRad(const _CVector & v) const {return acos(angleCos(v));}
|
||||
Type angleDeg(const _CVector & v) const {return toGrad(acos(angleCos(v)));}
|
||||
Type angleDeg(const _CVector & v) const {return toDeg(acos(angleCos(v)));}
|
||||
_CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
|
||||
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
||||
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
|
||||
@@ -207,7 +209,7 @@ typedef PIMathVectorT<4u, double> PIMathVectorT4d;
|
||||
#define PIMM_FOR_R(v) for (uint v = 0; v < Rows; ++v)
|
||||
|
||||
template<uint Cols, uint Rows = Cols, typename Type = double>
|
||||
class PIMathMatrixT {
|
||||
class PIP_EXPORT PIMathMatrixT {
|
||||
typedef PIMathMatrixT<Cols, Rows, Type> _CMatrix;
|
||||
typedef PIMathMatrixT<Rows, Cols, Type> _CMatrixI;
|
||||
typedef PIMathVectorT<Rows, Type> _CMCol;
|
||||
@@ -417,7 +419,7 @@ class PIMathMatrix;
|
||||
#define PIMV_FOR(v, s) for (uint v = s; v < size_; ++v)
|
||||
|
||||
template<typename Type>
|
||||
class PIMathVector {
|
||||
class PIP_EXPORT PIMathVector {
|
||||
typedef PIMathVector<Type> _CVector;
|
||||
public:
|
||||
PIMathVector(const uint size = 3) {resize(size);}
|
||||
@@ -440,7 +442,7 @@ public:
|
||||
Type angleCos(const _CVector & v) const {Type tv = v.length() * length(); return (tv == Type(0) ? Type(0) : ((*this) ^ v) / tv);}
|
||||
Type angleSin(const _CVector & v) const {Type tv = angleCos(v); return sqrt(Type(1) - tv * tv);}
|
||||
Type angleRad(const _CVector & v) const {return acos(angleCos(v));}
|
||||
Type angleDeg(const _CVector & v) const {return toGrad(acos(angleCos(v)));}
|
||||
Type angleDeg(const _CVector & v) const {return toDeg(acos(angleCos(v)));}
|
||||
_CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));}
|
||||
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; PIMV_FOR(i, 0) c[i] /= tv; return *this;}
|
||||
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
|
||||
@@ -499,7 +501,7 @@ typedef PIMathVector<double> PIMathVectord;
|
||||
#define PIMM_FOR_R(v) for (uint v = 0; v < rows_; ++v)
|
||||
|
||||
template<typename Type>
|
||||
class PIMathMatrix {
|
||||
class PIP_EXPORT PIMathMatrix {
|
||||
typedef PIMathMatrix<Type> _CMatrix;
|
||||
typedef PIMathVector<Type> _CMCol;
|
||||
typedef PIMathVector<Type> _CMRow;
|
||||
@@ -716,7 +718,7 @@ struct TransferFunction { // Для задания передаточной фу
|
||||
// Эйлера
|
||||
// Рунге-Кутта 4-го порядка
|
||||
// Адамса-Бэшфортса-Моултона 2, 3, 4 порядков
|
||||
class Solver
|
||||
class PIP_EXPORT Solver
|
||||
{
|
||||
public:
|
||||
enum Method {Global = -1,
|
||||
@@ -774,7 +776,7 @@ private:
|
||||
|
||||
|
||||
|
||||
class PIFFT
|
||||
class PIP_EXPORT PIFFT
|
||||
{
|
||||
public:
|
||||
PIFFT();
|
||||
@@ -827,7 +829,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class PIStatistic {
|
||||
class PIP_EXPORT PIStatistic {
|
||||
public:
|
||||
PIStatistic();
|
||||
bool calculate(const PIVector<double> &val);
|
||||
|
||||
Reference in New Issue
Block a user