4.4. Linear Algebra Matrix-Vector Functions

4.4.1. cumsum

Description:  Cumulative sum of matrix rows or columns

Syntax: 

void cumsum<d> ( const_Vector<T> A Vector<T> B );
 
void cumsum<d> ( const_Matrix<T> A Matrix<T> B );
 

Requirements:  Arguments A and B must be views of the same dimension. If matrices are passed, template parameter d must be either row (0) or col (1).

Result:  If arguments are vectors, the template parameter d is ignored and each element i of result is set to the the sum of the 0 through ith elements of the input vector: B(i) = sum(j = 0 ... i) of A(j).

If arguments are matrices, the template parameter d, controls whether summation is done along rows (if d == row == 0) or columns (if d == col == 1).

If d == row, then each result element B(r, c) is set to the sum of the 0 through cth elements of row r in matrix A: B(r, c) = sum(j = 0 ... c) of A(r, c)

If d == col, then each result element B(r, c) is set to the sum of the 0 through rth elements of column c in matrix A: B(r, c) = Sum(j = 0 .. r) of A(r, c)

Example: 

length_type m = 32, n = 16;
Matrix<float> A(m, n), B(m, n);
cumsum<row>(A, B);

4.4.2. cvjdot

Description:  Linear algebra conjugate dot-product.

Syntax: 

T cvjdot ( Vector<T> A Vector<T> B );
 

Requirements:  A and B must be vectors of the same size.

Result:  Returns the conjugate dot-product (inner-product) of the argument vectors:

result = sum(i = 0 .. size-1) : A(i) * conj(B(i))

Example: 

length_type n = 16;
Vector<complex<float> > A(n), B(n);
complex<float> result = cvjdot(A, B);

See Also:  dot (section 4.4.3) outer (section 4.4.9)

4.4.3. dot

Description:  Linear algebra dot-product.

Syntax: 

T dot ( Vector<T> A Vector<T> B );
 

Requirements:  A and B must be vectors of the same size.

Result:  Returns the dot-product (inner-product) of the argument vectors. result = sum(i = 0 ... size-1) : A(i) * B(i)

Example: 

length_type n = 16;
Vector<float> A(n), B(n);
float result = prod(A, B);

See Also: cvjdot(section 4.4.2)outer(section 4.4.9)

4.4.4. gemp

Description:  Linear algebra generalized matrix product.

Syntax: 

template <mat_op_type OpA,
          mat_op_type OpB,
          typename T0,
          typename ConstMatrix1T,
          typename ConstMatrix2T,
          typename T3,
          typename Matrix4T>
void
gemp(
   T0            alpha,
   ConstMatrix1T A,
   ConstMatrix2T B,
   T3            beta,
   Matrix4T      C)

Requirements:  The number of columns of OpA(A) must equal the number of rows of OpB(B).

Result:  Computes the expression: C = alpha * OpA(A) * OpB(B) + beta * C

Template parameters OpA and OpB are of type mat_op_type (section 2.7.3) and specify operations on matrices A and B: mat_ntrans indicates no transpose, mat_trans indicates transpose, mat_herm indicates hermetian, and mat_conj indicates conjugation.

Example: 

length_type m = 48, p = 16, n = 32;
Matrix<float> C(m, p), A(m, n), B(n, p);
gemp(0.5, A, B, 0.5, C);

See Also: gems(section 4.4.5)prod(section 4.4.10)prodh(section 4.4.13)prodj(section 4.4.14)prodt(section 4.4.15)

4.4.5. gems

Description:  Linear algebra generalized matrix sum.

Syntax: 

template <mat_op_type OpA,
          typename T0,
          typename ConstMatrix1T,
          typename T2,
          typename Matrix3>
T1
gems(
   T0            alpha,
   ConstMatrix1T A
   T2            beta,
   Matrix3T      C)

Requirements:  If OpA equal mat_ntrans or mat_conj, A and B must have the same size.

If OpA equal mat_trans or mat_herm, the number of rows of A must equal the number of columns of B, and the number of columns of A must equal the number of rows of B.

Result:  Computes the expression: C = alpha * OpA(A) + beta * C

