gp_lagMatrix: Compute a matrix of differences given two vectors.

Description Usage Arguments Details Value Notes Examples

View source: R/gp_functions.R

Description

gp_lagMatrix returns a matrix of differences between two vectors.

Usage

1

Arguments

x

vector 1

y

vector 2 (default to vector 1 if not specified)

Details

Given two vectors - x (length M) and y (length N) - as input, return the N*M matrix of differences result[i,j] = x[i] - y[j].

Value

N*M array of absolute differences, result[i,j] = |x[i] - y[j]|

Notes

Note that in the special case that x=y we have a square symmetric matrix: result[i,j] = result[j,i]. In the even more special case that the two vectors are synchronous and evenly spaced (x[i] = y[i] = i * delta + const) then we have a circulant matrix; the jth column result[,j] is the (j-1)th cyclic permutation of the first column. This matrix is symmetric, Toeplitz and circulant.

Examples

1
2
result <- gp_lagMatrix(c(1,2,3), c(2,3,4,5,6))
print(result)

svdataman/gin documentation built on March 12, 2021, 7:37 a.m.