Description Usage Arguments Examples
Overloads elementwise operators for tensors, arrays, and vectors that are conformable (have the same modes).
1 2 | ## S4 method for signature 'Tensor,Tensor'
Ops(e1, e2)
|
e1 |
left-hand object |
e2 |
right-hand object |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | tnsr <- rand_tensor(c(3,4,5))
tnsr2 <- rand_tensor(c(3,4,5))
tnsrsum <- tnsr + tnsr2
tnsrdiff <- tnsr - tnsr2
tnsrelemprod <- tnsr * tnsr2
tnsrelemquot <- tnsr / tnsr2
for (i in 1:3L){
for (j in 1:4L){
for (k in 1:5L){
stopifnot(tnsrsum@data[i,j,k]==tnsr@data[i,j,k]+tnsr2@data[i,j,k])
stopifnot(tnsrdiff@data[i,j,k]==(tnsr@data[i,j,k]-tnsr2@data[i,j,k]))
stopifnot(tnsrelemprod@data[i,j,k]==tnsr@data[i,j,k]*tnsr2@data[i,j,k])
stopifnot(tnsrelemquot@data[i,j,k]==tnsr@data[i,j,k]/tnsr2@data[i,j,k])
}
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.