Template parameter OpA is of type mat_op_type (section 2.7.3) and specify an operation on matrix A: mat_ntrans indicates no transpose, mat_trans indicates transpose, mat_herm indicates hermetian, and mat_conj indicates conjugation.

Example: 

length_type m = 48, p = 16, n = 32;
Matrix<float> C(m, p), A(m, n), B(n, p);
gemp(0.5, A, B, 0.5, C);

See Also: gemp(section 4.4.4)

4.4.6. herm

Description:  Matrix hermetian (conjugate-transpose).

Syntax: 

Matrix<T> herm ( Matrix<T> A );
 

Result:  Returns a matrix hermetian view. The i, jth element of the result are the conjugated j, ith element of the argument.

result(i, j) = conj(A(j, i))

Note that herm() does itself not rearrange or modify data in memory. However, if the result is assigned to a destination matrix, during the copy into the destination, a corner-turn and conjugation may be performed.

Example: 

length_type m = 32, n = 16;
Matrix<complex<float> > Z(m, n), A(n, m);
Z = herm(A);

See Also: trans(section 4.4.16)

4.4.7. kron

Description:  Linear algebra kronecker product.

Syntax: 

template <typename T0,
          typename View1,
          typename View2>
const_Matrix<PromotedT, unspecified>
kron(
   T0    alpha,
   View1 v,
   View2 w)

Requirements:  Arguments v and w must have the same dimensionality.

Result:  Returns the kronecker product of the two view parameters, scaled by alpha.

The number of output matrix rows equals the product of v and w's rows. The number of ouput matrix columns equal the product of v and w's columns.

The value type of the result matrix is the promoted value type of alpha, v, and w,

Example: 

length_type m = 4, p = 16, n = 8, q = 12;
Matrix<float> C(m*p, n*q), V(m, n), W(p, q);
C = kron(0.5, V, W);

4.4.8. modulate

Description:  Modulate vector with baseband frequency.

Syntax: 

template <typename ConstVectorT0,
          typename T1,
          typename T2,
          typename VectorT3>
T1
modulate(
   ConstVector0T v
   T1            nu,
   T2            phi,
   Vector3T      w)

Result:  Sets w to value of input v modulated with complex frequency phi + i*nu.

w(i) = v(i) * exp((i * nu + phi)i)

Where i is sqrt(-1)

Returns v.size() * nu + phi.

Example: 

float nu = 3.14/16, phi = 3.14/2;
length_type size = 16;
Vector<complex<float> > Z(size), A(size);
modulate(A, nu, phi, B);

4.4.9. outer

Description:  Linear algebra outer-product.

Syntax: 

Matrix<T> outer ( Vector<T> A Vector<T> B );
 

Result:  Returns the outer-product of the argument vectors. Each element result(i, j) is set to the product of the ith element of A and jth element of B.

result(i, j) = A(i) * B(j)

If the argument vectors have a complex value type, the conjugate of B is used in the product:

result(i, j) = A(i) * conj(B(j))

Example: 

length_type m = 32, n = 16;
Vector<float> A(m), B(n);
Matrix<float> Z(m, n);
Z = outer(A, B);

See Also:  cvjdot (section 4.4.2) dot (section 4.4.3)

4.4.10. prod

Description:  Linear algebra product.

Syntax: 

Matrix<T> prod ( Matrix<T> A Matrix<T> B );
 
Vector<T> prod ( Matrix<T> A Vector<T> B );
 
Vector<T> prod ( Vector<T> A Matrix<T> B );
 

Requirements:  If both arguments are matrices, the number of columns of A must equal the number of rows of B.

If A is a matrix and B is a vector, the number of columns of A must equal the size of B.

If A is a vector and B is a matrix, the size of A must equal the number of rows of B.

Result:  The result is equal to the linear algebraic product of the arguments.

If A is a m by n matrix and B is a n by p matrix, a m x p matrix is returned.

If A is a m by n matrix, and B is a n element vector, a m element vector is returned.

If A is a n element vector, and B is a n x p matrix, a p element vector is returned.

Example: 

Matrix<float> Z, A, B;
Z = prod(A, B);

See Also: prodh(section 4.4.13)prodj(section 4.4.14)prodt(section 4.4.15)

4.4.11. prod3

Description:  Linear algebra 3x3 product.

Syntax: 

