In the code below m
is a matrix
, v
is a vector
and s
is a scalar.
Construction:
vector<double> v,
v1(3),
v2(3, 1.),
v3(v2),
v4(v2 + v3);
matrix<double> m,
m1(3, 3),
m2(3, 3, 1.),
m3(m2),
m4(m2 + m3);
Element access:
v[0];
v(1);
m(0, 0);
m[0][1];
m[1](0);
m(1)[1];
m(1)(2);
Access to matrix rows and columns:
Basic linear algebra operations:
v = +v1;
v = -v1;
v = v1 + v2;
v = v1 - v2;
v = v1*s;
v = s*v1;
v += v1;
v -= v1;
v *= s;
m = +m1;
m = -m1;
m = m1 + m2;
m = m1 - m2;
m = m1*s;
m = s*m1;
m += m1;
m -= m1;
m *= m1;
m = m1*m2;
v = m*v;
Some common algorithms:
v = cross_product(v1, v2);
m = invert(m);
Some extended features:
m = v;
m = m1[0];
{
matrix<double, lower_tr> m1,
m2(3),
m3(3, 1.);
matrix<double> m;
m1 = m2*m3;
m1 = m2*reshape<lower_tr>(m);
}