Description Usage Arguments Details Examples
Computes the inner product of two vectors (or two matrices) with a specified metric
1 | inner_prod(x, y, metric = NULL)
|
x |
numeric vector or matrix |
y |
numeric vector or matrix |
metric |
either |
x
and y
must be of same length or
dimension.
If metric = NULL
this means the
identity metric.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # two vectors
u = 1:10
v = seq(0, 1, length.out = 10)
# identity metric
inner_prod(u, v)
# metric as vector
inner_prod(u, v, metric = rep(1/length(u), length(u)))
# metric as matrix
inner_prod(u, v, metric = diag(1/5, length(v)))
# two matrices
A = matrix(1:12, 4, 3)
B = matrix(seq(0, 1, length.out = 12), 4, 3)
inner_prod(A, B)
inner_prod(A, B, rep(0.3, 4))
inner_prod(A, B, metric = diag(1/2, nrow(A)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.