Efficient computation of the shortest angles matrix Ψ, defined as [REMOVE_ME]Ψij:=cos−1(Xi′Xj),\quadi,j=1,…,n,Ψij=cos−1(Xi′Xj),i,j=1,…,n,[REMOVEME2]
for a sample c("X1,ldots,Xnin\n", "Sp−1:=xinRp:∣∣x∣∣=1"), p≥2.
For a circular sample Θ1,…,Θn∈[0,2π), Ψ can be expressed as [REMOVE_ME]Ψij=π−∣π−∣Θi−Θj∣∣,\quadi,j=1,…,n.Ψij=π−∣π−∣Θi−Θj∣∣,i,j=1,…,n.[REMOVEME2]
data: an array of size c(n, p, M) containing the Cartesian coordinates of M samples of size n of directions on Sp−1. Alternatively if p = 2, an array of size c(n, 1, M) containing the angles on [0,2π) of the M
circular samples of size n on S1. Must not contain NA's.
ind_tri: if use_ind_tri = TRUE, the vector of 0-based indexes provided by upper_tri_ind(n), which allows to extract the upper triangular part of the matrix Ψ. See the examples.
use_ind_tri: use the already computed vector index ind_tri? If FALSE (default), ind_tri is computed internally.
scalar_prod: return the scalar products Xi′Xj instead of the shortest angles? Only taken into account for data in Cartesian form. Defaults to FALSE.
angles_diff: return the (unwrapped) angles difference Θi−Θj instead of the shortest angles? Only taken into account for data in angular form. Defaults to FALSE.
n: sample size, used to determine the index vector that gives the upper triangular part of Ψ.
Returns
Psi_mat: a matrix of size c(n * (n - 1) / 2, M) containing, for each column, the vector half of Ψ for each of the M samples.
upper_tri_ind: a matrix of size n * (n - 1) / 2
containing the 0-based linear indexes for extracting the upper triangular matrix of a matrix of size c(n, n), diagonal excluded, assuming column-major order.
Description
Efficient computation of the shortest angles matrix Ψ, defined as