24 GrapherExpr(
const std::string &expr)
49 void eval(
const char **)
override
79 if (!expr.isValid()) {
80 std::cerr <<
"expression failed " << expr.parseError() << std::endl;
82 }
else if (!expr.returnType().isFP(1)) {
83 std::cerr <<
"Expected expression of type " <<
ExprType().
FP(1).
Varying().
toString() <<
" got " << expr.returnType().toString() << std::endl;
93 auto buffer = std::vector<char>(
w *
h,
' ');
96 int j_zero =
static_cast<int>((-ymin) / (ymax - ymin) *
h);
98 for (
int i = 0;
i <
w;
i++) {
103 int i_zero =
static_cast<int>((-xmin) / (xmax - xmin) *
w);
105 for (
int j = 0;
j <
h;
j++) {
113 for (
int i = 0;
i <
w;
i++) {
120 const double *val = expr.evalFP();
126 int j =
static_cast<int>((y - ymin) / (ymax - ymin) *
h);
134 for (
int j =
h - 1;
j >= 0;
j--) {
135 for (
int i = 0;
i <
w;
i++) {
138 std::cout << std::endl;
int main(int argc, char *argv[])
ExprType & FP(int d)
Mutate this into a floating point type of dimension d.
ExprType & Varying()
Mutate this into a varying lifetime.
std::string toString() const
Stringify the type into a printable string.
abstract class for implementing variable references
virtual void eval(double *result)=0
returns this variable's value by setting result
virtual ExprVarRef * resolveVar(const std::string &) const