Mercurial > fem-fenics-eugenio
changeset 234:94895618701f
Add function evaluation with coordinates inside brackets
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Sat, 21 Jun 2014 16:07:42 +0200 |
parents | b07ec30369ab |
children | 568aff85dfa9 |
files | src/function.h |
diffstat | 1 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/function.h Sat Jun 21 15:28:07 2014 +0200 +++ b/src/function.h Sat Jun 21 16:07:42 2014 +0200 @@ -22,6 +22,7 @@ #include <vector> #include <dolfin.h> #include <octave/oct.h> +#include <octave/parse.h> class function : public octave_base_value { @@ -35,6 +36,13 @@ boost::shared_ptr <const dolfin::Function> _fun) : octave_base_value (), str(_str), fun (_fun) {} + function (function const& _func) + : octave_base_value () + { + str = _func.get_str (); + fun = _func.get_pfun (); + } + void print (std::ostream& os, bool pr_as_read_syntax = false) const @@ -65,6 +73,48 @@ get_str (void) const { return str; } + octave_value + subsref (const std::string& type, + const std::list<octave_value_list>& idx) + { + octave_value retval; + + switch (type[0]) + { + case '(': + { + std::list<octave_value_list> args; + args.push_back (octave_value (new function (*this))); + args.push_back (idx.front ()); + retval = feval ("feval", args); + } + break; + + case '{': + case '.': + { + std::string nm = type_name (); + error ("%s cannot be indexed with %c", nm.c_str (), type[0]); + } + break; + + default: + panic_impossible (); + } + + return retval; + } + + octave_value_list + subsref (const std::string& type, + const std::list<octave_value_list>& idx, + int) + { + octave_value_list retval; + retval = subsref (type, idx); + return retval; + } + private: std::string str;