git-svn-id: svn://db.shs.com.ru/pip@6 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
31
doc/examples/pievaluator.cpp
Normal file
31
doc/examples/pievaluator.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "pip.h"
|
||||
|
||||
void _() {
|
||||
//! [main]
|
||||
PIEvaluator eval;
|
||||
|
||||
eval.check("e2eelge");
|
||||
|
||||
piCout << eval.expression() << "=" << eval.evaluate();
|
||||
// e*2*e*e*lg(e) = (17.4461; 0)
|
||||
|
||||
eval.check("10x");
|
||||
|
||||
piCout << eval.error() << eval.unknownVariables();
|
||||
// Unknown variables: "x" {"x"}
|
||||
|
||||
eval.setVariable("x", complexd(1, 2));
|
||||
eval.check("10x");
|
||||
|
||||
piCout << eval.error() << eval.unknownVariables();
|
||||
// Correct {}
|
||||
|
||||
piCout << eval.expression() << "=" << eval.evaluate();
|
||||
// 10*x = (10; 20)
|
||||
|
||||
eval.setVariable("x", complexd(-2, 0));
|
||||
|
||||
piCout << eval.expression() << "=" << eval.evaluate();
|
||||
// 10*x = (-20; 0)
|
||||
//! [main]
|
||||
};
|
||||
Reference in New Issue
Block a user