Here we provide a conversion table between Matlab/Octave and IT++ syntax. This table is intended to help with the transition from Matlab/Octave programming to IT++, but it is not an exhaustive list of possible operations.
In what follows,
-
a, b denote vectors (assumed to be column vectors in Matlab/Octave notation),
-
A, B denote matrices,
-
x is a scalar,
-
k, l, n are indices
Vector indexing and manipulation:
a.length()
a(0)
a(1)
a(k-1)
a(k-1)=x; or a.set(k-1,x);
a.left(k)
a.right(k)
a.mid(k,l)
a.del(k);
a.clear();
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.
Note that indexing in IT++ starts at 0, whereas indexing in Matlab starts at 1. Also note that Matlab/Octave does distinguish between column and row vectors, whereas IT++ does not.
Matrix indexing and manipulation:
A.rows()
A.cols()
A(k-1,l-1)
A.set(k-1,l-1,x)
A.get_col(k-1)
A.get_row(k-1)
A.set_col(k-1,a)
A.set_row(k-1,a)
A.append_row(a)
A.append_col(a)
A.clear()
void transpose(const Mat< T > &m, Mat< T > &out)
Transposition of the matrix m returning the transposed matrix in out.
void hermitian_transpose(const Mat< T > &m, Mat< T > &out)
Some vector and matrix algebra:
a+b
a-b
a*b
A+B
A-B
A*B
elem_mul(A,B)
bool ls_solve_od(const mat &A, const vec &b, vec &x)
Solves overdetermined linear equation systems.
cvec conj(const cvec &x)
Conjugate of complex value.
Mat< Num_T > elem_div(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise division of two matrices.
Mat< Num_T > elem_mult(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices.
Mat< Num_T > outer_product(const Vec< Num_T > &v1, const Vec< Num_T > &v2, bool hermitian=false)
Outer product of two vectors v1 and v2.
Special matrices and vectors:
vec linspace(double from, double to, int points)
linspace (works in the same way as the MATLAB version)
ITPP_EXPORT vec zeros(int size)
A Double vector of zeros.
ITPP_EXPORT cvec zeros_c(int size)
A Double Complex vector of zeros.
ITPP_EXPORT cmat eye_c(int size)
A Double Complex (size,size) unit matrix.
template void eye(int, mat &)
Template instantiation of eye.
Hardcoded initializations:
mat X=
"1.1 1.2; 2.1; 2.2";
Mat< double > mat
Default Matrix Type.
Vec< int > ivec
Definition of integer vector type.