itmex.h
Go to the documentation of this file.
#ifndef ITMEX_H
#define ITMEX_H
#include <itpp/itbase.h>
#include <mex.h>
namespace itpp
{
//--------------------------------------------------------
// mex -> it++
//--------------------------------------------------------
// --------------------------------------------------------
// mex -> IT++
// --------------------------------------------------------
bin mxArray2bin(const mxArray *in);
short mxArray2short(const mxArray *in);
int mxArray2int(const mxArray *in);
double mxArray2double(const mxArray *in);
std::complex<double> mxArray2double_complex(const mxArray *in);
std::string mxArray2string(const mxArray *in);
bvec mxArray2bvec(const mxArray *in);
svec mxArray2svec(const mxArray *in);
ivec mxArray2ivec(const mxArray *in);
vec mxArray2vec(const mxArray *in);
cvec mxArray2cvec(const mxArray *in);
bmat mxArray2bmat(const mxArray *in);
smat mxArray2smat(const mxArray *in);
imat mxArray2imat(const mxArray *in);
mat mxArray2mat(const mxArray *in);
cmat mxArray2cmat(const mxArray *in);
// --------------------------------------------------------
// IT++ -> mex
// --------------------------------------------------------
void bin2mxArray(const bin &in, mxArray *out);
void short2mxArray(const short &in, mxArray *out);
void int2mxArray(const int &in, mxArray *out);
void double2mxArray(const double &in, mxArray *out);
void double_complex2mxArray(const std::complex<double> &in, mxArray *out);
void string2mxArray(const std::string &in, mxArray* &out);
void bvec2mxArray(const bvec &in, mxArray *out);
void svec2mxArray(const svec &in, mxArray *out);
void ivec2mxArray(const ivec &in, mxArray *out);
void vec2mxArray(const vec &in, mxArray *out);
void cvec2mxArray(const cvec &in, mxArray *out);
void bmat2mxArray(const bmat &in, mxArray *out);
void smat2mxArray(const smat &in, mxArray *out);
void imat2mxArray(const imat &in, mxArray *out);
void mat2mxArray(const mat &in, mxArray *out);
void cmat2mxArray(const cmat &in, mxArray *out);
// --------------------------------------------------------
// mex -> C
// --------------------------------------------------------
void mxArray2Csvec(const mxArray *in, short *out);
void mxArray2Civec(const mxArray *in, int *out);
void mxArray2Cvec(const mxArray *in, double *out);
void mxArray2Ccvec(const mxArray *in, double *out_real, double *out_imag);
void mxArray2Csmat(const mxArray *in, short **out);
void mxArray2Cimat(const mxArray *in, int **out);
void mxArray2Cmat(const mxArray *in, double **out);
void mxArray2Ccmat(const mxArray *in, double **out_real, double **out_imag);
// --------------------------------------------------------
// C -> mex
// --------------------------------------------------------
void Csvec2mxArray(short *in, mxArray *out);
void Civec2mxArray(int *in, mxArray *out);
void Cvec2mxArray(double *in, mxArray *out);
void Ccvec2mxArray(double *in_real, double *in_imag, mxArray *out);
void Csmat2mxArray(short **in, mxArray *out);
void Cimat2mxArray(int **in, mxArray *out);
void Cmat2mxArray(double **in, mxArray *out);
void Ccmat2mxArray(double **in_real, double **in_imag, mxArray *out);
bin mxArray2bin(const mxArray *in)
{
int size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2bin: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size != 1) mexErrMsgTxt("mxArray2bin: Size of data is not equal to one");
return (((*temp) > 0.0) ? bin(1) : bin(0));
}
short mxArray2short(const mxArray *in)
{
int size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2short: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size != 1) mexErrMsgTxt("mxArray2short: Size of data is not equal to one");
return (short)(*temp);
}
int mxArray2int(const mxArray *in)
{
int size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2int: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size != 1) mexErrMsgTxt("mxArray2int: Size of data is not equal to one");
return (int)(*temp);
}
double mxArray2double(const mxArray *in)
{
int size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2double: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size != 1) mexErrMsgTxt("mxArray2double: Size of data is not equal to one");
return (*temp);
}
std::complex<double> mxArray2double_complex(const mxArray *in)
{
int size;
double* tempR = (double*) mxGetPr(in);
double* tempI = (double*) mxGetPi(in);
if ((tempR == 0) && (tempI == 0)) mexErrMsgTxt("mxArray2double_complex: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size != 1) mexErrMsgTxt("mxArray2double_complex: Size of data is not equal to one");
if (tempR == 0) {
return std::complex<double>(0.0 , (*tempI));
}
else if (tempI == 0) {
return std::complex<double>((*tempR), 0.0);
}
else {
return std::complex<double>((*tempR), (*tempI));
}
}
std::string mxArray2string(const mxArray *in)
{
if (in == 0)
mexErrMsgTxt("mxArray2string: Pointer to data is NULL");
std::string str = mxArrayToString(in);
if (str.data() == 0)
mexErrMsgTxt("mxArray2string: Could not convert mxArray to string");
return str;
}
bvec mxArray2bvec(const mxArray *in)
{
bvec out;
int i, size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2bvec: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2bvec: Size of data is zero");
out.set_size(size, false);
for (i = 0; i < size; i++) {
out(i) = (((*temp++) > 1e-5) ? bin(1) : bin(0));
}
return out;
}
svec mxArray2svec(const mxArray *in)
{
svec out;
int i, size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2svec: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2svec: Size of data is zero");
out.set_size(size, false);
for (i = 0; i < size; i++) {
out(i) = (short)(*temp++);
}
return out;
}
ivec mxArray2ivec(const mxArray *in)
{
ivec out;
int i, size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2ivec: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2ivec: Size of data is zero");
out.set_size(size, false);
for (i = 0; i < size; i++) {
out(i) = (int)(*temp++);
}
return out;
}
vec mxArray2vec(const mxArray *in)
{
vec out;
int i, size;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2vec: Pointer to data is NULL");
size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2vec: Size of data is zero");
out.set_size(size, false);
for (i = 0; i < size; i++) {
out(i) = (*temp++);
}
return out;
}
cvec mxArray2cvec(const mxArray *in)
{
cvec out;
int i, size;
double* tempR = (double*) mxGetPr(in);
double* tempI = (double*) mxGetPi(in);
if ((tempR == 0) && (tempI == 0)) mexErrMsgTxt("mxArray2cvec: Pointer data is NULL");
size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2cvec: Size of data is zero");
out.set_size(size, false);
if (tempR == 0) {
for (i = 0; i < size; i++) { out(i) = std::complex<double>(0.0, (*tempI++)); }
}
else if (tempI == 0) {
for (i = 0; i < size; i++) { out(i) = std::complex<double>((*tempR++), 0.0); }
}
else {
for (i = 0; i < size; i++) { out(i) = std::complex<double>((*tempR++), (*tempI++)); }
}
return out;
}
bmat mxArray2bmat(const mxArray *in)
{
bmat out;
int r, c, rows, cols;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2bmat: Pointer to data is NULL");
rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2bmat: Data has zero rows");
cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2bmat: Data has zero columns");
out.set_size(rows, cols, false);
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out(r, c) = (((*temp++) > 0.0) ? bin(1) : bin(0));
}
}
return out;
}
smat mxArray2smat(const mxArray *in)
{
smat out;
int r, c, rows, cols;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2smat: Pointer to data is NULL");
rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2smat: Data has zero rows");
cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2smat: Data has zero columns");
out.set_size(rows, cols, false);
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out(r, c) = (short)(*temp++);
}
}
return out;
}
imat mxArray2imat(const mxArray *in)
{
imat out;
int r, c, rows, cols;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2imat: Pointer to data is NULL");
rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2imat: Data has zero rows");
cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2imat: Data has zero columns");
out.set_size(rows, cols, false);
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out(r, c) = (int)(*temp++);
}
}
return out;
}
mat mxArray2mat(const mxArray *in)
{
mat out;
int r, c, rows, cols;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2mat: Pointer to data is NULL");
rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2mat: Data has zero rows");
cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2mat: Data has zero columns");
out.set_size(rows, cols, false);
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out(r, c) = (*temp++);
}
}
return out;
}
cmat mxArray2cmat(const mxArray *in)
{
cmat out;
int r, c, rows, cols;
double* tempR = (double*) mxGetPr(in);
double* tempI = (double*) mxGetPi(in);
if ((tempR == 0) && (tempI == 0)) mexErrMsgTxt("mxArray2cmat: Pointer to data is NULL");
rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2cmat: Data has zero rows");
cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2cmat: Data has zero columns");
out.set_size(rows, cols, false);
if (tempR == 0) {
for (c = 0; c < cols; c++) { for (r = 0; r < rows; r++) { out(r, c) = std::complex<double>(0.0 , (*tempI++)); } }
}
else if (tempI == 0) {
for (c = 0; c < cols; c++) { for (r = 0; r < rows; r++) { out(r, c) = std::complex<double>((*tempR++), 0.0); } }
}
else {
for (c = 0; c < cols; c++) { for (r = 0; r < rows; r++) { out(r, c) = std::complex<double>((*tempR++), (*tempI++)); } }
}
return out;
}
void double2mxArray(const double &in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("double2mxArray: Pointer to data is NULL");
*temp = (double) in;
}
void double_complex2mxArray(const std::complex<double> &in, mxArray *out)
{
double* tempR = (double *) mxGetPr(out);
double* tempI = (double *) mxGetPi(out);
if (tempR == 0) mexErrMsgTxt("double_complex2mxArray: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("double_complex2mxArray: Pointer to imaginary valued part is NULL");
*tempR = (double) in.real();
*tempI = (double) in.imag();
}
void string2mxArray(const std::string &in, mxArray* &out)
{
if (in.data() == 0)
mexErrMsgTxt("string2mxArray: Pointer to string is NULL");
out = mxCreateString(in.data());
if (out == 0)
mexErrMsgTxt("string2mxArray: Could not convert string to mxArray");
}
void bvec2mxArray(const bvec &in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("bvec2mxArray: Pointer to data is NULL");
if (in.size() == 0) mexErrMsgTxt("bvec2mxArray: Size of data is zero");
for (int i = 0; i < in.size(); i++) {
if (in(i))
*temp++ = 1.0;
else
*temp++ = 0.0;
}
}
void ivec2mxArray(const ivec &in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("ivec2mxArray: Pointer to data is NULL");
if (in.size() == 0) mexErrMsgTxt("ivec2mxArray: Size of data is zero");
for (int i = 0; i < in.size(); i++) {
*temp++ = (double) in(i);
}
}
void vec2mxArray(const vec &in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("vec2mxArray: Pointer to data is NULL");
if (in.size() == 0) mexErrMsgTxt("vec2mxArray: Size of data is zero");
for (int i = 0; i < in.size(); i++) {
*temp++ = (double) in(i);
}
}
void cvec2mxArray(const cvec &in, mxArray *out)
{
double* tempR = (double *) mxGetPr(out);
double* tempI = (double *) mxGetPi(out);
if (tempR == 0) mexErrMsgTxt("cvec2mxArray: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("cvec2mxArray: Pointer to imaginary valued part is NULL");
if (in.size() == 0) mexErrMsgTxt("cvec2mxArray: Size of data is zero");
for (int i = 0; i < in.size(); i++) {
*tempR++ = (double) in(i).real();
*tempI++ = (double) in(i).imag();
}
}
void bmat2mxArray(const bmat &in, mxArray *out)
{
int rows, cols, r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("bmat2mxArray: Pointer to data is NULL");
rows = in.rows();
cols = in.cols();
if (rows == 0) mexErrMsgTxt("bmat2mxArray: Data has zero rows");
if (cols == 0) mexErrMsgTxt("bmat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
if (in(r, c))
*temp++ = 1.0;
else
*temp++ = 0.0;
}
}
}
void smat2mxArray(const smat &in, mxArray *out)
{
int rows, cols, r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("smat2mxArray: Pointer to data is NULL");
rows = in.rows();
cols = in.cols();
if (rows == 0) mexErrMsgTxt("smat2mxArray: Data has zero rows");
if (cols == 0) mexErrMsgTxt("smat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*temp++ = (double) in(r, c);
}
}
}
void imat2mxArray(const imat &in, mxArray *out)
{
int rows, cols, r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("imat2mxArray: Pointer to data is NULL");
rows = in.rows();
cols = in.cols();
if (rows == 0) mexErrMsgTxt("imat2mxArray: Data has zero rows");
if (cols == 0) mexErrMsgTxt("imat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*temp++ = (double) in(r, c);
}
}
}
void mat2mxArray(const mat &in, mxArray *out)
{
int rows, cols, r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("mat2mxArray: Pointer to data is NULL");
rows = in.rows();
cols = in.cols();
if (rows == 0) mexErrMsgTxt("mat2mxArray: Data has zero rows");
if (cols == 0) mexErrMsgTxt("mat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*temp++ = in(r, c);
}
}
}
void cmat2mxArray(const cmat &in, mxArray *out)
{
int rows, cols, r, c;
double* tempR = (double *) mxGetPr(out);
double* tempI = (double *) mxGetPi(out);
if (tempR == 0) mexErrMsgTxt("cvec2mxArray: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("cvec2mxArray: Pointer to imaginary valued part is NULL");
rows = in.rows();
cols = in.cols();
if (rows == 0) mexErrMsgTxt("cvec2mxArray: Data has zero rows");
if (cols == 0) mexErrMsgTxt("cvec2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*tempR++ = (double) in(r, c).real();
*tempI++ = (double) in(r, c).imag();
}
}
}
void mxArray2Csvec(const mxArray *in, short *out)
{
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2Csvec: Pointer to data is NULL");
int size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2Csvec: Size of data is zero");
for (int i = 0; i < size; i++) { out[i] = (short)(*temp++); }
}
void mxArray2Civec(const mxArray *in, int *out)
{
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2Civec: Pointer to data is NULL");
int size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2Civec: Size of data is zero");
for (int i = 0; i < size; i++) { out[i] = (int)(*temp++); }
}
void mxArray2Cvec(const mxArray *in, double *out)
{
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2Cvec: Pointer to data is NULL");
int size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2Cvec: Size of data is zero");
for (int i = 0; i < size; i++) { out[i] = (*temp++); }
}
void mxArray2Ccvec(const mxArray *in, double *out_real, double *out_imag)
{
double* tempR = (double*) mxGetPr(in);
double* tempI = (double*) mxGetPi(in);
if (tempR == 0) mexErrMsgTxt("mxArray2Ccvec: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("mxArray2Ccvec: Pointer to imaginary valued part is NULL");
int size = mxGetNumberOfElements(in);
if (size == 0) mexErrMsgTxt("mxArray2Ccvec: Size of data is zero");
for (int i = 0; i < size; i++) { out_real[i] = (*tempR++); out_imag[i] = (*tempI++); }
}
void mxArray2Csmat(const mxArray *in, short **out)
{
int r, c;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2Csmat: Pointer to data is NULL");
int rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2Csmat: Data has zero rows");
int cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2Csmat: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out[r][c] = (short)(*temp++);
}
}
}
void mxArray2Cimat(const mxArray *in, int **out)
{
int r, c;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2Cimat: Pointer to data is NULL");
int rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2Cimat: Data has zero rows");
int cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2Cimat: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out[r][c] = (int)(*temp++);
}
}
}
void mxArray2Cmat(const mxArray *in, double **out)
{
int r, c;
double* temp = (double*) mxGetPr(in);
if (temp == 0) mexErrMsgTxt("mxArray2Cmat: Pointer to data is NULL");
int rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2Cmat: Data has zero rows");
int cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2Cmat: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out[r][c] = (*temp++);
}
}
}
void mxArray2Ccmat(const mxArray *in, double **out_real, double **out_imag)
{
int r, c;
double* tempR = (double*) mxGetPr(in);
double* tempI = (double*) mxGetPi(in);
if (tempR == 0) mexErrMsgTxt("mxArray2Cmat: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("mxArray2Cmat: Pointer to imaginary valued part is NULL");
int rows = mxGetM(in);
if (rows == 0) mexErrMsgTxt("mxArray2Cmat: Data has zero rows");
int cols = mxGetN(in);
if (cols == 0) mexErrMsgTxt("mxArray2Cmat: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
out_real[r][c] = (*tempR++);
out_imag[r][c] = (*tempI++);
}
}
}
void Csvec2mxArray(short *in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("Csvec2mxArray: Pointer to data is NULL");
int size = mxGetNumberOfElements(out);
if (size == 0) mexErrMsgTxt("Csvec2mxArray: Size of data is zero");
for (int i = 0; i < size; i++) { *temp++ = (double) in[i]; }
}
void Civec2mxArray(int *in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("Civec2mxArray: Pointer to data is NULL");
int size = mxGetNumberOfElements(out);
if (size == 0) mexErrMsgTxt("Civec2mxArray: Size of data is zero");
for (int i = 0; i < size; i++) { *temp++ = (double) in[i]; }
}
void Cvec2mxArray(double *in, mxArray *out)
{
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("Cvec2mxArray: Pointer to data is NULL");
int size = mxGetNumberOfElements(out);
if (size == 0) mexErrMsgTxt("Cvec2mxArray: Size of data is zero");
for (int i = 0; i < size; i++) { *temp++ = in[i]; }
}
void Ccvec2mxArray(double *in_real, double *in_imag, mxArray *out)
{
double* tempR = (double *) mxGetPr(out);
double* tempI = (double *) mxGetPi(out);
if (tempR == 0) mexErrMsgTxt("Ccvec2mxArray: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("Ccvec2mxArray: Pointer to imaginary valued part is NULL");
int size = mxGetNumberOfElements(out);
if (size == 0) mexErrMsgTxt("Ccvec2mxArray: Size of data is zero");
for (int i = 0; i < size; i++) { *tempR++ = in_real[i]; *tempI++ = in_imag[i]; }
}
void Csmat2mxArray(short **in, mxArray *out)
{
int r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("Csmat2mxArray: Pointer to data is NULL");
int rows = mxGetM(out);
if (rows == 0) mexErrMsgTxt("Csmat2mxArray: Data has zero rows");
int cols = mxGetN(out);
if (cols == 0) mexErrMsgTxt("Csmat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*temp++ = (short) in[r][c];
}
}
}
void Cimat2mxArray(int **in, mxArray *out)
{
int r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("Cimat2mxArray: Pointer to data is NULL");
int rows = mxGetM(out);
if (rows == 0) mexErrMsgTxt("Cimat2mxArray: Data has zero rows");
int cols = mxGetN(out);
if (cols == 0) mexErrMsgTxt("Cimat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*temp++ = (int) in[r][c];
}
}
}
void Cmat2mxArray(double **in, mxArray *out)
{
int r, c;
double* temp = (double *) mxGetPr(out);
if (temp == 0) mexErrMsgTxt("Cmat2mxArray: Pointer to data is NULL");
int rows = mxGetM(out);
if (rows == 0) mexErrMsgTxt("Cmat2mxArray: Data has zero rows");
int cols = mxGetN(out);
if (cols == 0) mexErrMsgTxt("Cmat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*temp++ = in[r][c];
}
}
}
void Ccmat2mxArray(double **in_real, double **in_imag, mxArray *out)
{
int r, c;
double* tempR = (double *) mxGetPr(out);
double* tempI = (double *) mxGetPi(out);
if (tempR == 0) mexErrMsgTxt("Ccmat2mxArray: Pointer to real valued part is NULL");
if (tempI == 0) mexErrMsgTxt("Ccmat2mxArray: Pointer to imaginary valued part is NULL");
int rows = mxGetM(out);
if (rows == 0) mexErrMsgTxt("Ccmat2mxArray: Data has zero rows");
int cols = mxGetN(out);
if (cols == 0) mexErrMsgTxt("Ccmat2mxArray: Data has zero columns");
for (c = 0; c < cols; c++) {
for (r = 0; r < rows; r++) {
*tempR++ = in_real[r][c];
*tempI++ = in_imag[r][c];
}
}
}
} // namespace itpp
#endif // #ifndef ITMEX_H
itpp::Array
General array class.
Definition array.h:105
itpp::Array::size
int size() const
Returns the number of data elements in the array object.
Definition array.h:155
itpp::Array::data
T * data
A pointer to the data area.
Definition array.h:189
itpp::Array::set_size
void set_size(int n, bool copy=false)
Resizing an Array<T>.
Definition array.h:257
itpp::bin
Binary arithmetic (boolean) class.
Definition binary.h:57
itpp::size
int size(const Vec< T > &v)
Length of vector.
Definition matfunc.h:55
itpp::svec2mxArray
void svec2mxArray(const svec &in, mxArray *out)
Convert svec to the matlab-format mxArray.
itpp::Ccvec2mxArray
void Ccvec2mxArray(double *in_real, double *in_imag, mxArray *out)
Convert C-format pointers to double (real and imaginary parts) to matlab-format mxArray.
Definition itmex.h:838
itpp::double_complex2mxArray
void double_complex2mxArray(const std::complex< double > &in, mxArray *out)
Convert complex<double> to the matlab-format mxArray.
Definition itmex.h:531
itpp::smat2mxArray
void smat2mxArray(const smat &in, mxArray *out)
Convert smat to the matlab-format mxArray.
Definition itmex.h:623
itpp::mxArray2mat
mat mxArray2mat(const mxArray *in)
Convert the matlab-format mxArray to mat.
Definition itmex.h:471
itpp::mxArray2Csvec
void mxArray2Csvec(const mxArray *in, short *out)
Convert the matlab-format mxArray to C-format pointer to short.
Definition itmex.h:706
itpp::Cimat2mxArray
void Cimat2mxArray(int **in, mxArray *out)
Convert C-format pointer to pointer to int to matlab-format mxArray.
Definition itmex.h:865
itpp::mxArray2Ccvec
void mxArray2Ccvec(const mxArray *in, double *out_real, double *out_imag)
Convert the matlab-format mxArray to C-format pointers to double (real and imaginary parts)
Definition itmex.h:733
itpp::mxArray2bvec
bvec mxArray2bvec(const mxArray *in)
Convert the matlab-format mxArray to bvec.
Definition itmex.h:292
itpp::mxArray2cvec
cvec mxArray2cvec(const mxArray *in)
Convert the matlab-format mxArray to cvec.
Definition itmex.h:372
itpp::mxArray2double_complex
std::complex< double > mxArray2double_complex(const mxArray *in)
Convert the matlab-format mxArray to complex<double>
Definition itmex.h:259
itpp::mxArray2bmat
bmat mxArray2bmat(const mxArray *in)
Convert the matlab-format mxArray to bmat.
Definition itmex.h:400
itpp::mxArray2Cmat
void mxArray2Cmat(const mxArray *in, double **out)
Convert the matlab-format mxArray to C-format pointer to pointer to double.
Definition itmex.h:776
itpp::mxArray2smat
smat mxArray2smat(const mxArray *in)
Convert the matlab-format mxArray to smat.
Definition itmex.h:424
itpp::cmat2mxArray
void cmat2mxArray(const cmat &in, mxArray *out)
Convert cmat to the matlab-format mxArray.
Definition itmex.h:683
itpp::ivec2mxArray
void ivec2mxArray(const ivec &in, mxArray *out)
Convert ivec to the matlab-format mxArray.
Definition itmex.h:564
itpp::mat2mxArray
void mat2mxArray(const mat &in, mxArray *out)
Convert mat to the matlab-format mxArray.
Definition itmex.h:663
itpp::mxArray2double
double mxArray2double(const mxArray *in)
Convert the matlab-format mxArray to double.
Definition itmex.h:248
itpp::mxArray2ivec
ivec mxArray2ivec(const mxArray *in)
Convert the matlab-format mxArray to ivec.
Definition itmex.h:332
itpp::double2mxArray
void double2mxArray(const double &in, mxArray *out)
Convert double to the matlab-format mxArray.
Definition itmex.h:523
itpp::mxArray2vec
vec mxArray2vec(const mxArray *in)
Convert the matlab-format mxArray to vec.
Definition itmex.h:352
itpp::mxArray2Cimat
void mxArray2Cimat(const mxArray *in, int **out)
Convert the matlab-format mxArray to C-format pointer to pointer to int.
Definition itmex.h:760
itpp::short2mxArray
void short2mxArray(const short &in, mxArray *out)
Convert short to the matlab-format mxArray.
itpp::mxArray2imat
imat mxArray2imat(const mxArray *in)
Convert the matlab-format mxArray to imat.
Definition itmex.h:448
itpp::mxArray2string
std::string mxArray2string(const mxArray *in)
Convert the matlab-format mxArray to string.
Definition itmex.h:282
itpp::Ccmat2mxArray
void Ccmat2mxArray(double **in_real, double **in_imag, mxArray *out)
Convert C-format pointer to pointer to double (real and imaginary parts) to matlab-format mxArray.
Definition itmex.h:897
itpp::int2mxArray
void int2mxArray(const int &in, mxArray *out)
Convert int to the matlab-format mxArray.
itpp::mxArray2Csmat
void mxArray2Csmat(const mxArray *in, short **out)
Convert the matlab-format mxArray to C-format pointer to pointer to short.
Definition itmex.h:744
itpp::mxArray2Civec
void mxArray2Civec(const mxArray *in, int *out)
Convert the matlab-format mxArray to C-format pointer to int.
Definition itmex.h:715
itpp::Cmat2mxArray
void Cmat2mxArray(double **in, mxArray *out)
Convert C-format pointer to pointer to double to matlab-format mxArray.
Definition itmex.h:881
itpp::Cvec2mxArray
void Cvec2mxArray(double *in, mxArray *out)
Convert C-format pointer to double to matlab-format mxArray.
Definition itmex.h:829
itpp::mxArray2int
int mxArray2int(const mxArray *in)
Convert the matlab-format mxArray to int.
Definition itmex.h:237
itpp::mxArray2bin
bin mxArray2bin(const mxArray *in)
Convert the matlab-format mxArray to bin.
Definition itmex.h:215
itpp::bvec2mxArray
void bvec2mxArray(const bvec &in, mxArray *out)
Convert bvec to the matlab-format mxArray.
Definition itmex.h:551
itpp::Csvec2mxArray
void Csvec2mxArray(short *in, mxArray *out)
Convert C-format pointer to short to matlab-format mxArray.
Definition itmex.h:811
itpp::Civec2mxArray
void Civec2mxArray(int *in, mxArray *out)
Convert C-format pointer to int to matlab-format mxArray.
Definition itmex.h:820
itpp::imat2mxArray
void imat2mxArray(const imat &in, mxArray *out)
Convert imat to the matlab-format mxArray.
Definition itmex.h:643
itpp::cvec2mxArray
void cvec2mxArray(const cvec &in, mxArray *out)
Convert cvec to the matlab-format mxArray.
Definition itmex.h:586
itpp::vec2mxArray
void vec2mxArray(const vec &in, mxArray *out)
Convert vec to the matlab-format mxArray.
Definition itmex.h:575
itpp::bin2mxArray
void bin2mxArray(const bin &in, mxArray *out)
Convert bin to the matlab-format mxArray.
itpp::mxArray2svec
svec mxArray2svec(const mxArray *in)
Convert the matlab-format mxArray to svec.
Definition itmex.h:312
itpp::string2mxArray
void string2mxArray(const std::string &in, mxArray *&out)
Convert string to the matlab-format mxArray.
Definition itmex.h:542
itpp::mxArray2cmat
cmat mxArray2cmat(const mxArray *in)
Convert the matlab-format mxArray to cmat.
Definition itmex.h:494
itpp::mxArray2Ccmat
void mxArray2Ccmat(const mxArray *in, double **out_real, double **out_imag)
Convert the matlab-format mxArray to C-format pointer to pointer to double (real and imaginary parts)
Definition itmex.h:792
itpp::bmat2mxArray
void bmat2mxArray(const bmat &in, mxArray *out)
Convert bmat to the matlab-format mxArray.
Definition itmex.h:600
itpp::mxArray2short
short mxArray2short(const mxArray *in)
Convert the matlab-format mxArray to short.
Definition itmex.h:226
itpp::mxArray2Cvec
void mxArray2Cvec(const mxArray *in, double *out)
Convert the matlab-format mxArray to C-format pointer to double.
Definition itmex.h:724
itpp::Csmat2mxArray
void Csmat2mxArray(short **in, mxArray *out)
Convert C-format pointer to pointer to short to matlab-format mxArray.
Definition itmex.h:849
itbase.h
Include file for the IT++ base module.
bmat
Mat< bin > bmat
bin matrix
Definition mat.h:508
itpp
itpp namespace
Definition itmex.h:37

Generated on Mon Jun 10 2024 11:49:23 for IT++ by Doxygen 1.9.8