reptensor {tensorA} | R Documentation |
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 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 |
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
Examples
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)