Skip to content

Clarify use of Functions without Shapes #463

Description

@alexneufeld

I want to evaluate some function f(x) on many different intervals. I think that I don't want to rely on the Shape abstractions for this task, because I assume there is some performance penalty to passing y and z values that are never used.

Instead of doing something like this:

use fidget_core::{
    context::Tree,
    shape::EzShape,
};
use fidget_jit::JitShape;

let tree = Tree::x() + Tree::y();
let shape = JitShape::from(tree);

// Generate machine code to execute the tape
let tape = shape.ez_point_tape();
let mut eval = JitShape::new_point_eval();

// This calls directly into that machine code!
let (r, _trace) = eval.eval(&tape, 0.1, 0.3, 0.0)?;
assert_eq!(r, 0.1 + 0.3);

... I think I want to do something like this:

use fidget::context::{Context, Tree};
use fidget::eval::{TracingEvaluator};
use fidget::jit::{JitIntervalEval, JitTracingFn};
use fidget::types::Interval;

fn main() {

    let tree = (Tree::x().square() - 1.0).square() + 0.6*Tree::x() + 2.0;
    let mut ctx = Context::new();
    let root = ctx.import(&tree);
    let mut interval_evaluator = JitIntervalEval::default();
    let result = interval_evaluator.eval(&_what_, &[Interval::new(1.0,2.0)]);

}

Is it intended to be possible to use Function types directly? Could the docs in fidget_jit be improved?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions