Learn R Programming

stokes (version 1.2-0)

zero: Zero tensors and zero forms

Description

Correct idiom for generating zero k-tensors and k-forms

Usage

zeroform(n)
zerotensor(n)
is.zero(x)
is.empty(x)

Value

Returns an object of class kform or ktensor.

Arguments

n

Arity of the k-form or k-tensor

x

Object to be tested for zero

Author

Robin K. S. Hankin

See Also

scalar

Examples

Run this code

zerotensor(5)
zeroform(3)


x <- rform(k=3)
x*0 == zeroform(3)       # should be true
x   == x + zeroform(3)  # should be true

y <- rtensor(k=3)
y*0 == zerotensor(3)    # should be true
y   == y+zerotensor(3)  # should be true


## Following idiom is plausible but fails because as.ktensor(coeffs=0)
## and as.kform(coeffs=0) do not retain arity:

## as.ktensor(1+diag(5)) +  as.ktensor(rep(1,5),0)   # fails
## as.kform(matrix(1:6,2,3)) + as.kform(1:3,0)   # also fails


Run the code above in your browser using DataLab