5 #include "platform_global.h"
6 #include <memoryheap.h>
9 #include <QVariantList>
11 #include <QtAlgorithms>
19 typedef std::complex<double> CPLX;
21 #define THRESHOLD 1E-6
25 enum COMPOSITION { PEAK, INTEGRATE, PEAK_AVG, TROUGH };
38 template <
typename InputIterator,
typename OutputIterator>
39 inline OutputIterator
vCopy(InputIterator begin, InputIterator end, OutputIterator dest)
54 template <
typename BiIterator1,
typename BiIterator2>
55 inline BiIterator2
vCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 dest)
70 template <
typename InputIterator1,
typename InputIterator2>
71 inline bool vEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
73 for (; first1 != last1; ++first1, ++first2)
74 if (!(*first1 == *first2))
87 void VCast(
const VremVArray &si1, T *dst)
90 for( i = 0; i < si1.size(); ++i)
92 dst[i] = si1[i].value<T>();
104 void VCast(
const QVariantList &si1, T *dst)
107 for( i = 0; i < si1.size(); ++i)
109 dst[i] = si1[i].value<T>();
121 template <
typename ForwardIterator,
typename T>
122 inline void vFill(ForwardIterator first, ForwardIterator last,
const T &val)
124 for (; first != last; ++first)
135 template <
typename Container,
typename T>
136 inline void vFill(Container &container,
const T &val)
138 vFill(container.begin(), container.end(), val);
152 static QVariant DefaultValue(
155 QVariant defaultValue =
"",
156 bool ignorKeyCase =
true);
159 static QVariant DefaultValue(
162 QVariant defaultValue =
"",
163 bool ignorKeyCase =
true);
166 static QVariant DefaultValue(
169 QVariant defaultValue =
"",
170 bool ignorKeyCase =
true);
173 static bool Contains(QString pattern, QVariant src,
bool ignorKeyCase =
true);
176 static QVariant Normalize(
const QString str );
210 static void Inc(VremVArray &i1,
int count = -1,
int index = 0);
218 static void Dec(VremVArray &i1,
int count = -1,
int index = 0);
226 static void Atan(VremVArray &i1,
int count = -1,
int index = 0);
234 static void AtanH(VremVArray &i1,
int count = -1,
int index = 0);
242 static void Cos(VremVArray &i1,
int count = -1,
int index = 0);
250 static void CosH(VremVArray &i1,
int count = -1,
int index = 0);
258 static void ACos(VremVArray &i1,
int count = -1,
int index = 0);
266 static void Sin(VremVArray &i1,
int count = -1,
int index = 0);
274 static void SinH(VremVArray &i1,
int count = -1,
int index = 0);
282 static void Tan(VremVArray &i1,
int count = -1,
int index = 0);
290 static void TanH(VremVArray &i1,
int count = -1,
int index = 0);
293 static void Log(VremVArray &i1,
int count = -1,
int index = 0);
301 static void Exp(VremVArray &i1,
int count = -1,
int index = 0);
309 static void Sqrt(VremVArray &i1,
int count = -1,
int index = 0);
317 static void Fabs(VremVArray &i1,
int count = -1,
int index = 0);
325 static void Floor(VremVArray &i1,
int count = -1,
int index = 0);
332 static void Rev(VremVArray &i1,
int index = 0);
339 static void Rrl(VremVArray &i1,
int index = 0);
346 static void Rrr(VremVArray &i1,
int index = 0);
355 static void Fill(VremVArray &i1, QVariant with,
int count = -1,
int index = 0);
364 static QVariant Highest(
const VremVArray &i1,
int count = -1,
int index = 0);
374 static QVariant Highest(
const VremVArray &i1, QVariant except,
int count = -1,
int index = 0);
383 static QVariant Lowest(
const VremVArray &i1,
int count = -1,
int index = 0);
393 static QVariant Lowest(
const VremVArray &i1, QVariant except,
int count = -1,
int index = 0);
402 static QVariant Mean (
const VremVArray &i1,
int count = -1,
int index = 0);
412 static QVariant Mean (
const VremVArray &i1, QVariant except,
int count = -1,
int index = 0);
421 static QVariant Mean (
const QVariantList &i1,
int count = -1,
int index = 0);
431 static QVariant Mean (
const QVariantList &i1, QVariant except,
int count = -1,
int index = 0);
441 static QVariant Sum (
const VremVArray &i1,
int count = -1,
int index = 0);
451 static QVariant Sum (
const VremVArray &i1, QVariant except,
int count = -1,
int index = 0);
477 ,
const VremVArray &s1
491 unsigned int ms =
static_cast<unsigned>(QDateTime::currentMSecsSinceEpoch());
492 std::mt19937 gen(ms);
493 std::uniform_int_distribution<> uid(min, max);
505 static QVariant ComputerVar (
const VremVArray &i1,
int count = -1,
int index = 0);
514 static QVariant ComputerVarNZ (
const VremVArray &i1,
int count = -1,
int index = 0);
527 static int check_bounds(
double left,
double right,
int start,
int end,
int invert );
530 static bool map_doubles (
539 double total_s_width,
542 COMPOSITION composition,
550 const VremVArray &s );
556 static void FFT(VremVArray &s);
565 static bool IdenticalArray(
const VremVArray i1,
const VremVArray i2);
572 static QByteArray ConvertToStream(
const VremVArray &i1);
580 static VremVArray ConvertToVremVArray(QByteArray &stream);
587 static VremVArray ConvertToVremVArray(QVariantList &lst);
594 static QVariantList ConvertToQVariantList(QByteArray &stream);
601 static QVariantList ConvertToQVariantList(VremVArray &varray);
611 QString ptrStr = QString(
"0x%1").arg(
reinterpret_cast<quintptr
>(ptr),
612 QT_POINTER_SIZE * 2, 16, QChar(
'0'));
634 double temp = x.toDouble();
638 temp = temp * x.toDouble();
653 QVariant
poly(QVariant x,
int degree, QVariantList coeff)
665 value = value + coeff[degree].toDouble();
690 regression_clear(REGRESSION *rg);
720 regression_accumulator(REGRESSION *rg,
double x,
double y);
735 regression_compute(REGRESSION *rg);
754 correlation_compute(REGRESSION *rg);
862 bool setStep ( QVariant stepSize );
866 bool forward (
void ) {
return direction == Forward; }
871 virtual bool insertValue (
const QVariant v,
const QVariant vA);
874 virtual bool insertAValue (
const QVariant v );
877 virtual void flushValue (
void );
896 QVarLengthArray<int> N;
909 VremVArray GetValues()
916 VremVArray mean( array.size());
917 for(
int i = 0; i < array.size() && i < mean.size() && i < N.size(); ++i)
921 mean[i] = array[i].toDouble() /
static_cast<double>(NN);
928 void AddValues( VremVArray &v)
935 std::fill(N.begin(), N.end(),
static_cast<int>(1));
943 for(
int i = 0; i < v.size(); ++i)
945 if( i < array.size() && i < N.size())
948 array[i] = array[i].toDouble() + v[i].toDouble();
952 array.push_back(v[i]);
997 return Sum /
static_cast<T
>(_N);
1016 QStringList listOfMySubnet;
1024 int network, broadcast, range;
1025 QString NetworkAddress, BroadCastAddress;
1027 QString IpAddress = ip;
1028 QString NetMask = mask;
1031 int cIP = IpAddress.lastIndexOf(
'.');
1034 int nMsk = NetMask.lastIndexOf(
'.');
1037 if ( cIP == -1 || nMsk == -1)
1045 int cMask = NetMask.mid(nMsk + 1).toInt();
1046 int classC = IpAddress.mid(cIP + 1).toInt();
1049 QString classB = NetworkAddress = BroadCastAddress = IpAddress.left(cIP + 1);
1060 range = (255 - cMask) + 1;
1061 network = (classC & cMask) & 0xff;
1062 broadcast = network + (range -1);
1067 QVariant v(broadcast);
1068 BroadCastAddress += v.toString();
1072 QVariant v(network);
1073 NetworkAddress += v.toString();
1077 for (
int i = network; i < network + range; ++ i)
1080 QString ipInSubnet = classB + v.toString();
1081 listOfMySubnet.push_back(ipInSubnet);
1090 return listOfMySubnet;
1097 if (listOfMySubnet.size() )
1098 return listOfMySubnet[0];
1105 if (listOfMySubnet.size() )
1106 return listOfMySubnet[listOfMySubnet.size() -1 ];
class DbxDistributionFilter DbxDistributionFilter is a simple class for online filtering of non-equid...
Definition: algo.h:811
Direction direction
we'll need to know about the direction of filtering in order to properly assign the axis....
Definition: algo.h:825
double TotalValue
total value so far of the element currently being calculated..
Definition: algo.h:840
Direction
we'll need to know which direction we're going in order for proper axis and boundary calculations....
Definition: algo.h:818
bool forward(void)
return true if the actual filtering direction is forward..
Definition: algo.h:866
double StartVAxis
starting boundary of the element currently being calculated..
Definition: algo.h:837
bool WaitForValue
wait for the next value after we had reached exactly the edge of the previous one....
Definition: algo.h:831
bool WaitForFirst
wait for the first data point after construction or after reversing filtering direction....
Definition: algo.h:828
double LastVAxis
last value axis from the previous insertion of a value (pair)..
Definition: algo.h:843
double VAxisStep
step size of the output axis / coordinates, default is 1, e.g. 1 databox, or 1 second....
Definition: algo.h:834
virtual void interpolatedValue(const QVariant value, const QVariant vAxis)
virtual function for a new filtered value pair, will be called as soon as a new value pair could be c...
Definition: algo.h:880
QVariant step(void)
get the step size of the output axis..
Definition: algo.h:855
class MeanAverage in group platformlib
Definition: algo.h:893
SUMMER.
Definition: algo.h:966
The VremMask class Network Mask Utility for Automap.
Definition: algo.h:1014
VremMask(QString ip, QString mask)
Constructor, enter with any IP within the segment used within the Netmask.
Definition: algo.h:1021
const QString Network(void)
returns the network address if ever needed
Definition: algo.h:1094
static const QStringList ListOfSubnetAddresses(QString ip, QString mask)
returns a list of IP addresses based on a netmask
Definition: algo.h:1112
const QString BroadCast(void)
return the boardcast addess which everyone listens
Definition: algo.h:1103
const QStringList SubNet(void)
Returns all the ids allowed in that class C network, within the confines of that netmask.
Definition: algo.h:1088
The smath class in group platformlib.
Definition: algo.h:149
vmath mostly used for clar, does array math
Definition: algo.h:186
static int getRand(int min, int max)
getRand
Definition: algo.h:490
static void displayPointer(T *ptr)
displayPointer
Definition: algo.h:608