# HG changeset patch # User gedeone-octave # Date 1378068441 -7200 # Node ID ee608d1bffcabd0a5f057c828dfc92a730c658d8 # Parent 70322135b25f3393928ac442b99d9926962ef1f2 Index start from 1 following Octave convention. diff -r 70322135b25f -r ee608d1bffca src/SubSpace.cc --- a/src/SubSpace.cc Tue Aug 27 22:58:58 2013 +0200 +++ b/src/SubSpace.cc Sun Sep 01 22:47:21 2013 +0200 @@ -16,7 +16,17 @@ */ #include "functionspace.h" -DEFUN_DLD (SubSpace, args, , "initialize a fs from a mesh declared with fem_init_mesh") +DEFUN_DLD (SubSpace, args, , "-*- texinfo -*-\n\ +@deftypefn {Function File} {[@var{V1}]} = \ +SubSpace (@var{Space V}, @var{index}(Optional)) \n\ +The input arguments are\n\ +@itemize @bullet\n\ +@item @var{Space V} which is a mixed FunctionalSpace\n\ +@item @var{index} represents the subSpace which you want to extract; index\ +should be a positive integer.\n\ +@enditemize \n\ +The output @var{V0} is the SubSpace you need\n\ +@end deftypefn") { int nargin = args.length (); octave_value retval; @@ -41,8 +51,17 @@ if (! error_state) { const dolfin::FunctionSpace & V = fspo.get_fsp (); - boost::shared_ptr g (new dolfin::SubSpace (V, idx)); - retval = new functionspace(g); + + if (idx < 1 || idx > V.dim ()) + error ("SubSpace: index out of bounds"); + + else + { + std::cout << "Extracting subspace..." << std::endl; + boost::shared_ptr g (new dolfin::SubSpace (V, idx - 1)); + retval = new functionspace (g); + } + } } }