reptensor: Repeats a tensor

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

Description

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

Usage

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

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

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.

Value

A tensor with one additional dimensions of length times.

Author(s)

K. Gerald van den Boogaart

See Also

rep

Examples

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

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

Related to reptensor in tensorA...