PIEvaluator simplify variables sort
This commit is contained in:
78
main.cpp
78
main.cpp
@@ -1,53 +1,37 @@
|
||||
#include "pip.h"
|
||||
#include "pivariantsimple.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct MM {
|
||||
int x;
|
||||
int x2;
|
||||
double y;
|
||||
char c[16];
|
||||
int e2;
|
||||
int e;
|
||||
//PIPointd h;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
int Acnt = 0;
|
||||
|
||||
class A {
|
||||
public:
|
||||
A() {moved = false; i = "constructor"; piCout << "A()"; ++Acnt;}
|
||||
A(const PIString & s): i(s) {moved = false; piCout << "A(String)"; ++Acnt;}
|
||||
A(const A & a): i(a.i) {moved = false; piCout << "copy A(&)"; ++Acnt;}
|
||||
A(A && a): i(std::move(a.i)) {moved = false; a.moved = true; piCout << "copy A(&&)"; ++Acnt;}
|
||||
~A() {piCout << "~A()" << moved; --Acnt;}
|
||||
void swap(A & a) {piCout << "swap A()"; piSwap(i, a.i);}
|
||||
A & operator =(const A & a) {i = a.i; piCout << "= A&"; return *this;}
|
||||
A & operator =(A && a) {piSwap(i, a.i); a.moved = true; piCout << "= A&&)"; return *this;}
|
||||
bool operator ==(const A & a) {return true;}
|
||||
PIString i;
|
||||
bool moved;
|
||||
MM m;
|
||||
static void F(int) {}
|
||||
};
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & ba, const A & v) {ba << v.i << v.m; return ba;}
|
||||
inline PIByteArray & operator >>(PIByteArray & ba, A & v) {ba >> v.i >> v.m; return ba;}
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & ba, const MM & v) {piCout << "<<"; ba << v.x << v.y << v.c; return ba;}
|
||||
inline PIByteArray & operator >>(PIByteArray & ba, MM & v) {piCout << ">>"; ba >> v.x >> v.y >> v.c; return ba;}
|
||||
|
||||
|
||||
int main() {
|
||||
PIMathVectorT3d v3({1,2,3});
|
||||
PIMathVectord v(v3);
|
||||
PIMathVectord v2({3,2,1});
|
||||
piCout << v;
|
||||
piCout << v2;
|
||||
PIMathMatrixT22d m = PIMathMatrixT22d::identity();
|
||||
piCout << m;
|
||||
m.rotate(toRad(90.));
|
||||
piCout << m;
|
||||
PIVector<int> indexes;
|
||||
PIEvaluator eval;
|
||||
int dims = 3;
|
||||
indexes << eval.setVariable("l", complexd(1.));
|
||||
indexes << eval.setVariable("mc", complexd(1.));
|
||||
for (int i = 0; i < dims; ++i) {
|
||||
indexes << eval.setVariable("t" + PIString::fromNumber(i), complexd(1.));
|
||||
indexes << eval.setVariable("tv" + PIString::fromNumber(i), complexd(1.));
|
||||
}
|
||||
for (int i = 0; i < dims; ++i) {
|
||||
indexes << eval.setVariable("m" + PIString::fromNumber(i), complexd(1.));
|
||||
indexes << eval.setVariable("mv" + PIString::fromNumber(i), complexd(1.));
|
||||
}
|
||||
piCout << indexes;
|
||||
|
||||
indexes.clear();
|
||||
indexes << eval.setVariable("l", complexd(1.));
|
||||
indexes << eval.setVariable("mc", complexd(1.));
|
||||
for (int i = 0; i < dims; ++i) {
|
||||
indexes << eval.setVariable("t" + PIString::fromNumber(i), complexd(1.));
|
||||
indexes << eval.setVariable("tv" + PIString::fromNumber(i), complexd(1.));
|
||||
}
|
||||
for (int i = 0; i < dims; ++i) {
|
||||
indexes << eval.setVariable("m" + PIString::fromNumber(i), complexd(1.));
|
||||
indexes << eval.setVariable("mv" + PIString::fromNumber(i), complexd(1.));
|
||||
}
|
||||
piCout << indexes;
|
||||
|
||||
PIEvaluator * eval_x = new PIEvaluator();
|
||||
piCout << eval_x->setVariable("t");
|
||||
piCout << eval_x->setVariable("t");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user