add.tensor | R Documentation |
Adds/subs/multiplies/devides tensors element by element .
The luxury difference to a simple +
is that we
do not need to consider the correct permutation of indices or rules
on implicit replication, since all of this is handled automatically.
add.tensor(X,Y,op="+",only=NULL)
## Methods for class tensor
# x + y
# x - y
# x * y
# x - y
X |
a tensor |
Y |
a tensor |
op |
a binary function used to perform the "addition" |
only |
a list of dimnames that may be considered as equal. This parameter is here to allow parallelization of tensors with only partially known structure. |
The tensors are properly reordered such that dimensions of the same name are identified. If dimensions are missing in one of the tensors it is correspondingly repeated.
A tensor giving the element-wise operation X,Y. If some of the indices are missing in one of the tensors they are added by repetition.
K. Gerald van den Boogaart
to.tensor
A <- to.tensor(1:20,c(U=2,V=2,W=5))
add.tensor(A,A)/2 -A
(A+A)/2
A/A
A * 1/A
norm.tensor(reorder.tensor(A,c(2,3,1)) - A)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.