-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmexArrayProduct.cpp
More file actions
56 lines (45 loc) · 1.67 KB
/
mexArrayProduct.cpp
File metadata and controls
56 lines (45 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* This file illustrates how to construct a simple C++ MEX-File with
* EasyLink.
*
* The function multiplies an input scalar times an input NxM array and outputs
* a NxM array.
*
* The calling syntax is:
*
* outArray = mexArrayProduct(multiplier, inArray)
*
* To compile this C++ MEX-File, enter the following command in MATLAB:
*
* >>make mexArrayProduct.cpp
*
*/
//------------------------------------------------------------------------------
#include "EasyLink.h"
//------------------------------------------------------------------------------
class Function : public BaseFunction {
public:
// Checks the number and the sizes of the input ports of the function
// (right-side arguments)
static void checkInputPortSizes() {
checkInputPortsCount(2);
checkInputPort(0, 1, 1, mxDOUBLE_CLASS);
checkInputPort(1, -1, -1, mxDOUBLE_CLASS);
}
// Specifies the number and the sizes of the output ports of the function
// (left-side arguments)
static void initializeOutputPortSizes() {
checkOutputPortsCount(1);
setOutputPort(0, getInputNRows(1), getInputNCols(1), mxDOUBLE_CLASS);
}
// Calculates the function
static void computeOutputs() {
double multiplier = getInputDouble(0);
Array<double> inArray = getInputArray<double>(1);
Array<double> outArray = getOutputArray<double>(0);
outArray = inArray*multiplier;
}
};
//------------------------------------------------------------------------------
#include "mexDefinitions.h"
//------------------------------------------------------------------------------