toPos: get the position of an index of tensor

Description Usage Arguments Details Value Author(s) Examples

Description

Calculates the position of a tensor index, which specified in any possible way.

Usage

1
toPos.tensor(M,l=NULL,mnames=names(dim(M)),by=NULL,...,both=FALSE,missing.ok=FALSE)

Arguments

M

a tensor

l

a vector specifying the indices as positions or names

mnames

The names of the indices of the tensor. This can be specified instead of M.

both

Matches the index in its covariate and contravariate form.

by

the list dimension, all operations are done in parallel for all levels of these dimensions. Thus in the case of toPos all other dimensions are returned if they are not specified.

...

not used

missing.ok

If TRUE does give an error on missing dimension. Rather returns NA in that place.

Details

The function is only here to provide a consistent interface which provides the same functionality for positions and characters.

Value

a numeric vector giving the positions of the dimensions selected.

Author(s)

K. Gerald van den Boogaart

Examples

1
2
3
4
A <- to.tensor(1:30,c(a=2,b=3,c=5))
toPos.tensor(A,c("b","c"))
toPos.tensor(A,c(2,1))     # only returns the values
toPos.tensor(A,c("^a"),both=TRUE)

Example output

Attaching package: 'tensorA'

The following object is masked from 'package:base':

    norm

[1] 2 3
[1] 2 1
[1] 1

tensorA documentation built on Nov. 20, 2020, 9:07 a.m.

Related to toPos in tensorA...