Matrix<T> prod3 ( Matrix<T> A Matrix<T> B );
 
Vector<T> prod3 ( Matrix<T> A Vector<T> B );
 

Requirements:  All matrix arguments must be size 3 by 3. All vector arguments must be of size 3.

Result:  The result is equal to the linear algebraic product of the arguments.

If A is a 3 by 3 matrix and B is a 3 by 3 matrix, a 3 x 3 matrix is returned.

If A is a 3 by 3 matrix, and B is a 3 element vector, a 3 element vector is returned.

Example: 

Matrix<float> Z(3, 3), A(3, 3), B(3, 3);
Z = prod(A, B);

See Also:  prod (section 4.4.10) prod4 (section 4.4.12)

4.4.12. prod4

Description:  Linear algebra 4x4 product.

Syntax: 

Matrix<T> prod4 ( Matrix<T> A Matrix<T> B );
 
Vector<T> prod4 ( Matrix<T> A Vector<T> B );
 

Requirements:  All matrix arguments must be size 4 by 4. All vector arguments must be of size 4.

Result:  The result is equal to the linear algebraic product of the arguments.

If A is a 4 by 4 matrix and B is a 4 by 4 matrix, a 4 by 4 matrix is returned.

If A is a 4 by 4 matrix, and B is a 4 element vector, a 4 element vector is returned.

Example: 

Matrix<float> Z(4, 4), A(4, 4), B(4, 4);
Z = prod(A, B);

See Also:  prod (section 4.4.10) prod4 (section 4.4.12)

4.4.13. prodh

Description:  Linear algebra product, with hermetian.

Syntax: 

Matrix<T> prodh ( Matrix<T> A Matrix<T> B );
 

Requirements:  The number of columns of A must equal the number of columns of B.

Result:  The result is equal to the linear algebraic product of the first argument with the hermetian (conjugate transpose) of the second argument. Z = prodh(A, B) = prod(A, conj(trans(B)))

If A is a m by n matrix and B is a p by n matrix, a m x p matrix is returned.

Example: 

length_type m = 64, n = 32, p = 48;
Matrix<float> Z(m, p), A(m, n), B(p, n);
Z = prodh(A, B);

See Also:  prod (section 4.4.10) prodj (section 4.4.14) prodt (section 4.4.15)

4.4.14. prodj

Description:  Linear algebra product, with conjuage.

Syntax: 

Matrix<T> prodj ( Matrix<T> A Matrix<T> B );
 

Requirements:  The number of columns of A must equal the number of rows of B.

Result:  The result is equal to the linear algebraic product of the first argument with the conjugate of the second argument. Z = prodj(A, B) = prod(A, conj(B))

If A is a m by n matrix and B is a n by p matrix, a m x p matrix is returned.

Example: 

length_type m = 64, n = 32, p = 48;
Matrix<float> Z(m, p), A(m, n), B(n, p);
Z = prodj(A, B);

See Also: prod(section 4.4.10)prodh(section 4.4.13)prodt(section 4.4.15)

4.4.15. prodt

Description:  Linear algebra product, with transpose.

Syntax: 

Matrix<T> prodt ( Matrix<T> A Matrix<T> B );
 

Requirements:  The number of columns of A must equal the number of rows of B.

Result:  The result is equal to the linear algebraic product of the first argument with the transpose of the second argument.

If A is a m by n matrix and B is a p by n matrix, a m x p matrix is returned.

Example: 

length_type m = 64, n = 32, p = 48;
Matrix<float> Z(m, p), A(m, n), B(p, n);
Z = prod(A, B);

See Also: prod(section 4.4.10)prodh(section 4.4.13)prodj(section 4.4.14)

4.4.16. trans

Description:  Matrix transpose.

Syntax: 

Matrix<T> trans ( Matrix<T> A );
 

Result:  Returns a matrix transpose view. The i, jth element of the result are the j, ith element of the argument. result(i, j) = A(j, i)

Note that trans() does itself not rearrange data in memory. However, if the result is assigned to a destination matrix, during the copy into the destination, a corner-turn may be performed.

Example: 

length_type m = 32, n = 16;
Matrix<float> Z(m, n), A(n, m);
Z = trans(A);

See Also:  herm (section 4.4.6)