Functions and objects for VSA similarity values.

Share:

Description

Functions to convert between simvals and ordinary scalar values.

Usage

1
2
simval(x)
scalar(e1)

Arguments

x

a numeric value (i.e., a vector of length 1 )

e1

a simval

Details

A simval ("Similarity value") is a numeric vector of length 1 with the S3 class simval. Various functions, e.g., dot() and cosine() return simval objects. A object with a class is used instead of an ordinary scalar so as to catch some possible operator precedence errors such as writing x * y %.% z with the (false) belief that it will be parsed as (x * y) %.% z when in fact it will be parsed as x * (y %.% z). Having %.% return a simval object allows the expression x * y %.% z to result in an error, because it is illegal to multiple a vector by a simval. If x * (y %.% z) really was intended, then it must be written as x * scalar(y %.% z).

Value

simval() returns a vector with the S3 class simval.

scalar() strips off the S3 class simval (i.e., it returns a numeric vector with no S3 class).

Author(s)

Tony Plate tplate@acm.org

See Also

vsa

Examples

1
2
3
4
5
x <- newVec()
y <- newVec()
z <- newVec()
(x * y) %.% z
x * scalar(y %.% z)