tensorA (version 0.36.2.1)

reptensor: Repeats a tensor

Description

The tensor is repeated like a number is repeated by rep and an additional dimension is added to select the different tensors.

Usage

# S3 method for tensor
rep(x,times,pos=1,name="i",...)

Value

A tensor with one additional dimensions of length times.

Arguments

x

the tensor to be repeated

times

the number of copies that should be created. If times is a vector, x is seen as a sequence of tensors in dimension pos and each of the tensors is repeated according to the corresponding entry of times.

name

the name of the additional dimension. if NA no additional dimension is used.

pos

the position where the extra dimension should be added

...

not used, only here for generic consistency

Author

K. Gerald van den Boogaart

Details

This function is modeled as much as possible to mimic rep, by repeating tensors rather than numbers. The each argument is not necessary, since sequence of the dimensions can more precisely be controlled by pos. Another problem is the a ambiguity between rep(x,3) and rep(x,c(3)) as a special case of rep(x,c(3,2)). If the second is wanted it can be forced by rep(x,c(3),NA) through setting the name argument to NA.

See Also

Examples

Run this code
A <- to.tensor(1:4,c(A=2,B=2))
rep(A,3)
rep(A,3,3,"u")
rep(A,c(2,3))
A <- to.tensor(1:4,c(A=1,B=4))
rep(A,5,pos="A",name=NA)

Run the code above in your browser using DataLab