diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index e48083afd..9c3489fb8 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -5,6 +5,7 @@ +
-Octave is a high-level language intended for numerical programming that is -mostly compatible with MATLAB. More information can be found -at Octave web site. + Octave is a high-level language intended for numerical programming that is mostly compatible with MATLAB. +More information can be found at Octave web site.
-This chapter is intended to give an introduction to using the module. You -should also read the SWIG documentation that is not specific to Octave. Also, -there are a dozen or so examples in the Examples/octave directory, and hundreds -in the test suite (Examples/test-suite and Examples/test-suite/octave). + This chapter is intended to give an introduction to using the module. You should also read the SWIG documentation that is not specific to Octave. +Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).
-As of SWIG 3.0.0, the Octave module has been tested with Octave versions 3.0.5, -3.2.4, 3.4.3, 3.6.4, and 3.8.0. Use of Octave versions older than 3.x.x is not -recommended, as these versions are no longer tested with SWIG. +As of SWIG 3.0.0, the Octave module has been tested with Octave versions 3.0.5, 3.2.4, 3.4.3, 3.6.4, and 3.8.0. +Use of Octave versions older than 3.x.x is not recommended, as these versions are no longer tested with SWIG.
Let's start with a very simple SWIG interface file, example.i:
@@ -75,67 +76,54 @@ Let's start with a very simple SWIG interface file, example.i: #include "example.h" %} int gcd(int x, int y); -extern double Foo; - +extern double Foo;-To build an Octave module when wrapping C code, run swig using -the -octave option: +To build an Octave module when wrapping C code, run SWIG using the -octave option:
--$ swig -octave -o example_wrap.cpp example.i -
$ swig -octave -o example_wrap.cpp example.i
The -c++ option is also required when wrapping C++ code:
--$ swig -octave -c++ -o example_wrap.cpp example.i -
$ swig -octave -c++ -o example_wrap.cpp example.i
-This creates a C++ source file example_wrap.cpp. A C++ file is -generated even when wrapping C code as Octave is itself written in C++ and -requires wrapper code to be in the same language. The generated C++ source file -contains the low-level wrappers that need to be compiled and linked with the -rest of your C/C++ application (in this case, the gcd implementation) to create -an extension module. +This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.
-The swig command line has a number of options you can use, like to -redirect its output. Use swig -help to learn about these. Options -specific to the Octave module are: +The swig command line has a number of options you can use, like to redirect its output. Use swig -help to learn about these. +Options specific to the Octave module are:
$ swig -octave -help ... Octave Options (available with -octave) - -globals <name> - Set <name> used to access C global variables [default: 'cvar'] - Use '.' to load C global variables into module namespace - -opprefix <str> - Prefix <str> for global operator functions [default: 'op_'] + -globals name - Set name used to access C global variables [default: 'cvar'] + Use '.' to load C global variables into module namespace + -opprefix str - Prefix str for global operator functions [default: 'op_']
-The -globals option sets the name of the variable which is the -namespace for C global variables exported by the module. The special -name . loads C global variables into the module namespace, -i.e. alongside C functions and structs exported by the module. -The -opprefix options sets the prefix of the names of -global/friend operator functions. +The -globals option sets the name of the variable which is the namespace for C global variables exported by the module. +The special name "." loads C global variables into the module namespace, i.e. alongside C functions and structs exported by the module. +The -opprefix options sets the prefix of the names of global/friend operator functions.
-Octave modules are DLLs/shared objects having the .oct suffix. -Building an .oct file is usually done with the mkoctfile -command (either within Octave itself, or from the shell). For example, +Octave modules are DLLs/shared objects having the ".oct" suffix. +Building an oct file is usually done with the mkoctfile command (either within Octave itself, or from the shell). For example,
@@ -144,30 +132,28 @@ $ mkoctfile example_wrap.cpp example.c
-where example.c is the file containing the gcd() implementation. + where "example.c" is the file containing the gcd() implementation.
-mkoctfile can also be used to extract the build parameters required to -invoke the compiler and linker yourself. See the Octave manual -and mkoctfile man page. + mkoctfile can also be used to extract the build parameters required to invoke the compiler and linker yourself. See the Octave manual and mkoctfile man page.
-mkoctfile will produce swigexample.oct, which contains the -compiled extension module. Loading it into Octave is then a matter of invoking + mkoctfile will produce "swigexample.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking
-octave:1> swigexample -
octave:1> swigexample
-Assuming all goes well, you will be able to do this:
+Assuming all goes well, you will be able to do this:
+
$ octave -q ++ans = 4$ octave -q octave:1> swigexample octave:2> swigexample.gcd(4,6) ans = 2 @@ -175,27 +161,20 @@ octave:3> swigexample.cvar.Foo ans = 3 octave:4> swigexample.cvar.Foo=4; octave:5> swigexample.cvar.Foo -ans = 4 -
-The SWIG module directive specifies the name of the Octave module. If -you specify module swigexample, then in Octave everything in the module -will be accessible under swigexample, as in the above example. When -choosing a module name, make sure you don't use the same name as a built-in -Octave command or standard module name. +The SWIG module directive specifies the name of the Octave module. If you specify "module swigexample", then in Octave everything in the module will be accessible under "swigexample", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name.
-When Octave is asked to invoke swigexample, it will try to find -the .m or .oct file that defines the -function swigexample. You therefore need to make sure -that swigexample.oct is in Octave's search path, which can be specified -with the environment variable OCTAVE_PATH. +When Octave is asked to invoke swigexample, it will try to find the ".m" or ".oct" file that defines the function "swigexample". You therefore need to make sure that "swigexample.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH".
@@ -214,9 +193,8 @@ ans = 4
-Modules can also be loaded from within functions, even before being loaded in -the base context. If the module is also used in the base context, however, it -must first be loaded again: +Modules can also be loaded from within functions, even before being loaded in the base context. +If the module is also used in the base context, however, it must first be loaded again:
@@ -235,135 +213,112 @@ ans = 232.3.2 Functions
--Global functions are wrapped as new Octave built-in functions. For example, -
- --%module swigexample -int fact(int n); --creates a built-in function swigexample.fact(n) that works exactly like -you think it does: +Global functions are wrapped as new Octave built-in functions. For example,
-+octave:1> swigexample.fact(4) -24 -+ +%module swigexample +int fact(int n);+ creates a built-in function swigexample.fact(n) that works exactly like you think it does: +
+ +octave:1> swigexample.fact(4) +2432.3.3 Global variables
+-Global variables are a little special in Octave. Given a global variable: + Global variables are a little special in Octave. Given a global variable:
--%module swigexample +%module swigexample extern double Foo;-To expose variables, SWIG actually generates two functions, to get and set the -value. In this case, Foo_set and Foo_set would be -generated. SWIG then automatically calls these functions when you get and set -the variable -- in the former case creating a local copy in the interpreter of -the C variables, and in the latter case copying an interpreter variables onto -the C variable. + To expose variables, SWIG actually generates two functions, to get and set the value. In this case, Foo_set and Foo_set would be generated. SWIG then automatically calls these functions when you get and set the variable-- in the former case creating a local copy in the interpreter of the C variables, and in the latter case copying an interpreter variables onto the C variable.
-octave:1> swigexample; ++ans = 4octave:1> swigexample; octave:2> c=swigexample.cvar.Foo c = 3 octave:3> swigexample.cvar.Foo=4; octave:4> c c = 3 octave:5> swigexample.cvar.Foo -ans = 4 --If a variable is marked with the %immutable directive then any attempts -to set this variable will cause an Octave error. Given a global variable: +If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Octave error. Given a global variable:
--%module swigexample +%module swigexample %immutable; extern double Foo; %mutable;-SWIG will allow the reading of Foo but when a set attempt is made, an -error function will be called. + SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called.
-octave:1> swigexample ++error: evaluating assignment expression near line 2, column 12octave:1> swigexample octave:2> swigexample.Foo=4 error: attempt to set immutable member variable error: assignment failed, or no method for `swig_type = scalar' -error: evaluating assignment expression near line 2, column 12 --It is possible to add new functions or variables to the module. This also allows -the user to rename/remove existing functions and constants (but not linked -variables, mutable or immutable). Therefore users are recommended to be careful -when doing so. + It is possible to add new functions or variables to the module. This also allows the user to rename/remove existing functions and constants (but not linked variables, mutable or immutable). Therefore users are recommended to be careful when doing so.
-octave:1> swigexample; ++ans = 3.1420octave:1> swigexample; octave:2> swigexample.PI=3.142; octave:3> swigexample.PI -ans = 3.1420 -32.3.4 Constants and enums
+-Because Octave doesn't really have the concept of constants, C/C++ constants are -not really constant in Octave. They are actually just a copy of the value into -the Octave interpreter. Therefore they can be changed just as any other -value. For example given some constants: + Because Octave doesn't really have the concept of constants, C/C++ constants are not really constant in Octave. They are actually just a copy of the value into the Octave interpreter. Therefore they can be changed just as any other value. For example given some constants:
--%module swigexample +%module swigexample %constant int ICONST=42; #define SCONST "Hello World" enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};-This is effectively converted into the following Octave code: + This is 'effectively' converted into the following Octave code:
-swigexample.ICONST=42 ++....swigexample.ICONST=42 swigexample.SCONST="Hello World" swigexample.SUNDAY=0 -.... -32.3.5 Pointers
+-C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem -working with incomplete type information. Given a wrapping of -the file.h interface: + C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface: + C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface:
--%module swigexample +%module swigexample FILE *fopen(const char *filename, const char *mode); int fputs(const char *, FILE *); int fclose(FILE *);-When wrapped, you will be able to use the functions in a natural way from -Octave. For example: +When wrapped, you will be able to use the functions in a natural way from Octave. For example:
@@ -374,7 +329,7 @@ octave:4> swigexample.fclose(f);-Simply printing the value of a wrapped C++ type will print its typename, e.g.: + Simply printing the value of a wrapped C++ type will print its typename. E.g.,
+}octave:1> swigexample; @@ -384,67 +339,55 @@ f = { _p_FILE, ptr = 0x9b0cd00 -} --As the user of the pointer, you are responsible for freeing it, or closing any -resources associated with it (just as you would in a C program). This does not -apply so strictly to classes and structs (see below). + As the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes and structs (see below).
-octave:1> swigexample; ++error: evaluating assignment expression near line 2, column 2octave:1> swigexample; octave:2> f=swigexample.fopen("not there","r"); error: value on right hand side of assignment is undefined -error: evaluating assignment expression near line 2, column 2 -32.3.6 Structures and C++ classes
+-SWIG wraps C structures and C++ classes by using a special Octave type called -a swig_ref. A swig_ref contains a reference to one or more -instances of C/C++ objects, or just the type information for an object. For -each wrapped structure and class, a swig_ref will be exposed that has -the name of the type. When invoked as a function, it creates a new object of its -type and returns a swig_ref that points to that instance. This provides -a very natural interface. For example, + SWIG wraps C structures and C++ classes by using a special Octave type called a swig_ref. A swig_ref contains a reference to one or more instances of C/C++ objects, or just the type information for an object. +For each wrapped structure and class, a swig_ref will be exposed that has the name of the type. When invoked as a function, it creates a new object of its type and returns a swig_ref that points to that instance. This provides a very natural interface. For example,
--struct Point{ +struct Point{ int x,y; };-is used as follows: + is used as follows:
-octave:1> swigexample; ++-octave:1> swigexample; octave:2> p=swigexample.Point(); octave:3> p.x=3; octave:4> p.y=5; octave:5> p.x, p.y ans = 3 -ans = 5 +ans = 5In C++, invoking the type object in this way calls the object's constructor. -swig_ref objects can also be acquired by having a wrapped function -return a pointer, reference, or value of a non-primitive type. +swig_ref objects can also be acquired by having a wrapped function return a pointer, reference, or value of a non-primitive type.
--The swig_ref type handles indexing operations such that usage maps -closely to what you would have in C/C++. Structure members are accessed as in -the above example, by calling set and get methods for C++ variables. Methods -also work as expected. For example, code wrapped in the following way +The swig_ref type handles indexing operations such that usage maps closely to what you would have in C/C++. +Structure members are accessed as in the above example, by calling set and get methods for C++ variables. + +Methods also work as expected. For example, code wrapped in the following way
--class Point{ +-class Point{ public: int x,y; Point(int _x,int _y) : x(_x),y(_y) {} @@ -456,41 +399,34 @@ public: } };can be used from Octave like this
- -octave:1> swigexample; ++-octave:1> swigexample; octave:2> p1=swigexample.Point(3,5); octave:3> p2=swigexample.Point(1,2); octave:4> p1.distance(p2) ans = 3.6056-By using the swig_this() and swig_type() functions, one can -discover the pointers to and types of the underlying C/C++ object. +By using the swig_this() and swig_type() functions, one can discover the pointers to and types of the underlying C/C++ object.
-++-octave:5> swig_this(p1) ans = 162504808 octave:6> swig_type(p1) ans = Point-Note that swig_ref is a reference-counted pointer to a C/C++ -object/type, and as such has pass-by-reference semantics. For example if one has -a allocated a single object but has two swig_ref's pointing to it, -modifying the object through either of them will change the single allocated -object. This differs from the usual pass-by-value (copy-on-write) semantics -that Octave maintains for built-in types. For example, in the following snippet, -modifying b does not modify a, +Note that swig_ref is a reference-counted pointer to a C/C++ object/type, and as such has pass-by-reference semantics. For example if one has a allocated a single object but has two swig_ref's pointing to it, modifying the object through either of them will change the single allocated object. +This differs from the usual pass-by-value (copy-on-write) semantics that Octave maintains for built-in types. For example, in the following snippet, modifying b does not modify a,
-++-octave:7> a=struct('x',4) a = { @@ -516,12 +452,12 @@ a = x = 4 }However, when dealing with wrapped objects, one gets the behavior
-++octave:2> a=Point(3,5) a = @@ -546,58 +482,41 @@ ans = 1-Depending on the ownership setting of a swig_ref, it may call C++ -destructors when its reference count goes to zero. See the section on memory -management below for details. +Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
32.3.7 C++ inheritance
+-Single and multiple inheritance are fully supported. The swig_ref type -carries type information along with any C++ object pointer it holds. This -information contains the full class hierarchy. When an indexing operation (such -as a method invocation) occurs, the tree is walked to find a match in the -current class as well as any of its bases. The lookup is then cached in -the swig_ref. +Single and multiple inheritance are fully supported. The swig_ref type carries type information along with any C++ object pointer it holds. +This information contains the full class hierarchy. When an indexing operation (such as a method invocation) occurs, +the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.
32.3.8 C++ overloaded functions
+-Overloaded functions are supported, and handled as in other modules. That is, -each overload is wrapped separately (under internal names), and a dispatch -function is also emitted under the external/visible name. The dispatch function -selects which overload to call (if any) based on the passed arguments. -typecheck typemaps are used to analyze each argument, as well as assign -precedence. See the chapter on typemaps for details. +Overloaded functions are supported, and handled as in other modules. That is, +each overload is wrapped separately (under internal names), and a dispatch function is also emitted under the external/visible name. +The dispatch function selects which overload to call (if any) based on the passed arguments. +typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
32.3.9 C++ operators
+C++ operator overloading is supported, in a way similar to other modules. -The swig_ref type supports all unary and binary operators between -itself and all other types that exist in the system at module load time. When an -operator is used (where one of the operands is a swig_ref), the runtime -routes the call to either a member function of the given object, or to a global -function whose named is derived from the types of the operands (either both or -just the lhs or rhs). +The swig_ref type supports all unary and binary operators between itself and all other types that exist in the system at module load time. When an operator is used (where one of the operands is a swig_ref), the runtime routes the call to either a member function of the given object, or to a global function whose named is derived from the types of the operands (either both or just the lhs or rhs).
--For example, if a and b are SWIG variables in -Octave, a+b becomes a.__add(b). The wrapper is then free to -implement __add to do whatever it wants. A wrapper may define the __add -function manually, %rename some other function to it, -or %rename a C++ operator to it. +For example, if a and b are SWIG variables in Octave, a+b becomes a.__add(b). The wrapper is then free to implement __add to do whatever it wants. A wrapper may define the __add function manually, %rename some other function to it, or %rename a C++ operator to it.
--By default the C++ operators are renamed to their corresponding Octave -operators. So without doing any work, the following interface +By default the C++ operators are renamed to their corresponding Octave operators. So without doing any work, the following interface
--%inline { struct A { @@ -609,20 +528,16 @@ struct A { }; }is usable from Octave like this:
--a=A(2), b=A(3), c=a+b assert(c.value==5);Octave operators are mapped in the following way:
--__brace a{args} __brace_asgn a{args} = rhs @@ -657,11 +572,9 @@ __el_ldiv a .\ b __el_and a & b __el_or a | bOn the C++ side, the default mappings are as follows:
-%rename(__add) *::operator+; %rename(__add) *::operator+(); @@ -692,21 +605,18 @@ On the C++ side, the default mappings are as follows:-Octave can also utilise friend (i.e. non-member) operators with a simple -%rename: see the example in the Examples/octave/operator directory. +Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.
32.3.10 Class extension with %extend
--The %extend directive works the same as in other modules. You can use -it to define special behavior, like for example defining Octave operators not -mapped to C++ operators, or defining certain Octave mechanisms such as how an -object prints. For example, -the octave_value::{is_string,string_value,print} functions are routed -to a special method __str that can be defined inside an extend>. -
++The %extend directive works the same as in other modules. +
++You can use it to define special behavior, like for example defining Octave operators not mapped to C++ operators, or defining certain Octave mechanisms such as how an object prints. For example, the octave_value::{is_string,string_value,print} functions are routed to a special method __str that can be defined inside an %extend. +
-%extend A { string __str() { @@ -716,11 +626,9 @@ string __str() { } }Then in Octave one gets,
--octave:1> a=A(4); octave:2> a @@ -730,18 +638,15 @@ octave:3> printf("%s\n",a); octave:4> a.__str() 432.3.11 C++ templates
+-C++ class and function templates are fully supported as in other modules, in -that the template> directive may used to create explicit instantiations of -templated types. For example, function templates can be instantiated as -follows: +C++ class and function templates are fully supported as in other modules, in that the %template directive may used to create explicit instantiations of templated types. +For example, function templates can be instantiated as follows:
--%module swigexample +-%module swigexample %inline { template<class __scalar> __scalar mul(__scalar a,__scalar b) { @@ -752,7 +657,6 @@ follows: %template(mul) mul<std::complex<double> > %template(mul) mul<double>and then used from Octave
@@ -770,8 +674,7 @@ ans = 22 + 46i Similarly, class templates can be instantiated as in the following example, --%module swigexample ++%module swigexample %include <std_complex.i> %include <std_string.i> %inline { @@ -811,30 +714,26 @@ ans = (7,4)32.3.12 C++ Smart Pointers
+C++ smart pointers are fully supported as in other modules.
32.3.13 Directors (calling Octave from C++ code)
--There is full support for SWIG directors, which permits Octave code to subclass -C++ classes, and implement their virtual methods. -
-Octave has no direct support for object oriented programming, however -the swig_ref type provides some of this support. You can manufacture -a swig_ref using the subclass function (provided by the -SWIG/Octave runtime). +There is full support for SWIG Directors, which permits Octave code to subclass C++ classes, and implement their virtual methods. +
++Octave has no direct support for object oriented programming, however the swig_ref type provides some of this support. You can manufacture a swig_ref using the subclass function (provided by the SWIG/Octave runtime).
-For example,
--octave:1> a=subclass(); octave:2> a.my_var = 4; @@ -842,12 +741,9 @@ octave:3> a.my_method = @(self) printf("my_var = ",self.my_var); octave:4> a.my_method(); my_var = 4-subclass() can also be used to subclass one or more C++ types. Suppose -you have an interface defined by +subclass() can also be used to subclass one or more C++ types. Suppose you have an interface defined by
--%inline { class A { @@ -861,11 +757,9 @@ void call_your_method(A& a) { } }Then from Octave you can say:
--octave:1> B=@() subclass(A(),@my_method); octave:2> function my_method(self) @@ -874,46 +768,30 @@ octave:4> end octave:5> call_your_method(B()); octave-side routine calledor more concisely,
--octave:1> B=@() subclass(A(),'my_method',@(self) printf("octave-side routine called\n")); octave:2> call_your_method(B()); octave-side routine called-Note that you have to enable directors via the %feature directive (see -other modules for this). +Note that you have to enable directors via the %feature directive (see other modules for this).
--subclass() will accept any number of C++ bases or -other subclass()'ed objects, (string,octave_value) pairs, -and function_handles. In the first case, these are taken as base -classes; in the second case, as named members (either variables or functions, -depending on whether the given value is a function handle); in the third case, -as member functions whose name is taken from the given function handle, e.g.: +subclass() will accept any number of C++ bases or other subclass()'ed objects, (string,octave_value) pairs, and function_handles. In the first case, these are taken as base classes; in the second case, as named members (either variables or functions, depending on whether the given value is a function handle); in the third case, as member functions whose name is taken from the given function handle. E.g.,
--octave:1> B=@(some_var=2) subclass(A(),'some_var',some_var,@some_func,'another_func', @(self) do_stuff())-You can also assign non-C++ member variables and functions after construction -time. There is no support for non-C++ static members. +You can also assign non-C++ member variables and functions after construct time. There is no support for non-C++ static members.
--There is limited support for explicitly referencing C++ bases. So, in the -example above, we could have +There is limited support for explicitly referencing C++ bases. So, in the example above, we could have
-octave:1> B=@() subclass(A(),@my_method); octave:2> function my_method(self) @@ -927,29 +805,19 @@ octave-side routine called32.3.14 Threads
+-The use of threads in wrapped director code is not supported; i.e., an -Octave-side implementation of a C++ class must be called from the Octave -interpreter's thread. Anything fancier (apartment/queue model, whatever) is left -to the user. Without anything fancier, this amounts to the limitation that -Octave must drive the module... like, for example, an optimization package that -calls Octave to evaluate an objective function. +The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
32.3.15 Memory management
--As noted above, swig_ref represents a reference counted pointer to a -C/C++-side object. It also contains a flag indicating whether Octave or the -C/C++ code owns the object. If Octave owns it, any destructors will be called -when the reference count reaches zero. If the C/C++ side owns the object, then -destructors will not be called when the reference count goes to zero. -
++As noted above, swig_ref represents a reference counted pointer to a C/C++-side object. It also contains a flag indicating whether Octave or the C/C++ code owns the object. If Octave owns it, any destructors will be called when the reference count reaches zero. If the C/C++ side owns the object, then destructors will not be called when the reference count goes to zero. +
For example, -
--%inline { class A { @@ -959,11 +827,9 @@ public: }; }-would produce this behavior in Octave: +Would produce this behavior in Octave:
--octave:1> a=A(); A constructing @@ -972,49 +838,36 @@ octave:3> clear a; octave:4> b=4; A destructing-The %newobject directive may be used to control this behavior for -pointers returned from functions. -
- +The %newobject directive may be used to control this behavior for pointers returned from functions.-In the case where one wishes for the C++ side to own an object that was created -in Octave (especially a Director object), one can use the __disown() method to -invert this logic. Then letting the Octave reference count go to zero will not -destroy the object, but destroying the object will invalidate the Octave-side -object if it still exists (and call destructors of other C++ bases in the case -of multiple inheritance/subclass()'ing). +In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).
32.3.16 STL support
+Various STL library files are provided for wrapping STL containers.
32.3.17 Matrix typemaps
--Octave provides a rich set of classes for dealing with matrices. Currently there -are no built-in typemaps to deal with those. However, these are relatively -straight forward for users to add themselves (see the docs on typemaps). Without -much work (a single typemap decl -- say, 5 lines of code in the interface file), -it would be possible to have a function -
++Octave provides a rich set of classes for dealing with matrices. Currently there are no built-in typemaps to deal with those. However, these are relatively straight forward for users to add themselves (see the docs on typemaps). Without much work (a single typemap decl-- say, 5 lines of code in the interface file), it would be possible to have a function +
-double my_det(const double* mat,int m,int n);that is accessed from Octave as,
-- +octave:1> my_det(rand(4)); ans = -0.18388
+