dragtensor.RdEach 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.
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,...)the tensor, its dimension (for *.numeric) or its
index-names (for *.character and contraname)
The geometry tensor \(g_{ij}\) giving the transformation between covariate and contravariate. It needs to have either covariate and or contravariate indices.
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
returns a tensor like x but with the dimension
returns a boolean vector giving true for every covariate index
returns a boolean vector giving true for every contravariate index
changes the state of the indices
returns the names with opposite the opposite covariate and contravariate state
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.
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
#> , , 1
#>
#> ^b
#> a [,1] [,2]
#> [1,] 0.01917759 0.5114724
#> [2,] 0.02956075 -2.3332364
#>
#> , , 2
#>
#> ^b
#> a [,1] [,2]
#> [1,] 2.6442020 -6.174703
#> [2,] -0.4203428 6.463261
#>
#> attr(,"class")
#> [1] "tensor"
names(A2)
#> [1] "a" "^b" "^c"
as.covariate(names(A2))
#> [1] "a" "b" "c"
as.contravariate(names(A2))
#> [1] "^a" "^b" "^c"
is.covariate(A2)
#> [1] TRUE FALSE FALSE
is.contravariate(A2)
#> [1] FALSE TRUE TRUE
riemann.tensor(A2,g)
#> , , 1, 1, 1
#>
#> ^b
#> a [,1] [,2]
#> [1,] 0.01917759 0.5114724
#> [2,] 0.02956075 -2.3332364
#>
#> , , 2, 1, 1
#>
#> ^b
#> a [,1] [,2]
#> [1,] 2.6442020 -6.174703
#> [2,] -0.4203428 6.463261
#>
#> , , 1, 2, 1
#>
#> ^b
#> a [,1] [,2]
#> [1,] 0.03835518 1.022945
#> [2,] 0.05912151 -4.666473
#>
#> , , 2, 2, 1
#>
#> ^b
#> a [,1] [,2]
#> [1,] 5.2884040 -12.34941
#> [2,] -0.8406855 12.92652
#>
#> , , 1, 1, 2
#>
#> ^b
#> a [,1] [,2]
#> [1,] 0 0
#> [2,] 0 0
#>
#> , , 2, 1, 2
#>
#> ^b
#> a [,1] [,2]
#> [1,] 0 0
#> [2,] 0 0
#>
#> , , 1, 2, 2
#>
#> ^b
#> a [,1] [,2]
#> [1,] 0.01917759 0.5114724
#> [2,] 0.02956075 -2.3332364
#>
#> , , 2, 2, 2
#>
#> ^b
#> a [,1] [,2]
#> [1,] 2.6442020 -6.174703
#> [2,] -0.4203428 6.463261
#>
#> attr(,"class")
#> [1] "tensor"