ktensor: k-tensors

Description Usage Arguments Details Author(s) References See Also Examples

Description

Functionality for k-tensors

Usage

1
2
3
4
ktensor(S)
as.ktensor(M,coeffs)
## S3 method for class 'ktensor'
as.function(x,...)

Arguments

M,coeffs

Matrix of indices and coefficients, as in spray(M,coeffs)

S

Object of class spray

x

Object of class ktensor

...

Further arguments, currently ignored

Details

A k-tensor object S is a map from V^k to the reals R, where V is a vector space (here R^n) that satisfies multilinearity:

omitted; see PDF

and

omitted; see PDF

Note that this is not equivalent to linearity over V^nk (see examples).

In the wedge package, k-tensors are represented as sparse arrays (spray objects), but with a class of c("ktensor", "spray"). This is a natural and efficient representation for tensors that takes advantage of sparsity using spray package features.

Author(s)

Robin K. S. Hankin

References

Spivak 1961

See Also

cross,kform,wedge

Examples

 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
28
29
30
31
32
33
ktensor(rspray(4,powers=1:4))
as.ktensor(cbind(1:4,2:5,3:6),1:4)


## Test multilinearity:
k <- 4
n <- 5
u <- 3

## Define a randomish k-tensor:
S  <- ktensor(spray(matrix(1+sample(u*k)%%n,u,k),seq_len(u)))

## And a random point in V^k:
E <- matrix(rnorm(n*k),n,k)  

E1 <- E2 <- E3 <- E

x1 <- rnorm(n)
x2 <- rnorm(n)
r1 <- rnorm(1)
r2 <- rnorm(1)

# change one column:
E1[,2] <- x1
E2[,2] <- x2
E3[,2] <- r1*x1 + r2*x2

f <- as.function(S)

r1*f(E1) + r2*f(E2) -f(E3) # should be small

## Note that multilinearity is different from linearity:
r1*f(E1) + r2*f(E2) - f(r1*E1 + r2*E2)  # not small!

wedge documentation built on Sept. 4, 2019, 9:02 a.m.