addtensor: Element-wise arithmetic operations +,-,*,/ with tensors

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

Description

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.

Usage

1
2
3
4
5
6
add.tensor(X,Y,op="+",only=NULL)
## Methods for class tensor
# x + y
# x - y
# x * y
# x - y

Arguments

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.

Details

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.

Value

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.

Author(s)

K. Gerald van den Boogaart

See Also

to.tensor

Examples

1
2
3
4
5
6
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)

tensorA documentation built on May 30, 2017, 4:24 a.m.

Related to addtensor in tensorA...