Ipopt 3.11.9
Loading...
Searching...
No Matches
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.
18bool 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.
29public:
30
31 // The default constructor creates a null function handle.
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.
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
52protected:
53 mxArray* f; // The MATLAB function handle.
54};
55
56#endif
MatlabFunctionHandle(const mxArray *ptr)
bool evaluate(int nin, int nout, const mxArray **inputs, mxArray **outputs)
bool isFunctionHandle(const mxArray *ptr)