git-svn-id: svn://db.shs.com.ru/pip@649 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
8
main.cpp
8
main.cpp
@@ -42,6 +42,8 @@ public:
|
||||
};
|
||||
int main() {
|
||||
PIEvaluator eval, eval2;
|
||||
//eval.check("1-1+1");
|
||||
//piCout << eval.evaluate().real();
|
||||
eval.setVariable("t", complexd(1, 2));
|
||||
eval.check("(t*t*(t<8))+(72*(t>8)-8*(9-t)*(9-t)*(t>8)*(t<8.8))+(3*(t-8.8)*(t>8.8))");
|
||||
PIByteArray ba = eval.save();
|
||||
@@ -59,12 +61,14 @@ int main() {
|
||||
|
||||
tm.reset();
|
||||
PIEvaluator e2;
|
||||
piForTimes(100) {
|
||||
e2.load(ba);
|
||||
piForTimes(10000) {
|
||||
e2.setVariable("t", complexd(1, 2));
|
||||
complexd ret = e2.evaluate();
|
||||
}
|
||||
us = tm.elapsed_u(); piCout << " save" << us / 100.;
|
||||
us = tm.elapsed_u(); piCout << " save" << us / 10000.;
|
||||
|
||||
|
||||
|
||||
/*A a;
|
||||
CONNECTU(PICout::Notifier::object(), finished, &a, pcf);
|
||||
|
||||
@@ -259,8 +259,10 @@ void PIBroadcast::mcastRead(uchar * data, int size) {
|
||||
void PIBroadcast::run() {
|
||||
PIVector<PIEthernet::Address> al = PIEthernet::allAddresses();
|
||||
mcast_mutex.lock();
|
||||
bool r = _reinit;
|
||||
bool r = _reinit, ac = (al != prev_al);
|
||||
mcast_mutex.unlock();
|
||||
if (al != prev_al || r)
|
||||
if (ac || r)
|
||||
reinit();
|
||||
if (ac)
|
||||
addressesChanged();
|
||||
}
|
||||
|
||||
@@ -125,6 +125,9 @@ protected:
|
||||
//! Called when packet received
|
||||
virtual void received(PIByteArray data) {}
|
||||
|
||||
//! Called when addresses are changed
|
||||
virtual void addressesChanged() {}
|
||||
|
||||
private:
|
||||
EVENT_HANDLER2(void, mcastRead, uchar * , data, int, size);
|
||||
void destroyAll();
|
||||
|
||||
@@ -863,7 +863,7 @@ int PIEvaluator::parse(const PIString & string, int offset) {
|
||||
if (args.size_s() > 0) return args.back();
|
||||
else return -666;
|
||||
}
|
||||
for (int i = 0; i < PIEvaluatorTypes::operationCount; i++) {
|
||||
for (int i = 0; i < PIEvaluatorTypes::oOperatorsCount; i++) {
|
||||
coper = operationInOrder(i);
|
||||
for (int j = 0; j < opers.size_s(); j++) {
|
||||
if (coper == PIEvaluatorTypes::oDivide || coper == PIEvaluatorTypes::oMultiply) {
|
||||
@@ -1016,7 +1016,7 @@ inline complexd PIEvaluator::residue(const complexd & f, const complexd & s) {
|
||||
|
||||
|
||||
inline void PIEvaluator::execFunction(const PIEvaluatorTypes::Instruction & ci) {
|
||||
PIEvaluatorTypes::Function cfunc = content.function(ci.function);
|
||||
const PIEvaluatorTypes::Function & cfunc(content.function(ci.function));
|
||||
int oi = -ci.out - 1;
|
||||
complexd tmp, stmp, ttmp;
|
||||
//qDebug() << "function " << (int)cfunc.type;
|
||||
@@ -1181,13 +1181,12 @@ inline void PIEvaluator::execFunction(const PIEvaluatorTypes::Instruction & ci)
|
||||
|
||||
inline bool PIEvaluator::execInstructions() {
|
||||
kvars = &(content.variables);
|
||||
PIEvaluatorTypes::Instruction ci;
|
||||
int oi;
|
||||
complexd tmp;
|
||||
tmpvars = variables;
|
||||
//cout << "var count " << tmpvars.size_s() << endl;
|
||||
for (int i = 0; i < instructions.size_s(); i++) {
|
||||
ci = instructions[i];
|
||||
const PIEvaluatorTypes::Instruction & ci(instructions[i]);
|
||||
oi = -ci.out - 1;
|
||||
//cout << value(ci.operators[0]) << operationChar(ci.operation) << value(ci.operators[1]) << ", " << oi << endl;
|
||||
switch (ci.operation) {
|
||||
@@ -1241,6 +1240,7 @@ inline bool PIEvaluator::execInstructions() {
|
||||
case PIEvaluatorTypes::oNone:
|
||||
tmpvars[oi].value = value(ci.operators[0]);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (!instructions.isEmpty())
|
||||
|
||||
@@ -29,12 +29,11 @@
|
||||
typedef complexd (*FuncFunc)(void * , int, complexd * );
|
||||
|
||||
namespace PIEvaluatorTypes {
|
||||
static const int operationCount = 14;
|
||||
|
||||
enum PIP_EXPORT eType {etNumber, etOperator, etVariable, etFunction};
|
||||
enum PIP_EXPORT Operation {oNone, oAdd, oSubtract, oMultiply, oDivide, oResidue, oPower,
|
||||
oEqual, oNotEqual, oGreater, oSmaller, oGreaterEqual, oSmallerEqual,
|
||||
oAnd, oOr, oFunction
|
||||
oAnd, oOr, oOperatorsCount, oFunction
|
||||
};
|
||||
enum PIP_EXPORT BaseFunctions {bfUnknown, bfSin, bfCos, bfTg, bfCtg,
|
||||
bfArcsin, bfArccos, bfArctg, bfArcctg,
|
||||
|
||||
Reference in New Issue
Block a user