84 if (outputBuffer != NULL) {
85 if (engOutputBuffer(
Engine_, outputBuffer, outputBufferSize)) {
89 if (engEvalString(
Engine_, command)) {
102 matlabA = mxCreateDoubleMatrix(
A.GlobalLength(),
A.NumVectors(), mxREAL);
103 pr = mxGetPr(matlabA);
107 mxDestroyArray(matlabA);
113 mxDestroyArray(matlabA);
117 mxDestroyArray(matlabA);
123 mxArray* matlabA = 0;
126 matlabA = mxCreateSparse(
A.OperatorDomainMap().MaxAllGID() -
A.OperatorDomainMap().MinAllGID()+1,
A.OperatorRangeMap().MaxAllGID() -
A.OperatorRangeMap().MinAllGID() + 1,
A.NumGlobalNonzeros(), mxREAL);
132 mxDestroyArray(matlabA);
149 mxDestroyArray(matlabA);
154 char* buff =
new char[128];;
155 sprintf(buff,
"%s = %s'", variableName, variableName);
157 mxDestroyArray(matlabA);
164 mxDestroyArray(matlabA);
178 mxArray* matlabA = 0;
183 matlabA = mxCreateDoubleMatrix(numRows, numCols, mxREAL);
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++;
202 mxDestroyArray(matlabA);
206 mxDestroyArray(matlabA);
214 int* numVectors =
new int[1];
215 int* temp =
new int[1];
222 int* numVectors =
new int[1];
223 int* temp =
new int[1];
236 mxArray* matlabA = 0;
243 matlabA = mxCreateDoubleMatrix(numRows, numCols, mxREAL);
247 double* targetPtr = 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++;
262 mxDestroyArray(matlabA);
268 int* numVectors =
new int[2];
270 int* temp =
new int[2];
276 int* temp =
new int[2];
282 int numRows = numVectors[1];
283 int numCols = numVectors[0];
284 double* targetPtr = 0;
290 matlabA = mxCreateDoubleMatrix(numRows, numCols, mxREAL);
291 target = (
double*)mxGetPr(matlabA);
310 for(
int i=0; i < numVectors[0]; i++) {
320 targetPtr = target + (i * numRows);
321 sourcePtr = (
int*)tgIntVector.
Values();
322 for (row = 0; row < numRows; row++) {
323 *targetPtr++ = *sourcePtr++;
329 mxDestroyArray(matlabA);
334 mxDestroyArray(matlabA);
340 mxArray* matlabA = 0;
347 matlabA = mxCreateSparse(
N, M, M*
N, mxREAL);
348 int* matlabAcolumnIndicesPtr = mxGetJc(matlabA);
349 matlabAcolumnIndicesPtr += M;
350 *matlabAcolumnIndicesPtr = M*
N;
354 mxDestroyArray(matlabA);
360 mxDestroyArray(matlabA);
365 char* buff =
new char[128];;
366 sprintf(buff,
"%s = %s'", variableName, variableName);
368 mxDestroyArray(matlabA);
374 mxDestroyArray(matlabA);
383 #ifdef USE_ENGPUTARRAY
385 mxSetName(matlabA, variableName);
386 return(engPutArray(
Engine_, matlabA));
389 return(engPutVariable(
Engine_, variableName, matlabA));
395 mxArray* matlabA = 0;
397 if (ierr =
GetmxArray(variableName, &matlabA)) {
398 mxDestroyArray(matlabA);
402 bool isSparse =
false;
408 mxDestroyArray(matlabA);
413 mxDestroyArray(matlabA);
422 double* tempValues = 0;
424 tempValues = mxGetPr(matlabA);
428 A.Export(tempMV, exporter,
Insert);
430 mxDestroyArray(matlabA);
449 double* aValues =
A.
A();
450 double* mvValues = tempMV.Values();
451 for(
int i=0; i <
A.M() *
A.N(); i++) {
452 *aValues++ = *mvValues++;
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++;
480 int* aValues =
A.
A();
481 double* mvValues = tempMV.Values();
482 for(
int i=0; i <
A.M() *
A.N(); i++) {
483 *aValues++ = *mvValues++;
492 const char* variableName;
495 int inVariableNameLength = strlen(inVariableName);
496 char* buff =
new char[inVariableNameLength*2 + 11];
497 sprintf(buff,
"TRANS_%s = %s'", inVariableName, inVariableName);
501 char* tempStr =
new char[inVariableNameLength + 7];
502 sprintf(tempStr,
"TRANS_%s", inVariableName);
503 variableName = tempStr;
506 variableName = inVariableName;
509 mxArray* matlabA = 0;
511 if (ierr =
GetmxArray(variableName, &matlabA)) {
512 mxDestroyArray(matlabA);
517 char* buff =
new char[strlen(variableName) + 7];
518 sprintf(buff,
"clear %s", variableName);
524 bool isSparse =
false;
532 mxDestroyArray(matlabA);
537 mxDestroyArray(matlabA);
548 int* rowIndex = mxGetJc(matlabA);
549 int* colIndex = mxGetIr(matlabA);
550 double* values = mxGetPr(matlabA);
552 for(
int row = 0; row < numRows; row++) {
553 numCols = *(rowIndex+1) - *rowIndex;
555 int* indices =
new int[numCols];
556 int* indicesPtr = indices;
557 for(
int col=0; col < numCols; col++) {
558 *indicesPtr++ = *colIndex++;
569 A.Export(tempCRSM, exporter,
Insert);
571 mxDestroyArray(matlabA);
578 if (mxGetNumberOfDimensions(matlabA) > 2) {
582 const int* dimensions = mxGetDimensions(matlabA);
583 numRows = dimensions[0];
584 numCols = dimensions[1];
585 isSparse = mxIsSparse(matlabA);
588 numNonZeros = mxGetNzmax(matlabA);
591 numNonZeros = numRows * numCols;
601 #ifdef USE_ENGPUTARRAY
603 *matlabA = engGetArray(
Engine_, variableName);
606 *matlabA = engGetVariable(
Engine_, variableName);
608 if (matlabA == NULL) {