EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_MatlabEngine.cpp
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 
42 #include "EpetraExt_MatlabEngine.h"
44 #include "EpetraExt_PutRowMatrix.h"
45 #include "EpetraExt_PutBlockMap.h"
46 
47 #include "Epetra_Comm.h"
48 #include "Epetra_MultiVector.h"
51 #include "Epetra_IntVector.h"
52 #include "Epetra_RowMatrix.h"
53 #include "Epetra_DataAccess.h"
54 #include "Epetra_Import.h"
55 #include "Epetra_Export.h"
56 #include "Epetra_CombineMode.h"
57 #include "Epetra_CrsMatrix.h"
58 #include "Epetra_Map.h"
59 #include "Epetra_CrsMatrix.h"
60 
61 using namespace EpetraExt;
62 namespace EpetraExt {
63 
64 //=============================================================================
66  if (Comm_.MyPID() == 0) {
67  // construct the MATLAB engine
68  Engine_ = engOpen(NULL);
69  }
70 }
71 
72 //=============================================================================
74  if (Comm_.MyPID() == 0) {
75  // to destruct the MATLAB engine
76  engClose(Engine_);
77  }
78 }
79 
80 //=============================================================================
81 int EpetraExt_MatlabEngine::EvalString (char* command, char* outputBuffer, int outputBufferSize) {
82  // send a string command to the MATLAB engine
83  if (Comm_.MyPID() == 0) {
84  if (outputBuffer != NULL) {
85  if (engOutputBuffer(Engine_, outputBuffer, outputBufferSize)) {
86  return(-4);
87  }
88  }
89  if (engEvalString(Engine_, command)) {
90  return(-3);
91  }
92  }
93 
94  return(0);
95 }
96 
97 //=============================================================================
98 int EpetraExt_MatlabEngine::PutMultiVector(const Epetra_MultiVector& A, const char * variableName) {
99  mxArray* matlabA = 0;
100  double* pr = 0;
101  if (Comm_.MyPID() == 0) {
102  matlabA = mxCreateDoubleMatrix(A.GlobalLength(), A.NumVectors(), mxREAL);
103  pr = mxGetPr(matlabA);
104  }
105 
106  if (Matlab::CopyMultiVector(&pr, A)) {
107  mxDestroyArray(matlabA);
108  return(-2);
109  }
110 
111  if (Comm_.MyPID() == 0)
112  if (PutIntoMatlab(variableName, matlabA)) {
113  mxDestroyArray(matlabA);
114  return(-1);
115  }
116 
117  mxDestroyArray(matlabA);
118  return(0);
119 }
120 
121 //=============================================================================
122 int EpetraExt_MatlabEngine::PutRowMatrix(const Epetra_RowMatrix& A, const char* variableName, bool transA) {
123  mxArray* matlabA = 0;
124  if (Comm_.MyPID() == 0) {
125  // since matlab uses column major for matrices, switch row and column numbers
126  matlabA = mxCreateSparse(A.OperatorDomainMap().MaxAllGID() - A.OperatorDomainMap().MinAllGID()+1, A.OperatorRangeMap().MaxAllGID() - A.OperatorRangeMap().MinAllGID() + 1, A.NumGlobalNonzeros(), mxREAL);
127  }
128  //cout << "numrows: " << A.RowMatrixColMap().NumGlobalElements() << " numCols: " << A.NumGlobalRows() << "numNonZeros: " << A.NumGlobalNonzeros() << "\n";
129 
130  //cout << "calling CopyRowMatrix\n";
131  if (Matlab::CopyRowMatrix(matlabA, A)) {
132  mxDestroyArray(matlabA);
133  return(-2);
134  }
135 
136  //cout << "done doing CopyRowMatrix\n";
137  if (Comm_.MyPID() == 0) {
138 
139  /*cout << "printing matlabA pointers\n";
140  double* matlabAvaluesPtr = mxGetPr(matlabA);
141  int* matlabAcolumnIndicesPtr = mxGetJc(matlabA);
142  int* matlabArowIndicesPtr = mxGetIr(matlabA);
143  for(int i=0; i < A.NumGlobalNonzeros(); i++) {
144  cout << "*matlabAvaluesPtr: " << *matlabAvaluesPtr++ << " *matlabAcolumnIndicesPtr: " << *matlabAcolumnIndicesPtr++ << " *matlabArowIndicesPtr" << *matlabArowIndicesPtr++ << "\n";
145  }
146  cout << "done printing matlabA pointers\n";
147  */
148  if (PutIntoMatlab(variableName, matlabA)) {
149  mxDestroyArray(matlabA);
150  return(-1);
151  }
152 
153  if (!transA) {
154  char* buff = new char[128];;
155  sprintf(buff, "%s = %s'", variableName, variableName);
156  if (EvalString(buff)) {
157  mxDestroyArray(matlabA);
158  return(-3);
159  }
160  }
161  }
162 
163  //cout << "done with everything in PutRowMatrix, going to destroy matlabA\n" << "matlabA=" << matlabA << "\n";
164  mxDestroyArray(matlabA);
165  //cout << "done destroying matlabA\n";
166  return(0);
167 }
168 
169 //=============================================================================
170 int EpetraExt_MatlabEngine::PutCrsGraph(const Epetra_CrsGraph& A, const char* variableName, bool transA) {
171  return(-9999);
172 }
173 
174 //=============================================================================
175 int EpetraExt_MatlabEngine::PutSerialDenseMatrix(const Epetra_SerialDenseMatrix& A, const char* variableName, int proc) {
176  if (proc == 0) {
177  if (Comm_.MyPID() == 0) {
178  mxArray* matlabA = 0;
179 
180  int numRows = A.M();
181  int numCols = A.N();
182 
183  matlabA = mxCreateDoubleMatrix(numRows, numCols, mxREAL);
184 
185  int row;
186  int col;
187  double* targetPtr = 0;
188  double* sourcePtr = 0;
189  double* source = (double*)A.A();
190  double* target = (double*)mxGetPr(matlabA);
191  int source_LDA = A.LDA();
192  int target_LDA = A.LDA();
193  for (col = 0; col < numCols; col++) {
194  targetPtr = target + (col * target_LDA);
195  sourcePtr = source + (col * source_LDA);
196  for (row = 0; row < numRows; row++) {
197  *targetPtr++ = *sourcePtr++;
198  }
199  }
200 
201  if (PutIntoMatlab(variableName, matlabA)) {
202  mxDestroyArray(matlabA);
203  return(-1);
204  }
205 
206  mxDestroyArray(matlabA);
207  }
208 
209  return(0);
210  }
211  else {
212  Epetra_MultiVector* tempMultiVector = 0;
213  if (proc == Comm_.MyPID()) {
214  int* numVectors = new int[1];
215  int* temp = new int[1];
216  temp[0] = A.N();
217  Comm_.MaxAll (temp, numVectors, 1);
218  const Epetra_BlockMap tempBlockMap (-1, A.LDA(), 1, 0, Comm_);
219  tempMultiVector = new Epetra_MultiVector (View, tempBlockMap, A.A(), A.LDA(), A.N());
220  }
221  else {
222  int* numVectors = new int[1];
223  int* temp = new int[1];
224  temp[0] = 0;
225  Comm_.MaxAll (temp, numVectors, 1);
226  const Epetra_BlockMap tempBlockMap (-1, 0, 1, 0, Comm_);
227  tempMultiVector = new Epetra_MultiVector (tempBlockMap, numVectors[0], false);
228  }
229 
230  return(PutMultiVector(*tempMultiVector, variableName));
231  }
232 }
233 
234 //=============================================================================
235 int EpetraExt_MatlabEngine::PutIntSerialDenseMatrix(const Epetra_IntSerialDenseMatrix& A, const char* variableName, int proc) {
236  mxArray* matlabA = 0;
237 
238  if (proc == 0) {
239  if (Comm_.MyPID() == 0) {
240  int numRows = A.M();
241  int numCols = A.N();
242 
243  matlabA = mxCreateDoubleMatrix(numRows, numCols, mxREAL);
244 
245  int row;
246  int col;
247  double* targetPtr = 0;
248  int* sourcePtr = 0;
249  int* source = (int*)A.A();
250  double* target = (double*)mxGetPr(matlabA);
251  int source_LDA = A.LDA();
252  int target_LDA = A.LDA();
253  for (col = 0; col < numCols; col++) {
254  targetPtr = target + (col * target_LDA);
255  sourcePtr = source + (col * source_LDA);
256  for (row = 0; row < numRows; row++) {
257  *targetPtr++ = *sourcePtr++;
258  }
259  }
260 
261  if (PutIntoMatlab(variableName, matlabA)) {
262  mxDestroyArray(matlabA);
263  return(-1);
264  }
265  }
266  }
267  else {
268  int* numVectors = new int[2];
269  if (proc == Comm_.MyPID()) {
270  int* temp = new int[2];
271  temp[0] = A.N();
272  temp[1] = A.M();
273  Comm_.MaxAll (temp, numVectors, 2);
274  }
275  else {
276  int* temp = new int[2];
277  temp[0] = 0;
278  temp[1] = 0;
279  Comm_.MaxAll (temp, numVectors, 2);
280  }
281 
282  int numRows = numVectors[1];
283  int numCols = numVectors[0];
284  double* targetPtr = 0;
285  int* sourcePtr = 0;
286  int row;
287  double* target = 0;
288  const Epetra_BlockMap* tgBlockMap = 0;
289  if (Comm_.MyPID() == 0) {
290  matlabA = mxCreateDoubleMatrix(numRows, numCols, mxREAL);
291  target = (double*)mxGetPr(matlabA);
292  tgBlockMap = new Epetra_BlockMap(-1, numRows, 1, 0, Comm_);
293  }
294  else {
295  tgBlockMap = new Epetra_BlockMap(-1, 0, 1, 0, Comm_);
296  }
297 
298  const Epetra_BlockMap* srcBlockMap = 0;
299  Epetra_IntVector* srcIntVector = 0;
300  Epetra_IntVector tgIntVector (*tgBlockMap, false);
301  if (proc == Comm_.MyPID()) {
302  srcBlockMap = new Epetra_BlockMap(-1, A.LDA(), 1, 0, Comm_);
303  }
304  else {
305  srcBlockMap = new Epetra_BlockMap(-1, 0, 1, 0, Comm_);
306  }
307 
308  Epetra_Import importer (*tgBlockMap, *srcBlockMap);
309 
310  for(int i=0; i < numVectors[0]; i++) {
311  if (proc == Comm_.MyPID()) {
312  srcIntVector = new Epetra_IntVector(View, *srcBlockMap, (int*)A[i]);
313  }
314  else {
315  srcIntVector = new Epetra_IntVector(*srcBlockMap, false);
316  }
317  // need to add some error checking for this!
318  tgIntVector.Import(*srcIntVector, importer, Insert);
319  if (Comm_.MyPID() == 0) {
320  targetPtr = target + (i * numRows);
321  sourcePtr = (int*)tgIntVector.Values();
322  for (row = 0; row < numRows; row++) {
323  *targetPtr++ = *sourcePtr++;
324  }
325  }
326  }
327 
328  if (PutIntoMatlab(variableName, matlabA)) {
329  mxDestroyArray(matlabA);
330  return(-1);
331  }
332  }
333 
334  mxDestroyArray(matlabA);
335  return(0);
336 }
337 
338 //=============================================================================
339 int EpetraExt_MatlabEngine::PutBlockMap(const Epetra_BlockMap& blockMap, const char* variableName, bool transA) {
340  mxArray* matlabA = 0;
341  if (Comm_.MyPID() == 0) {
342  int M = blockMap.NumGlobalElements();
343  int N = 1;
344 
345  if (blockMap.MaxElementSize()>1) N = 2; // Non-trivial block map, store element sizes in second column
346 
347  matlabA = mxCreateSparse(N, M, M*N, mxREAL);
348  int* matlabAcolumnIndicesPtr = mxGetJc(matlabA);
349  matlabAcolumnIndicesPtr += M;
350  *matlabAcolumnIndicesPtr = M*N; // set max cap.
351  }
352 
353  if (Matlab::CopyBlockMap(matlabA, blockMap)) {
354  mxDestroyArray(matlabA);
355  return(-2);
356  }
357 
358  if (Comm_.MyPID() == 0) {
359  if (PutIntoMatlab(variableName, matlabA)) {
360  mxDestroyArray(matlabA);
361  return(-1);
362  }
363 
364  if (!transA) {
365  char* buff = new char[128];;
366  sprintf(buff, "%s = %s'", variableName, variableName);
367  if (EvalString(buff)) {
368  mxDestroyArray(matlabA);
369  return(-3);
370  }
371  }
372  }
373 
374  mxDestroyArray(matlabA);
375  return(0);
376 }
377 
378 //=============================================================================
379 int EpetraExt_MatlabEngine::PutIntoMatlab(const char* variableName, mxArray* matlabA) {
380  if (Comm_.MyPID() != 0) {
381  return(0);
382  }
383 #ifdef USE_ENGPUTARRAY
384  // for matlab versions < 6.5 (release 13)
385  mxSetName(matlabA, variableName);
386  return(engPutArray(Engine_, matlabA));
387 #else
388  // for matlab versions >= 6.5 (release 13)
389  return(engPutVariable(Engine_, variableName, matlabA));
390 #endif
391 }
392 
393 //=============================================================================
395  mxArray* matlabA = 0;
396  int ierr = 0;
397  if (ierr = GetmxArray(variableName, &matlabA)) {
398  mxDestroyArray(matlabA);
399  return(ierr);
400  }
401 
402  bool isSparse = false;
403  int numRows = 0;
404  int numCols = 0;
405  int numNonZeros = 0;
406 
407  if (ierr = GetmxArrayDimensions(matlabA, isSparse, numRows, numCols, numNonZeros)) {
408  mxDestroyArray(matlabA);
409  return(ierr);
410  }
411 
412  if ((Comm_.MyPID() == 0) && isSparse) {
413  mxDestroyArray(matlabA);
414  return(-7);
415  }
416 
417  // tempMap is nontrivial only on PE0
418  Epetra_Map tempMap (-1, numRows, 0, Comm_);
419 
420  int numVectors = 0;
421  Comm_.MaxAll (&numCols, &numVectors, 1);
422  double* tempValues = 0;
423  if (Comm_.MyPID() == 0) {
424  tempValues = mxGetPr(matlabA);
425  }
426  Epetra_MultiVector tempMV (View, tempMap, tempValues, numRows, numVectors);
427  Epetra_Export exporter (tempMap, A.Map());
428  A.Export(tempMV, exporter, Insert);
429 
430  mxDestroyArray(matlabA);
431  return(0);
432 }
433 
434 //=============================================================================
436  int ierr = 0;
437  int numMyGIDs = 0;
438  if (Comm_.MyPID() == proc) {
439  numMyGIDs = A.M();
440  }
441  Epetra_Map tempMap (-1, numMyGIDs, 0, Comm_);
442  Epetra_MultiVector tempMV (View, tempMap, A.A(), numMyGIDs, A.N());
443 
444  if (ierr = GetMultiVector(variableName, tempMV)) {
445  return(ierr);
446  }
447 
448  if (Comm_.MyPID() == proc) {
449  double* aValues = A.A();
450  double* mvValues = tempMV.Values();
451  for(int i=0; i < A.M() * A.N(); i++) {
452  *aValues++ = *mvValues++;
453  }
454  }
455 
456  return(0);
457 }
458 
459 //=============================================================================
461  int ierr = 0;
462  int numMyGIDs = 0;
463  double* values = 0;
464  if (Comm_.MyPID() == proc) {
465  numMyGIDs = A.M();
466  int* aValues = A.A();
467  values = new double[A.M() * A.N()];
468  for (int i=0; i < A.M() * A.N(); i++) {
469  *values++ = *aValues++;
470  }
471  }
472  Epetra_Map tempMap (-1, numMyGIDs, 0, Comm_);
473  Epetra_MultiVector tempMV (View, tempMap, values, numMyGIDs, A.N());
474 
475  if (ierr = GetMultiVector(variableName, tempMV)) {
476  return(ierr);
477  }
478 
479  if (Comm_.MyPID() == proc) {
480  int* aValues = A.A();
481  double* mvValues = tempMV.Values();
482  for(int i=0; i < A.M() * A.N(); i++) {
483  *aValues++ = *mvValues++;
484  }
485  }
486 
487  return(0);
488 }
489 
490 //=============================================================================
491 int EpetraExt_MatlabEngine::GetCrsMatrix(const char* inVariableName, Epetra_CrsMatrix& A, bool getTrans) {
492  const char* variableName;
493 
494  if (!getTrans) {
495  int inVariableNameLength = strlen(inVariableName);
496  char* buff = new char[inVariableNameLength*2 + 11];
497  sprintf(buff, "TRANS_%s = %s'", inVariableName, inVariableName);
498  if (EvalString(buff)) {
499  return(-3);
500  }
501  char* tempStr = new char[inVariableNameLength + 7];
502  sprintf(tempStr, "TRANS_%s", inVariableName);
503  variableName = tempStr;
504  }
505  else {
506  variableName = inVariableName;
507  }
508 
509  mxArray* matlabA = 0;
510  int ierr = 0;
511  if (ierr = GetmxArray(variableName, &matlabA)) {
512  mxDestroyArray(matlabA);
513  return(ierr);
514  }
515 
516  if (!getTrans) {
517  char* buff = new char[strlen(variableName) + 7];
518  sprintf(buff, "clear %s", variableName);
519  if (EvalString(buff)) {
520  return(-3);
521  }
522  }
523 
524  bool isSparse = false;
525  int numRows = 0;
526  int numCols = 0;
527  int numNonZeros = 0;
528 
529  // note that numCols and numRows are transposed on purpose here
530  // we will treat the column major mxArray as a row major mxArray
531  if (ierr = GetmxArrayDimensions(matlabA, isSparse, numCols, numRows, numNonZeros)) {
532  mxDestroyArray(matlabA);
533  return(ierr);
534  }
535 
536  if ((Comm_.MyPID() == 0) && !isSparse) {
537  mxDestroyArray(matlabA);
538  return(-8);
539  }
540 
541  // tempMap is nontrivial only on PE0
542  Epetra_Map tempMap (-1, numRows, 0, Comm_);
543 
544  int numVectors = 0;
545  Comm_.MaxAll (&numCols, &numVectors, 1);
546  Epetra_CrsMatrix tempCRSM (View, tempMap, numVectors);
547  if (Comm_.MyPID() == 0) {
548  int* rowIndex = mxGetJc(matlabA);
549  int* colIndex = mxGetIr(matlabA);
550  double* values = mxGetPr(matlabA);
551  int numCols = 0;
552  for(int row = 0; row < numRows; row++) {
553  numCols = *(rowIndex+1) - *rowIndex;
554  if (numCols > 0) {
555  int* indices = new int[numCols];
556  int* indicesPtr = indices;
557  for(int col=0; col < numCols; col++) {
558  *indicesPtr++ = *colIndex++;
559  }
560  tempCRSM.InsertGlobalValues(row, numCols, values, indices);
561  }
562  values += numCols;
563  rowIndex++;
564  }
565  }
566 
567  tempCRSM.FillComplete();
568  Epetra_Export exporter (tempMap, A.RowMatrixRowMap());
569  A.Export(tempCRSM, exporter, Insert);
570 
571  mxDestroyArray(matlabA);
572  return(0);
573 }
574 
575 //=============================================================================
576 int EpetraExt_MatlabEngine::GetmxArrayDimensions(mxArray* matlabA, bool& isSparse, int& numRows, int& numCols, int& numNonZeros) {
577  if (Comm_.MyPID() == 0) {
578  if (mxGetNumberOfDimensions(matlabA) > 2) {
579  return(-6);
580  }
581 
582  const int* dimensions = mxGetDimensions(matlabA);
583  numRows = dimensions[0];
584  numCols = dimensions[1];
585  isSparse = mxIsSparse(matlabA);
586 
587  if (isSparse) {
588  numNonZeros = mxGetNzmax(matlabA);
589  }
590  else {
591  numNonZeros = numRows * numCols;
592  }
593  }
594 
595  return(0);
596 }
597 
598 //=============================================================================
599 int EpetraExt_MatlabEngine::GetmxArray(const char* variableName, mxArray** matlabA) {
600  if (Comm_.MyPID() == 0) {
601 #ifdef USE_ENGPUTARRAY
602  // for matlab versions < 6.5 (release 13)
603  *matlabA = engGetArray(Engine_, variableName);
604 #else
605  // for matlab versions >= 6.5 (release 13)
606  *matlabA = engGetVariable(Engine_, variableName);
607 #endif
608  if (matlabA == NULL) {
609  return(-5);
610  }
611  }
612 
613  return(0);
614 }
615 
616 } // namespace EpetraExt
int NumGlobalElements() const
int CopyMultiVector(double **matlabApr, const Epetra_MultiVector &A)
int GetIntSerialDenseMatrix(const char *variableName, Epetra_IntSerialDenseMatrix &A, int proc=0)
Puts a Matlab variable into a IntSerialDenseMatrix on the specified PE.
int CopyBlockMap(mxArray *matlabA, const Epetra_BlockMap &map)
int GetCrsMatrix(const char *variableName, Epetra_CrsMatrix &A, bool getTrans)
Puts a Matlab variable into a CrsMatrix.
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)
const Epetra_Map & RowMatrixRowMap() const
int PutSerialDenseMatrix(const Epetra_SerialDenseMatrix &A, const char *variableName, int proc=0)
Puts a copy of the SerialDenseMatrix into the Matlab workspace.
virtual const Epetra_Map & OperatorDomainMap() const =0
int * Values() const
EpetraExt_MatlabEngine(const Epetra_Comm &Comm)
EpetraExt_MatlabEngine constructor which creates a MatlabEngine object with a connection to an instan...
virtual int NumGlobalNonzeros() const =0
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
int GetSerialDenseMatrix(const char *variableName, Epetra_SerialDenseMatrix &A, int proc=0)
Puts a Matlab variable into a SerialDenseMatrix on the specified PE.
const int * A() const
int GetMultiVector(const char *variableName, Epetra_MultiVector &A)
Puts a Matlab variable into a MultiVector.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
double * A() const
const int N
virtual const Epetra_Map & OperatorRangeMap() const =0
virtual const Epetra_BlockMap & Map() const =0
int CopyRowMatrix(mxArray *matlabA, const Epetra_RowMatrix &A)
int MinAllGID() const
~EpetraExt_MatlabEngine()
EpetraExt_MatlabEngine destructor which closes the connection to Matlab which causes the Matlab proce...
int GetmxArray(const char *variableName, mxArray **matlabA)
Get a mxArray from Matlab. For internal use but can be used by an advanced user.
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 MaxElementSize() const
int PutCrsGraph(const Epetra_CrsGraph &A, const char *variableName, bool transA)
not implemented yet
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.
int PutIntoMatlab(const char *variableName, mxArray *matlabA)
Puts a mxArray into Matlab.
int MaxAllGID() const