177 void mxArray2Ccvec(
const mxArray *in,
double *out_real,
double *out_imag);
186 void mxArray2Ccmat(
const mxArray *in,
double **out_real,
double **out_imag);
199 void Ccvec2mxArray(
double *in_real,
double *in_imag, mxArray *out);
208 void Ccmat2mxArray(
double **in_real,
double **in_imag, mxArray *out);
218 double* temp = (
double*) mxGetPr(in);
219 if (temp == 0) mexErrMsgTxt(
"mxArray2bin: Pointer to data is NULL");
220 size = mxGetNumberOfElements(in);
221 if (size != 1) mexErrMsgTxt(
"mxArray2bin: Size of data is not equal to one");
223 return (((*temp) > 0.0) ?
bin(1) :
bin(0));
229 double* temp = (
double*) mxGetPr(in);
230 if (temp == 0) mexErrMsgTxt(
"mxArray2short: Pointer to data is NULL");
231 size = mxGetNumberOfElements(in);
232 if (size != 1) mexErrMsgTxt(
"mxArray2short: Size of data is not equal to one");
234 return (
short)(*temp);
240 double* temp = (
double*) mxGetPr(in);
241 if (temp == 0) mexErrMsgTxt(
"mxArray2int: Pointer to data is NULL");
242 size = mxGetNumberOfElements(in);
243 if (size != 1) mexErrMsgTxt(
"mxArray2int: Size of data is not equal to one");
251 double* temp = (
double*) mxGetPr(in);
252 if (temp == 0) mexErrMsgTxt(
"mxArray2double: Pointer to data is NULL");
253 size = mxGetNumberOfElements(in);
254 if (size != 1) mexErrMsgTxt(
"mxArray2double: Size of data is not equal to one");
262 double* tempR = (
double*) mxGetPr(in);
263 double* tempI = (
double*) mxGetPi(in);
265 if ((tempR == 0) && (tempI == 0)) mexErrMsgTxt(
"mxArray2double_complex: Pointer to data is NULL");
267 size = mxGetNumberOfElements(in);
268 if (size != 1) mexErrMsgTxt(
"mxArray2double_complex: Size of data is not equal to one");
271 return std::complex<double>(0.0 , (*tempI));
273 else if (tempI == 0) {
274 return std::complex<double>((*tempR), 0.0);
277 return std::complex<double>((*tempR), (*tempI));
285 mexErrMsgTxt(
"mxArray2string: Pointer to data is NULL");
286 std::string str = mxArrayToString(in);
288 mexErrMsgTxt(
"mxArray2string: Could not convert mxArray to string");
296 double* temp = (
double*) mxGetPr(in);
297 if (temp == 0) mexErrMsgTxt(
"mxArray2bvec: Pointer to data is NULL");
299 size = mxGetNumberOfElements(in);
300 if (size == 0) mexErrMsgTxt(
"mxArray2bvec: Size of data is zero");
302 out.set_size(size,
false);
304 for (i = 0; i <
size; i++) {
305 out(i) = (((*temp++) > 1e-5) ?
bin(1) :
bin(0));
316 double* temp = (
double*) mxGetPr(in);
317 if (temp == 0) mexErrMsgTxt(
"mxArray2svec: Pointer to data is NULL");
319 size = mxGetNumberOfElements(in);
320 if (size == 0) mexErrMsgTxt(
"mxArray2svec: Size of data is zero");
322 out.set_size(size,
false);
324 for (i = 0; i <
size; i++) {
325 out(i) = (short)(*temp++);
336 double* temp = (
double*) mxGetPr(in);
337 if (temp == 0) mexErrMsgTxt(
"mxArray2ivec: Pointer to data is NULL");
339 size = mxGetNumberOfElements(in);
340 if (size == 0) mexErrMsgTxt(
"mxArray2ivec: Size of data is zero");
342 out.set_size(size,
false);
344 for (i = 0; i <
size; i++) {
345 out(i) = (int)(*temp++);
356 double* temp = (
double*) mxGetPr(in);
357 if (temp == 0) mexErrMsgTxt(
"mxArray2vec: Pointer to data is NULL");
359 size = mxGetNumberOfElements(in);
360 if (size == 0) mexErrMsgTxt(
"mxArray2vec: Size of data is zero");
362 out.set_size(size,
false);
364 for (i = 0; i <
size; i++) {
376 double* tempR = (
double*) mxGetPr(in);
377 double* tempI = (
double*) mxGetPi(in);
379 if ((tempR == 0) && (tempI == 0)) mexErrMsgTxt(
"mxArray2cvec: Pointer data is NULL");
381 size = mxGetNumberOfElements(in);
382 if (size == 0) mexErrMsgTxt(
"mxArray2cvec: Size of data is zero");
384 out.set_size(size,
false);
387 for (i = 0; i <
size; i++) { out(i) = std::complex<double>(0.0, (*tempI++)); }
389 else if (tempI == 0) {
390 for (i = 0; i <
size; i++) { out(i) = std::complex<double>((*tempR++), 0.0); }
393 for (i = 0; i <
size; i++) { out(i) = std::complex<double>((*tempR++), (*tempI++)); }
403 int r, c, rows, cols;
404 double* temp = (
double*) mxGetPr(in);
405 if (temp == 0) mexErrMsgTxt(
"mxArray2bmat: Pointer to data is NULL");
408 if (rows == 0) mexErrMsgTxt(
"mxArray2bmat: Data has zero rows");
410 if (cols == 0) mexErrMsgTxt(
"mxArray2bmat: Data has zero columns");
412 out.set_size(rows, cols,
false);
414 for (c = 0; c < cols; c++) {
415 for (r = 0; r < rows; r++) {
416 out(r, c) = (((*temp++) > 0.0) ?
bin(1) :
bin(0));
427 int r, c, rows, cols;
428 double* temp = (
double*) mxGetPr(in);
429 if (temp == 0) mexErrMsgTxt(
"mxArray2smat: Pointer to data is NULL");
432 if (rows == 0) mexErrMsgTxt(
"mxArray2smat: Data has zero rows");
434 if (cols == 0) mexErrMsgTxt(
"mxArray2smat: Data has zero columns");
436 out.set_size(rows, cols,
false);
438 for (c = 0; c < cols; c++) {
439 for (r = 0; r < rows; r++) {
440 out(r, c) = (short)(*temp++);
451 int r, c, rows, cols;
452 double* temp = (
double*) mxGetPr(in);
453 if (temp == 0) mexErrMsgTxt(
"mxArray2imat: Pointer to data is NULL");
456 if (rows == 0) mexErrMsgTxt(
"mxArray2imat: Data has zero rows");
458 if (cols == 0) mexErrMsgTxt(
"mxArray2imat: Data has zero columns");
459 out.set_size(rows, cols,
false);
461 for (c = 0; c < cols; c++) {
462 for (r = 0; r < rows; r++) {
463 out(r, c) = (int)(*temp++);
474 int r, c, rows, cols;
475 double* temp = (
double*) mxGetPr(in);
476 if (temp == 0) mexErrMsgTxt(
"mxArray2mat: Pointer to data is NULL");
479 if (rows == 0) mexErrMsgTxt(
"mxArray2mat: Data has zero rows");
481 if (cols == 0) mexErrMsgTxt(
"mxArray2mat: Data has zero columns");
482 out.set_size(rows, cols,
false);
484 for (c = 0; c < cols; c++) {
485 for (r = 0; r < rows; r++) {
486 out(r, c) = (*temp++);
497 int r, c, rows, cols;
498 double* tempR = (
double*) mxGetPr(in);
499 double* tempI = (
double*) mxGetPi(in);
501 if ((tempR == 0) && (tempI == 0)) mexErrMsgTxt(
"mxArray2cmat: Pointer to data is NULL");
504 if (rows == 0) mexErrMsgTxt(
"mxArray2cmat: Data has zero rows");
506 if (cols == 0) mexErrMsgTxt(
"mxArray2cmat: Data has zero columns");
507 out.set_size(rows, cols,
false);
510 for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) { out(r, c) = std::complex<double>(0.0 , (*tempI++)); } }
512 else if (tempI == 0) {
513 for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) { out(r, c) = std::complex<double>((*tempR++), 0.0); } }
516 for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) { out(r, c) = std::complex<double>((*tempR++), (*tempI++)); } }
525 double* temp = (
double *) mxGetPr(out);
526 if (temp == 0) mexErrMsgTxt(
"double2mxArray: Pointer to data is NULL");
533 double* tempR = (
double *) mxGetPr(out);
534 double* tempI = (
double *) mxGetPi(out);
535 if (tempR == 0) mexErrMsgTxt(
"double_complex2mxArray: Pointer to real valued part is NULL");
536 if (tempI == 0) mexErrMsgTxt(
"double_complex2mxArray: Pointer to imaginary valued part is NULL");
538 *tempR = (double) in.real();
539 *tempI = (double) in.imag();
545 mexErrMsgTxt(
"string2mxArray: Pointer to string is NULL");
546 out = mxCreateString(in.data());
548 mexErrMsgTxt(
"string2mxArray: Could not convert string to mxArray");
553 double* temp = (
double *) mxGetPr(out);
554 if (temp == 0) mexErrMsgTxt(
"bvec2mxArray: Pointer to data is NULL");
555 if (in.size() == 0) mexErrMsgTxt(
"bvec2mxArray: Size of data is zero");
556 for (
int i = 0; i < in.size(); i++) {
566 double* temp = (
double *) mxGetPr(out);
567 if (temp == 0) mexErrMsgTxt(
"ivec2mxArray: Pointer to data is NULL");
568 if (in.size() == 0) mexErrMsgTxt(
"ivec2mxArray: Size of data is zero");
570 for (
int i = 0; i < in.size(); i++) {
571 *temp++ = (double) in(i);
577 double* temp = (
double *) mxGetPr(out);
578 if (temp == 0) mexErrMsgTxt(
"vec2mxArray: Pointer to data is NULL");
579 if (in.size() == 0) mexErrMsgTxt(
"vec2mxArray: Size of data is zero");
581 for (
int i = 0; i < in.size(); i++) {
582 *temp++ = (double) in(i);
588 double* tempR = (
double *) mxGetPr(out);
589 double* tempI = (
double *) mxGetPi(out);
590 if (tempR == 0) mexErrMsgTxt(
"cvec2mxArray: Pointer to real valued part is NULL");
591 if (tempI == 0) mexErrMsgTxt(
"cvec2mxArray: Pointer to imaginary valued part is NULL");
592 if (in.size() == 0) mexErrMsgTxt(
"cvec2mxArray: Size of data is zero");
594 for (
int i = 0; i < in.size(); i++) {
595 *tempR++ = (double) in(i).real();
596 *tempI++ = (double) in(i).imag();
602 int rows, cols, r, c;
604 double* temp = (
double *) mxGetPr(out);
605 if (temp == 0) mexErrMsgTxt(
"bmat2mxArray: Pointer to data is NULL");
609 if (rows == 0) mexErrMsgTxt(
"bmat2mxArray: Data has zero rows");
610 if (cols == 0) mexErrMsgTxt(
"bmat2mxArray: Data has zero columns");
612 for (c = 0; c < cols; c++) {
613 for (r = 0; r < rows; r++) {
625 int rows, cols, r, c;
627 double* temp = (
double *) mxGetPr(out);
628 if (temp == 0) mexErrMsgTxt(
"smat2mxArray: Pointer to data is NULL");
632 if (rows == 0) mexErrMsgTxt(
"smat2mxArray: Data has zero rows");
633 if (cols == 0) mexErrMsgTxt(
"smat2mxArray: Data has zero columns");
635 for (c = 0; c < cols; c++) {
636 for (r = 0; r < rows; r++) {
637 *temp++ = (double) in(r, c);
645 int rows, cols, r, c;
647 double* temp = (
double *) mxGetPr(out);
648 if (temp == 0) mexErrMsgTxt(
"imat2mxArray: Pointer to data is NULL");
652 if (rows == 0) mexErrMsgTxt(
"imat2mxArray: Data has zero rows");
653 if (cols == 0) mexErrMsgTxt(
"imat2mxArray: Data has zero columns");
655 for (c = 0; c < cols; c++) {
656 for (r = 0; r < rows; r++) {
657 *temp++ = (double) in(r, c);
665 int rows, cols, r, c;
667 double* temp = (
double *) mxGetPr(out);
668 if (temp == 0) mexErrMsgTxt(
"mat2mxArray: Pointer to data is NULL");
672 if (rows == 0) mexErrMsgTxt(
"mat2mxArray: Data has zero rows");
673 if (cols == 0) mexErrMsgTxt(
"mat2mxArray: Data has zero columns");
675 for (c = 0; c < cols; c++) {
676 for (r = 0; r < rows; r++) {
685 int rows, cols, r, c;
687 double* tempR = (
double *) mxGetPr(out);
688 double* tempI = (
double *) mxGetPi(out);
689 if (tempR == 0) mexErrMsgTxt(
"cvec2mxArray: Pointer to real valued part is NULL");
690 if (tempI == 0) mexErrMsgTxt(
"cvec2mxArray: Pointer to imaginary valued part is NULL");
694 if (rows == 0) mexErrMsgTxt(
"cvec2mxArray: Data has zero rows");
695 if (cols == 0) mexErrMsgTxt(
"cvec2mxArray: Data has zero columns");
697 for (c = 0; c < cols; c++) {
698 for (r = 0; r < rows; r++) {
699 *tempR++ = (double) in(r, c).real();
700 *tempI++ = (double) in(r, c).imag();
708 double* temp = (
double*) mxGetPr(in);
709 if (temp == 0) mexErrMsgTxt(
"mxArray2Csvec: Pointer to data is NULL");
710 int size = mxGetNumberOfElements(in);
711 if (size == 0) mexErrMsgTxt(
"mxArray2Csvec: Size of data is zero");
712 for (
int i = 0; i <
size; i++) { out[i] = (short)(*temp++); }
717 double* temp = (
double*) mxGetPr(in);
718 if (temp == 0) mexErrMsgTxt(
"mxArray2Civec: Pointer to data is NULL");
719 int size = mxGetNumberOfElements(in);
720 if (size == 0) mexErrMsgTxt(
"mxArray2Civec: Size of data is zero");
721 for (
int i = 0; i <
size; i++) { out[i] = (int)(*temp++); }
726 double* temp = (
double*) mxGetPr(in);
727 if (temp == 0) mexErrMsgTxt(
"mxArray2Cvec: Pointer to data is NULL");
728 int size = mxGetNumberOfElements(in);
729 if (size == 0) mexErrMsgTxt(
"mxArray2Cvec: Size of data is zero");
730 for (
int i = 0; i <
size; i++) { out[i] = (*temp++); }
735 double* tempR = (
double*) mxGetPr(in);
736 double* tempI = (
double*) mxGetPi(in);
737 if (tempR == 0) mexErrMsgTxt(
"mxArray2Ccvec: Pointer to real valued part is NULL");
738 if (tempI == 0) mexErrMsgTxt(
"mxArray2Ccvec: Pointer to imaginary valued part is NULL");
739 int size = mxGetNumberOfElements(in);
740 if (size == 0) mexErrMsgTxt(
"mxArray2Ccvec: Size of data is zero");
741 for (
int i = 0; i <
size; i++) { out_real[i] = (*tempR++); out_imag[i] = (*tempI++); }
747 double* temp = (
double*) mxGetPr(in);
748 if (temp == 0) mexErrMsgTxt(
"mxArray2Csmat: Pointer to data is NULL");
749 int rows = mxGetM(in);
750 if (rows == 0) mexErrMsgTxt(
"mxArray2Csmat: Data has zero rows");
751 int cols = mxGetN(in);
752 if (cols == 0) mexErrMsgTxt(
"mxArray2Csmat: Data has zero columns");
753 for (c = 0; c < cols; c++) {
754 for (r = 0; r < rows; r++) {
755 out[r][c] = (short)(*temp++);
763 double* temp = (
double*) mxGetPr(in);
764 if (temp == 0) mexErrMsgTxt(
"mxArray2Cimat: Pointer to data is NULL");
765 int rows = mxGetM(in);
766 if (rows == 0) mexErrMsgTxt(
"mxArray2Cimat: Data has zero rows");
767 int cols = mxGetN(in);
768 if (cols == 0) mexErrMsgTxt(
"mxArray2Cimat: Data has zero columns");
769 for (c = 0; c < cols; c++) {
770 for (r = 0; r < rows; r++) {
771 out[r][c] = (int)(*temp++);
779 double* temp = (
double*) mxGetPr(in);
780 if (temp == 0) mexErrMsgTxt(
"mxArray2Cmat: Pointer to data is NULL");
781 int rows = mxGetM(in);
782 if (rows == 0) mexErrMsgTxt(
"mxArray2Cmat: Data has zero rows");
783 int cols = mxGetN(in);
784 if (cols == 0) mexErrMsgTxt(
"mxArray2Cmat: Data has zero columns");
785 for (c = 0; c < cols; c++) {
786 for (r = 0; r < rows; r++) {
787 out[r][c] = (*temp++);
795 double* tempR = (
double*) mxGetPr(in);
796 double* tempI = (
double*) mxGetPi(in);
797 if (tempR == 0) mexErrMsgTxt(
"mxArray2Cmat: Pointer to real valued part is NULL");
798 if (tempI == 0) mexErrMsgTxt(
"mxArray2Cmat: Pointer to imaginary valued part is NULL");
799 int rows = mxGetM(in);
800 if (rows == 0) mexErrMsgTxt(
"mxArray2Cmat: Data has zero rows");
801 int cols = mxGetN(in);
802 if (cols == 0) mexErrMsgTxt(
"mxArray2Cmat: Data has zero columns");
803 for (c = 0; c < cols; c++) {
804 for (r = 0; r < rows; r++) {
805 out_real[r][c] = (*tempR++);
806 out_imag[r][c] = (*tempI++);
813 double* temp = (
double *) mxGetPr(out);
814 if (temp == 0) mexErrMsgTxt(
"Csvec2mxArray: Pointer to data is NULL");
815 int size = mxGetNumberOfElements(out);
816 if (size == 0) mexErrMsgTxt(
"Csvec2mxArray: Size of data is zero");
817 for (
int i = 0; i <
size; i++) { *temp++ = (double) in[i]; }
822 double* temp = (
double *) mxGetPr(out);
823 if (temp == 0) mexErrMsgTxt(
"Civec2mxArray: Pointer to data is NULL");
824 int size = mxGetNumberOfElements(out);
825 if (size == 0) mexErrMsgTxt(
"Civec2mxArray: Size of data is zero");
826 for (
int i = 0; i <
size; i++) { *temp++ = (double) in[i]; }
831 double* temp = (
double *) mxGetPr(out);
832 if (temp == 0) mexErrMsgTxt(
"Cvec2mxArray: Pointer to data is NULL");
833 int size = mxGetNumberOfElements(out);
834 if (size == 0) mexErrMsgTxt(
"Cvec2mxArray: Size of data is zero");
835 for (
int i = 0; i <
size; i++) { *temp++ = in[i]; }
840 double* tempR = (
double *) mxGetPr(out);
841 double* tempI = (
double *) mxGetPi(out);
842 if (tempR == 0) mexErrMsgTxt(
"Ccvec2mxArray: Pointer to real valued part is NULL");
843 if (tempI == 0) mexErrMsgTxt(
"Ccvec2mxArray: Pointer to imaginary valued part is NULL");
844 int size = mxGetNumberOfElements(out);
845 if (size == 0) mexErrMsgTxt(
"Ccvec2mxArray: Size of data is zero");
846 for (
int i = 0; i <
size; i++) { *tempR++ = in_real[i]; *tempI++ = in_imag[i]; }
852 double* temp = (
double *) mxGetPr(out);
853 if (temp == 0) mexErrMsgTxt(
"Csmat2mxArray: Pointer to data is NULL");
854 int rows = mxGetM(out);
855 if (rows == 0) mexErrMsgTxt(
"Csmat2mxArray: Data has zero rows");
856 int cols = mxGetN(out);
857 if (cols == 0) mexErrMsgTxt(
"Csmat2mxArray: Data has zero columns");
858 for (c = 0; c < cols; c++) {
859 for (r = 0; r < rows; r++) {
860 *temp++ = (short) in[r][c];
868 double* temp = (
double *) mxGetPr(out);
869 if (temp == 0) mexErrMsgTxt(
"Cimat2mxArray: Pointer to data is NULL");
870 int rows = mxGetM(out);
871 if (rows == 0) mexErrMsgTxt(
"Cimat2mxArray: Data has zero rows");
872 int cols = mxGetN(out);
873 if (cols == 0) mexErrMsgTxt(
"Cimat2mxArray: Data has zero columns");
874 for (c = 0; c < cols; c++) {
875 for (r = 0; r < rows; r++) {
876 *temp++ = (int) in[r][c];
884 double* temp = (
double *) mxGetPr(out);
885 if (temp == 0) mexErrMsgTxt(
"Cmat2mxArray: Pointer to data is NULL");
886 int rows = mxGetM(out);
887 if (rows == 0) mexErrMsgTxt(
"Cmat2mxArray: Data has zero rows");
888 int cols = mxGetN(out);
889 if (cols == 0) mexErrMsgTxt(
"Cmat2mxArray: Data has zero columns");
890 for (c = 0; c < cols; c++) {
891 for (r = 0; r < rows; r++) {
900 double* tempR = (
double *) mxGetPr(out);
901 double* tempI = (
double *) mxGetPi(out);
902 if (tempR == 0) mexErrMsgTxt(
"Ccmat2mxArray: Pointer to real valued part is NULL");
903 if (tempI == 0) mexErrMsgTxt(
"Ccmat2mxArray: Pointer to imaginary valued part is NULL");
904 int rows = mxGetM(out);
905 if (rows == 0) mexErrMsgTxt(
"Ccmat2mxArray: Data has zero rows");
906 int cols = mxGetN(out);
907 if (cols == 0) mexErrMsgTxt(
"Ccmat2mxArray: Data has zero columns");
908 for (c = 0; c < cols; c++) {
909 for (r = 0; r < rows; r++) {
910 *tempR++ = in_real[r][c];
911 *tempI++ = in_imag[r][c];
918 #endif // #ifndef ITMEX_H