Learn R Programming

tensorA (version 0.36.2.1)

as.tensor: Coercion to a tensor

Description

Coerces a array to a tensor keeping dimension and names.

Usage

as.tensor(X,...)
# S3 method for default
as.tensor(X,...,dims=NULL)
# S3 method for tensor
as.tensor(X,...)

Value

a tensor containing the same data as X

Arguments

X

a multidimensional array

...

further generic arguments

dims

the new dim attribute to be used

Author

K. Gerald van den Boogaart

Details

The main idea is that a multiway array like a vector or a matrix is nothing else than a tensor for R, but it still needs the tensor class be used with the tensorA library. However this is more a convenience function for migraters than a proper way construct a tensor, which is done by to.tensor.

See Also

to.tensor

Examples

Run this code
A <- diag(5)
as.tensor(A)

Run the code above in your browser using DataLab