#include <EpetraExt_MatlabEngine.h>
Constructors/destructors. | |
| EpetraExt_MatlabEngine (const Epetra_Comm &Comm) | |
| EpetraExt_MatlabEngine constructor which creates a MatlabEngine object with a connection to an instance of the application Matlab by starting a new Matlab process. | |
| ~EpetraExt_MatlabEngine () | |
| EpetraExt_MatlabEngine destructor which closes the connection to Matlab which causes the Matlab process to also exit. | |
General Epetra to Matlab Access Methods | |
| int | EvalString (char *command, char *outputBuffer=NULL, int outputBufferSize=-1) |
| Sends a command to Matlab. | |
Epetra to Matlab Data Transfer Methods | |
| int | PutMultiVector (const Epetra_MultiVector &A, const char *variableName) |
| Puts a copy of the serial or distributed MultiVector into the Matlab workspace. | |
| int | PutRowMatrix (const Epetra_RowMatrix &A, const char *variableName, bool transA) |
| Puts a copy of the serial or distributed RowMatrix into the Matlab workspace. | |
| int | PutCrsGraph (const Epetra_CrsGraph &A, const char *variableName, bool transA) |
| not implemented yet | |
| int | PutSerialDenseMatrix (const Epetra_SerialDenseMatrix &A, const char *variableName, int proc=0) |
| Puts a copy of the SerialDenseMatrix into the Matlab workspace. | |
| int | PutIntSerialDenseMatrix (const Epetra_IntSerialDenseMatrix &A, const char *variableName, int proc=0) |
| Puts a copy of the IntSerialDenseMatrix into the Matlab workspace. | |
| int | PutBlockMap (const Epetra_BlockMap &blockMap, const char *variableName, bool transA) |
| Puts a copy of the BlockMap or Map into the Matlab workspace. | |
| int | PutIntoMatlab (const char *variableName, mxArray *matlabA) |
| Puts a mxArray into Matlab. | |
Matlab to Epetra Data Transfer Methods | |
| int | GetMultiVector (const char *variableName, Epetra_MultiVector &A) |
| Puts a Matlab variable into a MultiVector. | |
| int | GetSerialDenseMatrix (const char *variableName, Epetra_SerialDenseMatrix &A, int proc=0) |
| Puts a Matlab variable into a SerialDenseMatrix on the specified PE. | |
| int | GetIntSerialDenseMatrix (const char *variableName, Epetra_IntSerialDenseMatrix &A, int proc=0) |
| Puts a Matlab variable into a IntSerialDenseMatrix on the specified PE. | |
| int | GetCrsMatrix (const char *variableName, Epetra_CrsMatrix &A, bool getTrans) |
| Puts a Matlab variable into a CrsMatrix. | |
General Matlab to Epetra Access Methods | |
| int | GetmxArrayDimensions (mxArray *matlabA, bool &isSparse, int &numRows, int &numCols, int &numNonZeros) |
| Get general information about the mxArray. For internal use but can be used by an advanced user. | |
| int | GetmxArray (const char *variableName, mxArray **matlabA) |
| Get a mxArray from Matlab. For internal use but can be used by an advanced user. | |
Private Attributes | |
| Engine * | Engine_ |
| const Epetra_Comm & | Comm_ |
The EpetraExt_MatlabEngine class allows Epetra data objects to be exported to Matlab and then operated on within Matlab using Matlab commands.
When an EpetraExt_MatlabEngine object is constructed a new instance of the application Matlab is started for EpetraExt_MatlabEngine to communicate with. All communication between EpetraExt_MatlabEngine and Matlab occurs on the root node (0) only. For parallel environments all objects are collected onto the root node before being put into Matlab. Object data is put into a mxArray which is then sent to the Matlab process. All objects passed to Matlab are copied into the Matlab memory space. So at the point when Matlab receives its copy of the data there is two copies of the mxArray in memory, one in the Epetra application and one in Matlab. Since Matlab has its own memory space the mxArray in the Epetra application should be deleted in order to free up memory space. All methods in EpetraExt_MatlabEngine that put Epetra objects into Matlab delete the temporary mxArray as soon as it is put into Matlab. If a user desires to create his/her own mxArray's and then send them to Matlab the method PutIntoMatlab can be used. It is important to note that PutIntoMatlab does NOT delete the mxArray it is passed. When the EpetraExt_MatlabEngine deconstructor is called the instance of Matlab that was started during construction of the EpetraExt_MatlabEngine object exits.
Error Codes
Build Instructions
These instructions can be found in the file Trilinos/packages/epetraext/doc/matlab.README.
Example Code
The following example code generates simple Epetra objects and then puts them into Matlab.
The point of this example is to illustrate the flow of calls when using EpetraExt_MatlabEngine. This example program can be found in the file Trilinos/packages/epetraext/example/matlab/cxx_main.cpp.
Definition at line 102 of file EpetraExt_MatlabEngine.h.
|
|
EpetraExt_MatlabEngine constructor which creates a MatlabEngine object with a connection to an instance of the application Matlab by starting a new Matlab process.
Definition at line 52 of file EpetraExt_MatlabEngine.cpp. |
|
|
EpetraExt_MatlabEngine destructor which closes the connection to Matlab which causes the Matlab process to also exit.
Definition at line 60 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Sends a command to Matlab. Any command that can normally be typed in at the Matlab command line can be passed in to EvalString(char* command). Commands such as 'help desk', 'edit', and 'plot(MATRIX)' will pop up an interactive window.
Definition at line 68 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||
|
Puts a copy of the serial or distributed MultiVector into the Matlab workspace.
Definition at line 85 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a copy of the serial or distributed RowMatrix into the Matlab workspace.
Definition at line 109 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
not implemented yet
Definition at line 157 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a copy of the SerialDenseMatrix into the Matlab workspace.
Definition at line 162 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a copy of the IntSerialDenseMatrix into the Matlab workspace.
Definition at line 222 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a copy of the BlockMap or Map into the Matlab workspace.
Definition at line 326 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||
|
Puts a mxArray into Matlab. The Matlab provided C library provides mxArray which is used to construct and fill a Matlab object before sending it to Matlab to be put into the Matlab workspace. The mxArray is copied into the Matlab memory space and is not needed after it has been passed to Matlab. mxArrays should be destroyed using mxDestoryArray(mxArray) when they are no longer needed by the C/C++ program using them. Objects in Matlab must be destroyed using EvalString(char* command) and the appropriate Matlab command to destroy the object. EpetraExt::MatlabEngine uses PutIntoMatlab to pass all mxArrays it generates into Matlab. However, a user can create, fill, and put his/her own mxArrays into Matlab using this method. To create a mxArray mex.h must be included. For more information on how to use mxArrays see Matlab's documentation (type helpdesk at the Matlab command prompt) and see the External API Reference section.
Definition at line 366 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||
|
Puts a Matlab variable into a MultiVector. The values from the Matlab variable are exported to the MultiVector using an export object. Therefore the MultiVector must be prepared by the user just like any MultiVector would be before calling an export.
Definition at line 381 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a Matlab variable into a SerialDenseMatrix on the specified PE. The SerialDenseMatrix must be constructed by the user and have the proper amount of space to hold the values that will be copied from the given Matlab variable.
Definition at line 422 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a Matlab variable into a IntSerialDenseMatrix on the specified PE. The IntSerialDenseMatrix must be constructed by the user and have the proper amount of space to hold the values that will be copied from the given Matlab variable.
Definition at line 447 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||
|
Puts a Matlab variable into a CrsMatrix. The values from the Matlab variable are exported to the CrsMatrix using an export object. Therefore the CrsMatrix must be prepared by the user just like any CrsMatrix would be before calling an export.
Definition at line 478 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||||||||||||||
|
Get general information about the mxArray. For internal use but can be used by an advanced user. Makes several Matlab function calls on the mxArray in order to determine the number of rows, columns, nonzeros, and whether or not the mxArray is sparse.
Definition at line 563 of file EpetraExt_MatlabEngine.cpp. |
|
||||||||||||
|
Get a mxArray from Matlab. For internal use but can be used by an advanced user. Calls the Matlab provided engGetVariable function which copies the specified variable from the Matlab workspace into a mxArray. Hence any changes to mxArray will not show up in Matlab, and any changes to the Matlab variable in Matlab will not show up in the mxArray. When finished with the mxArray mxDestroyArray should be called on the mxArray. Matlab appears to perform a copy to a new mxArray each time engGetVariable is called.
Definition at line 586 of file EpetraExt_MatlabEngine.cpp. |
|
|
Definition at line 375 of file EpetraExt_MatlabEngine.h. |
|
|
Definition at line 377 of file EpetraExt_MatlabEngine.h. |
1.3.9.1