# dragtensor: Managing covariate and contravariate indices In tensorA: Advanced Tensor Arithmetic with Named Indices

## Description

Each index of a tensor can be covariate or contravariate. The `is.*` routines check the state of the individual indices based on the tensor, its dimension or its index names. `drag.tensor` can change the state for the tensor and contraname for the names of the tensor.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```drag.tensor(x,g,d) contraname(x) is.covariate(x,...) ## S3 method for class 'tensor' is.covariate(x,...) ## S3 method for class 'numeric' is.covariate(x,...) ## S3 method for class 'character' is.covariate(x,...) as.covariate(x,...) ## S3 method for class 'character' as.covariate(x,...) is.contravariate(x,...) ## S3 method for class 'numeric' is.contravariate(x,...) ## S3 method for class 'character' is.contravariate(x,...) as.contravariate(x,...) ## S3 method for class 'character' as.contravariate(x,...) ```

## Arguments

 `x` the tensor, its dimension (for `*.numeric`) or its index-names (for `*.character` and `contraname`) `g` The geometry tensor g_ij giving the transformation between covariate and contravariate. It needs to have either covariate and or contravariate indices. `d` a vector (or list) of indices that should be dragged, i.e. multiplied with g_i^j in the right way such that it changes from covariate to contravariate or vice versa. The name of the index is kept, only its state changes. The index is thus dragged from one state to the other. Indices can given in covariate or contravariate form. `...` only for generic use

## Details

The covariate and contravariate state of a dimension corresponds to column and row vectors. The transformation between these type is done by a linear mapping give by the geometry tensor g, which is the identity matrix if the enclosing the geometry is represented by the orthonormal basis and ordinary scalar product.

## Value

 `drag.tensor` returns a tensor like x but with the dimension `is.covariate` returns a boolean vector giving true for every covariate index `is.contravariate` returns a boolean vector giving true for every contravariate index `as.*` changes the state of the indices `contraname` returns the names with opposite the opposite covariate and contravariate state

## Author(s)

K. Gerald van den Boogaart

`riemann.tensor`, `to.tensor`, `Tensor`
 ``` 1 2 3 4 5 6 7 8 9 10``` ```g <- to.tensor(c(1,2,0,1),c(i=2,j=2)) A <- to.tensor(rnorm(8),c(a=2,b=2,c=2)) A2 <- drag.tensor(A,g,c("b","c")) A2 names(A2) as.covariate(names(A2)) as.contravariate(names(A2)) is.covariate(A2) is.contravariate(A2) riemann.tensor(A2,g) ```