Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
matlabfunctionhandle.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008 Peter Carbonetto. All Rights Reserved.
2 // This code is published under the Eclipse Public License.
3 //
4 // Author: Peter Carbonetto
5 // Dept. of Computer Science
6 // University of British Columbia
7 // August 25, 2008
8
9 #ifndef INCLUDE_MATLABFUNCTIONHANDLE
10 #define INCLUDE_MATLABFUNCTIONHANDLE
11
12 #include "mex.h"
13
14 // Function declarations.
15 // -----------------------------------------------------------------
16 // This function returns true if and only if the MATLAB array is a
17 // valid function handle.
18 bool isFunctionHandle (const mxArray* ptr);
19
20 // Class MatlabFunctionHandle.
21 // -----------------------------------------------------------------
22 // The purpose of this class is twofold. The first aim is to store
23 // information about a MATLAB function handle. (For more information
24 // on function handles in MATLAB, type HELP FUNCTION_HANDLE in the
25 // MATLAB console). The second purpose is to provide a routine for
26 // evaluating the response of the function, provided inputs to the
27 // function.
28 class MatlabFunctionHandle {
29 public:
30
31 // The default constructor creates a null function handle.
32 MatlabFunctionHandle() : f(0) { };
33
34 // This constructor accepts as input a pointer to a MATLAB array. It
35 // is up to the user to ensure that the MATLAB array is a valid
36 // function handle.
37 explicit MatlabFunctionHandle (const mxArray* ptr);
38
39 // The destructor.
40 ~MatlabFunctionHandle();
41
42 // This method is used to call the MATLAB function, provided inputs
43 // to the function. It is up to the user to make sure that the
44 // outputs array is of the appropriate size. The function returns
45 // "true" on success, or "false" on failure. It is up to the user to
46 // properly deallocate the outputs.
47 bool evaluate (int nin, int nout, const mxArray** inputs, mxArray** outputs);
48
49 // Returns true if and only if the function handle is not null.
50 operator bool() const { return f != 0; };
51
52 protected:
53 mxArray* f; // The MATLAB function handle.
54 };
55
56 #endif
MatlabFunctionHandle::MatlabFunctionHandle
MatlabFunctionHandle()
Definition: matlabfunctionhandle.hpp:32
isFunctionHandle
bool isFunctionHandle(const mxArray *ptr)
MatlabFunctionHandle
Definition: matlabfunctionhandle.hpp:28
MatlabFunctionHandle::f
mxArray * f
Definition: matlabfunctionhandle.hpp:50
MatlabFunctionHandle::evaluate
bool evaluate(int nin, int nout, const mxArray **inputs, mxArray **outputs)
MatlabFunctionHandle::~MatlabFunctionHandle
~MatlabFunctionHandle()