Correct idiom for generating zero \(k\)-tensors and \(k\)-forms

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

Arguments

n

Arity of the \(k\)-form or \(k\)-tensor

x

Object to be tested for zero

Author

Robin K. S. Hankin

Note

Idiom such as as.ktensor(rep(1,5),0) and as.kform(rep(1,5),0) and indeed as.kform(1:5,0) will return the zero tensor or \(k\)-form (in earlier versions of the package, these were held to be incorrect as the arity of the tensor was lost).

A \(0\)-form is not the same thing as a zero tensor. A \(0\)-form maps \(V^0\) to the reals; a scalar. A zero tensor maps \(V^k\) to zero. Some discussion is given at scalar.Rd.

Value

Returns an object of class kform or ktensor.

See also

Examples


zerotensor(5)
#> The zero linear map from V^5 to R with V=R^n:
#> empty sparse array with 5 columns
zeroform(3)
#> The zero alternating linear map from V^3 to R with V=R^n:
#> empty sparse array with 3 columns


x <- rform(k=3)
x*0 == zeroform(3)       # should be true
#> [1] TRUE
x   == x + zeroform(3)  # should be true
#> [1] TRUE

y <- rtensor(k=3)
y*0 == zerotensor(3)    # should be true
#> [1] TRUE
y   == y+zerotensor(3)  # should be true
#> [1] 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