67 int main(
int argc, 
char *argv[]) {
 
   71   MPI_Init(&argc,&argv);
 
   77   int MyPID = comm.
MyPID();
 
   79   bool verbose = (0 == MyPID);
 
   80   bool reportErrors = (0 == MyPID);
 
   82   if (verbose) cout << 
"going to startup a matlab process...\n";
 
   84   if (verbose) cout << 
"matlab started\n";
 
   88   int numGlobalElements = M * comm.
NumProc();
 
   90   int numMyEntries = M * 
N;
 
   91   double* 
A = 
new double[numMyEntries];
 
   93   int startValue = numMyEntries * MyPID;
 
   95   for(
int col=0; col < 
N; col++) {
 
   96   for(
int row=0; row < M; row++) {
 
   97           *Aptr++ = startValue++;
 
  102   int* intA = 
new int[numMyEntries];
 
  104   int intStartValue = numMyEntries * MyPID;
 
  105   for(
int i=0; i < M*
N; i++) {
 
  106       *intAptr++ = intStartValue++;
 
  114   if (verbose) cout << 
" constructing CrsMatrix...\n";
 
  116   int* indices = 
new int[
N];
 
  117   for (
int col=0; col < 
N; col++) {
 
  121   double value = startValue;
 
  122   double* values = 
new double[numMyEntries];
 
  124   for (
int row=0; row < M; row++) {
 
  125     for (
int col=0; col < 
N; col++) {
 
  126       values[col] = value++;
 
  133   if (verbose) cout << 
" CrsMatrix constructed\n";
 
  134   if (verbose) cout << 
" putting CrsMatrix into Matlab as CRSM\n";
 
  137     if (reportErrors) cout << 
"There was an error in engine.PutRowMatrix(crsMatrix, \"CRSM\", false): " << ierr << endl;
 
  142   if (verbose) cout << 
" putting Map into Matlab as MAP\n";
 
  145     if (reportErrors) cout << 
"There was an error in engine.PutBlockMap(map, \"MAP\", false);: " << ierr << endl;
 
  150   if (verbose) cout << 
" constructing MultiVector...\n";
 
  152   if (verbose) cout << 
" MultiVector constructed\n";
 
  153   if (verbose) cout << 
" putting MultiVector into Matlab as MV\n";
 
  156     if (reportErrors) cout << 
"There was an error in engine.PutMultiVector(multiVector, \"MV\"): " << ierr << endl;
 
  161   if (verbose) cout << 
" constructing a SerialDenseMatrix...\n";
 
  163   if (verbose) cout << 
" SerialDenseMatrix constructed\n";
 
  164   if (verbose) cout << 
" putting SerialDenseMatrix from PE0 into Matlab as SDM_PE0\n";
 
  168     if (reportErrors) cout << 
"There was an error in engine.PutSerialDenseMatrix(sdMatrix, \"SDM_PE0\"): " << ierr << endl;
 
  171     if (verbose) cout << 
" putting SerialDenseMatrix from PE1 into Matlab as SDM_PE1\n";
 
  175       if (reportErrors) cout << 
"There was an error in engine.PutSerialDenseMatrix(sdMatrix, \"SDM_PE1\", 1): " << ierr << endl;
 
  182   if (verbose) cout << 
" constructing a SerialDenseVector...\n";
 
  184   if (verbose) cout << 
" SerialDenseVector constructed\n";
 
  186   if (verbose) cout << 
" putting SerialDenseVector from PE0 into Matlab as SDV_PE0\n";
 
  189     if (reportErrors) cout << 
"There was an error in engine.PutSerialDenseMatrix(sdVector, \"SDV_PE0\"): " << ierr << endl;
 
  192     if (verbose) cout << 
" putting SerialDenseVector from PE1 into Matlab as SDV_PE1\n";
 
  196       if (reportErrors) cout << 
"There was an error in engine.PutSerialDenseMatrix(sdMatrix, \"SDV_PE1\", 1): " << ierr << endl;
 
  202   if (verbose) cout << 
" constructing a IntSerialDenseMatrix...\n";
 
  204   if (verbose) cout << 
" IntSerialDenseMatrix constructed\n";
 
  206   if (verbose) cout << 
" putting IntSerialDenseMatrix from PE0 into Matlab as ISDM_PE0\n";
 
  209     if (reportErrors) cout << 
"There was an error in engine.PutIntSerialDenseMatrix(isdMatrix, \"ISDM_PE0\"): " << ierr << endl;
 
  212     if (verbose) cout << 
" putting IntSerialDenseMatrix from PE1 into Matlab as ISDM_PE1\n";
 
  216       if (reportErrors) cout << 
"There was an error in engine.PutSerialDenseMatrix(isdMatrix, \"ISDM_PE1\", 1): " << ierr << endl;
 
  223   if (verbose) cout << 
" constructing a IntSerialDenseVector...\n";
 
  225   if (verbose) cout << 
" IntSerialDenseVector constructed\n";
 
  227   if (verbose) cout << 
" putting IntSerialDenseVector from PE0 into Matlab as ISDV_PE0\n";
 
  230     if (reportErrors) cout << 
"There was an error in engine.PutIntSerialDenseMatrix(isdVector, \"ISDV_PE0\"): " << ierr << endl;
 
  233     if (verbose) cout << 
" putting IntSerialDenseVector from PE1 into Matlab as ISDV_PE1\n";
 
  237       if (reportErrors) cout << 
"There was an error in engine.PutSerialDenseMatrix(isdVector, \"ISDV_PE1\", 1): " << ierr << endl;
 
  249   const int bufSize = 200;
 
  251   const int matlabBufferSize = 1024 * 16;
 
  252   char matlabBuffer [matlabBufferSize];
 
  255   engine.
EvalString(
"whos", matlabBuffer, matlabBufferSize);
 
  256   if (verbose) cout << matlabBuffer << endl;
 
  257   engine.
EvalString(
"SDV_PE0", matlabBuffer, matlabBufferSize);
 
  258   if (verbose) cout << matlabBuffer << endl;
 
  260     engine.
EvalString(
"SDV_PE1", matlabBuffer, matlabBufferSize);
 
  261     if (verbose) cout << matlabBuffer << endl;
 
  269       if (fgets(s, bufSize, stdin) == NULL) {
 
  273       printf (
"command :%s:\n", s) ;
 
  277       ierr = engine.
EvalString(s, matlabBuffer, matlabBufferSize);
 
  279           printf(
"there was an error: %d", ierr);
 
  283           printf(
"Matlab Output:\n%s", matlabBuffer);
 
  287   if (verbose) cout << endl << 
" all done\n";
 
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. 
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
int PutSerialDenseMatrix(const Epetra_SerialDenseMatrix &A, const char *variableName, int proc=0)
Puts a copy of the SerialDenseMatrix into the Matlab workspace. 
int FillComplete(bool OptimizeDataStorage=true)
int main(int argc, char **argv)
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 PutMultiVector(const Epetra_MultiVector &A, const char *variableName)
Puts a copy of the serial or distributed MultiVector into the Matlab workspace. 
int EvalString(char *command, char *outputBuffer=NULL, int outputBufferSize=-1)
Sends a command to Matlab. 
A class which provides data and command access to Matlab from Epetra.