EasyLink
EasyLink is a C++ software development kit for developing blocks for SIMULINK (S-functions)
/Users/guillaume.laurent/Documents/Prog/easylinkEigen/easylink/mexArrayProduct.cpp
1 /*
2  * This file illustrates how to construct a simple C++ MEX-File with
3  * EasyLink.
4  *
5  * The function multiplies an input scalar times an input NxM array and outputs
6  * a NxM array.
7  *
8  * The calling syntax is:
9  *
10  * outArray = mexArrayProduct(multiplier, inArray)
11  *
12  * To compile this C++ MEX-File, enter the following command in MATLAB:
13  *
14  * >>make mexArrayProduct.cpp
15  *
16  */
17 
18 //------------------------------------------------------------------------------
19 
20 #include "EasyLink.h"
21 
22 //------------------------------------------------------------------------------
23 
24 class Function : public BaseFunction {
25 public:
26 
27  // Specifies the number and the sizes of the input ports of the function
28  // (right-side arguments)
29 
30  static void initializeInputPortSizes() {
32  setInputPort(0, 1, 1, mxDOUBLE_CLASS);
33  setInputPort(1, -1, -1, mxDOUBLE_CLASS);
34  }
35 
36  // Specifies the number and the sizes of the output ports of the function
37  // (right-side arguments)
38 
39  static void initializeOutputPortSizes() {
41  setOutputPort(0, getInputNRows(1), getInputNCols(1), mxDOUBLE_CLASS);
42  }
43 
44  // Calculates the function
45 
46  static void outputs() {
47  double multiplier = getInputDouble(0);
48  Array<double> inArray = getInputArray<double>(1);
49  Array<double> outArray = getOutputArray<double>(0);
50  outArray = inArray*multiplier;
51  }
52 
53 };
54 
55 //------------------------------------------------------------------------------
56 
57 #include "mexDefinitions.h"
58 
59 //------------------------------------------------------------------------------
static void setInputPort(int port, int nRows, int nCols, mxClassID type=mxDOUBLE_CLASS, mxComplexity complexFlag=mxREAL)
Definition: BaseFunction.h:44
static void setOutputPort(int port, int nRows, int nCols, mxClassID type=mxDOUBLE_CLASS, mxComplexity complexFlag=mxREAL)
Definition: BaseFunction.h:88
static void initializeInputPortSizes()
Definition: BaseFunction.h:72
static int getInputNCols(int port)
Definition: BaseFunction.h:192
static void outputs()
Definition: BaseFunction.h:117
static double getInputDouble(int port)
Definition: BaseFunction.h:123
static void initializeOutputPortSizes()
Definition: BaseFunction.h:106
static void setInputPortsCount(int portsCount)
Definition: BaseFunction.h:33
static void setOutputPortsCount(int portsCount)
Definition: BaseFunction.h:79
static int getInputNRows(int port)
Definition: BaseFunction.h:185

Copyright (c) 2014 FEMTO-ST / ENSMM / UFC / UTBM, Besançon, France. Generated by Doxygen.