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);
concat(a,b)
a.clear();
to_cmat(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.transpose()
A.hermitian_transpose()
A.clear()
to_cmat(A)
Some vector and matrix algebra:
a+b
a-b
elem_mult(a,b)
a*b
conj(a)*b
outer_product(a,b)
elem_div(a,b)
A+B
A-B
A*B
elem_mul(A,B)
elem_div(A,B)
ls_solve_od(A,b)
Special matrices and vectors:
zeros(n,n)
zeros_c(n,n)
eye(n)
eye_c(n)
linspace(alpha,beta,n)
Hardcoded initializations:
mat X="1.1 1.2; 2.1; 2.2";
ivec a="1 2 3 4 5";
ivec a="1:-3:-8";