Function angles_from_matrix

Function Documentation

arma::fvec angles_from_matrix(const arma::fmat &mat)

Computes the angles (in radians) between consecutive row vectors of a matrix.

This function takes a matrix where each row is a vector and calculates the angle between each pair of consecutive rows using the dot product formula. The result is a vector of angles in radians, with one fewer element than the number of rows in the input matrix.

Note

The function clamps the cosine values to [-1, 1] to avoid domain errors in acos.

Parameters:

mat – A matrix (arma::fmat) where each row represents a vector.

Returns:

A vector (arma::fvec) containing the angles in radians between each pair of consecutive row vectors.