solvetensor: Solving linear equations with tensors

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

Description

We can formulate linear equation systems with tensors. This functions solves these systems or gives a least squares fit of minimal norm.

Usage

1
2
 ## S3 method for class 'tensor'
solve(a,b,i,j=i,...,allowSingular=FALSE,eps=1E-10,by=NULL)

Arguments

a

The a of ax=b

b

The a of ax=b

i

The dimensions of the equation in a

j

The dimensions of the equation in b

allowSingular

A boolean, indicating the that a least squares fit should be generated with singular equations systems.

...

further arguments for generic use

eps

The limit for the smallest singular value in inversion

by

the operation is done in parallel for these dimensions

Details

A tensor can be seen as a linear mapping of a tensor to a tensor. Let denote R_i the space of real tensors with dimensions i_1...i_d.

Value

a tensor such that ax=b as good as possible for each combination of by values.

Author(s)

K. Gerald van den Boogaart

See Also

to.tensor, svd.tensor, inv.tensor, chol.tensor, power.tensor

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
R1  <- matrix(rnorm(9),nrow=3)
R1i <- solve(R1)
R2 <- to.tensor(R1,c(a=3,b=3),what=1:2)
R2i <- to.tensor(R1i,c(b=3,a=3),what=1:2)

inv.tensor(R2,"a","b") - R2i
inv.tensor(R2,"a","b",allowSingular=TRUE) - R2i

inv.tensor(rep(R2,4,1,"K"),"a","b",by="K") - rep(R2i,4,1,"K")
inv.tensor(rep(R2,4,1,"K"),"a","b",by="K",allowSingular=TRUE) - rep(R2i,4,3,"K")

R3 <- to.tensor(rnorm(15),c(a=3,z=5))

mul.tensor(R2i,"b",mul.tensor(R2,"a",R3)) # R3

solve.tensor(R2i,R3[[z=1]],"a")
mul.tensor(R2,"a",R3[[z=1]])

solve.tensor(R2i,R3,"a")
mul.tensor(R2,"a",R3)

solve.tensor(R2i,R3[[z=1]],"a",allowSingular=TRUE)
mul.tensor(R2,"a",R3[[z=1]])

solve.tensor(R2i,R3,"a",allowSingular=TRUE)
mul.tensor(R2,"a",R3)

solve.tensor(rep(R2i,4,1,"K"),R3[[z=1]],"a",by="K")
rep(mul.tensor(R2,"a",R3[[z=1]]),4,1,"K")

solve.tensor(rep(R2i,4,1,"K"),rep(R3[[z=1]],4,1,"K"),"a",by="K")
rep(mul.tensor(R2,"a",R3[[z=1]]),4,1,"K")

tensorA documentation built on Nov. 20, 2020, 9:07 a.m.

Related to solvetensor in tensorA...