Description Usage Arguments Details Value Author(s) References See Also Examples
Generic functions for working with VSA vectors. Functions for all standard algebraic operations on vectors: multiplication, addition, superposition, scaling, powers (including inverses), approximate inverse, similarity.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
e1 |
a |
e2 |
a |
method |
computational method for convolution ( |
tol |
numerical tolerance for |
mag1,mag2 |
precomputed magnitudes for |
actual |
work with data values from this object (in this mode of
invocation |
... |
addtional |
All of these functions take as arguments one or more VSA vectors, and
possibily a scalar. A VSA vector is a subclass of vsa
(e.g.,
realhrr
). The result is a VSA vector, or a scalar with class
simval
. To catch some errors due to misunderstanding of R's
precedence, a "simval" scalar cannot be supplied as the argument of
one of these functions (to do, remove the simval
class using
the function scalar
).
mag
computes the magnitude of a vector (scalar value)
vnorm
normalizes a vector so that its magnitude is 1 (vector value)
vsaprod
and its synonym *
compute the vector product of two vectors (vector value)
appinv
and its synonym !
computes an approximate inverse of a vector. The expression x / y
where x
and y
are vectors computes x * appinv(y)
. (vector value)
vsascale
and its synonym *
multiple a vector by a scalar (vector value)
add
computes the vector superposition of a collection of
vectors (supplied as arguments). Need not be associative (if it
always was, a two-argument addition function would suffice). x
+ y
is a synonym for add(x, y)
. x - y
is a synonym for
add(x, vsascale(y, -1))
. (vector value)
addnorm
computes the vector superposition of a collection of
vectors (supplied as arguments) and normalizes the result.
vsapower
and its synonym ^
compute the power of a vector. Negative powers are allowed (vector value)
equiv
compares two vectors for approximate relative equality (to a quite strict tolerance) (logical value)
cosine
and its synonym %cos%
compute the
normalized similarity of two vectors and return a scalar value with class simval
dot
and its synonym %.%
compute the unnormalized
similarity of two vectors and return a scalar value with class simval
vsaprod
, appinv
, add
, vnorm
, vsapower
, vsascale
return a vsa
object of the same class as their argument.
mag
, dot
and cosine
return a scalar value with class simval
Tony Plate tplate@acm.org
vsa
, vsa.mem
, for operator precedence: Syntax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | library(vsa)
a <- newVec()
a
b <- newVec()
b
dot(a, b)
a
elts(a)[1:10]
x <- a * b
(!a)
(!a * x)
((!a) * x)
(appinv(a) * x)
(x / a)
c <- newVec()
d <- newVec()
e <- newVec()
f <- newVec()
x <- vnorm(a * b + c * d + e * f)
mem <- vsamem(a, b, c, d, e, f)
cosmem(mem, a)
dotmem(mem, x / b)
cosmem(mem, x / b)
cosmem(mem, x / c)
cosmem(mem, x / f)
bestmatch(mem, x / b, cos=TRUE)
bestmatch(mem, x / b, cos=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.