Skip to content
Snippets Groups Projects
Commit a0707c16 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Adjust octave bindings to shared pointer interface

parent 0d9ebf6e
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "config.h" #include "config.h"
#endif #endif
#include <dune/common/shared_ptr.hh>
#include <dune/tectonic/octave/duneoctave.hh> #include <dune/tectonic/octave/duneoctave.hh>
#include <dune/tectonic/samplefunctional.hh> #include <dune/tectonic/samplefunctional.hh>
...@@ -25,22 +27,25 @@ Evaluate x -> 1/2<Ax,x> - <b,x> + H(|x|) at each point y that is a column vector ...@@ -25,22 +27,25 @@ Evaluate x -> 1/2<Ax,x> - <b,x> + H(|x|) at each point y that is a column vector
Functional::SmallVector b; Functional::SmallVector b;
Dune::octaveToDune<dim>(args(1).vector_value(), b); Dune::octaveToDune<dim>(args(1).vector_value(), b);
Dune::SampleFunction<100> f_steep; Dune::shared_ptr<Functional::NonlinearityType const> phi;
Dune::SampleFunction<2> f_sample;
charNDArray bar = args(2).char_array_value(); charNDArray bar = args(2).char_array_value();
Dune::NiceFunction *foo;
switch (bar(0)) { switch (bar(0)) {
case 'S': case 'S': {
foo = &f_steep; Dune::NiceFunction const *pre_f = new Dune::SampleFunction<100>();
Dune::shared_ptr<Dune::NiceFunction const> f(pre_f);
phi = Dune::make_shared<Functional::NonlinearityType const>(f);
break; break;
case 's': }
foo = &f_sample; case 's': {
Dune::NiceFunction const *pre_f = new Dune::SampleFunction<2>();
Dune::shared_ptr<Dune::NiceFunction const> f(pre_f);
phi = Dune::make_shared<Functional::NonlinearityType const>(f);
break; break;
}
default: default:
assert(false); assert(false);
} }
Dune::LocalNonlinearity<dim> phi(*foo);
Functional J(A, b, phi); Functional J(A, b, phi);
Matrix points(args(3).matrix_value()); Matrix points(args(3).matrix_value());
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "config.h" #include "config.h"
#endif #endif
#include <dune/common/shared_ptr.hh>
#include <dune/tectonic/octave/duneoctave.hh> #include <dune/tectonic/octave/duneoctave.hh>
#include <dune/tectonic/samplefunctional.hh> #include <dune/tectonic/samplefunctional.hh>
...@@ -25,22 +27,25 @@ Make a minimisation step of x -> 1/2<Ax,x> - <b,x> + H(|x|) using DUNE starting ...@@ -25,22 +27,25 @@ Make a minimisation step of x -> 1/2<Ax,x> - <b,x> + H(|x|) using DUNE starting
Functional::SmallVector b; Functional::SmallVector b;
Dune::octaveToDune<dim>(args(1).vector_value(), b); Dune::octaveToDune<dim>(args(1).vector_value(), b);
Dune::SampleFunction<100> f_steep; Dune::shared_ptr<Functional::NonlinearityType const> phi;
Dune::SampleFunction<2> f_sample;
charNDArray bar = args(2).char_array_value(); charNDArray bar = args(2).char_array_value();
Dune::NiceFunction *foo;
switch (bar(0)) { switch (bar(0)) {
case 'S': case 'S': {
foo = &f_steep; Dune::NiceFunction const *pre_f = new Dune::SampleFunction<100>();
Dune::shared_ptr<Dune::NiceFunction const> f(pre_f);
phi = Dune::make_shared<Functional::NonlinearityType const>(f);
break; break;
case 's': }
foo = &f_sample; case 's': {
Dune::NiceFunction const *pre_f = new Dune::SampleFunction<2>();
Dune::shared_ptr<Dune::NiceFunction const> f(pre_f);
phi = Dune::make_shared<Functional::NonlinearityType const>(f);
break; break;
}
default: default:
assert(false); assert(false);
} }
Dune::LocalNonlinearity<dim> phi(*foo);
Functional J(A, b, phi); Functional J(A, b, phi);
ColumnVector start_octave(args(3).vector_value()); ColumnVector start_octave(args(3).vector_value());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment