view src/expression.h @ 34:5f8e72452780

Use variable name x instead of xy
author gedeone-octave <marco.vassallo@outlook.com>
date Thu, 18 Jul 2013 14:30:12 +0200
parents eaf8a1e8f377
children cedb2b5d6455
line wrap: on
line source

/*
 Copyright (C) 2013 Marco Vassallo

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 2 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _EXPRESSION_OCTAVE_
#define _EXPRESSION_OCTAVE_

#include <dolfin.h>
#include <octave/oct.h>
#include <octave/oct-map.h>
#include <octave/ov-fcn-handle.h>
#include <octave/ov-fcn.h>
#include <octave/parse.h>
#include <octave/octave.h>

class expression : public dolfin::Expression
{

 public:
  expression() : dolfin::Expression() {}

  expression (octave_fcn_handle & _f) :
             dolfin::Expression (), f (new octave_fcn_handle (_f)) {}

  ~expression (void) { delete f; }


  void eval (dolfin::Array<double>& values, const dolfin::Array<double>& x) const
  {
    octave_value_list b;
    b.resize (x.size ());
    for (int i = 0; i < x.size (); ++i)
      b(i) = x[i];
    octave_value_list res = feval (f->function_value (), b);
    values[0] = res(0).double_value ();
  }

 private:
  octave_fcn_handle * f;
};

#endif