stokes (version 1.2-0)

Ops.kform: Arithmetic Ops Group Methods for kform and ktensor objects

Description

Allows arithmetic operators to be used for k-forms and k-tensors such as addition, multiplication, etc, where defined.

Usage

# S3 method for kform
Ops(e1, e2 = NULL)
# S3 method for ktensor
Ops(e1, e2 = NULL)

Value

All functions documented here return an object of class

kform or ktensor.

Arguments

e1,e2

Objects of class kform or ktensor

Author

Robin K. S. Hankin

Details

The functions Ops.kform() and Ops.ktensor() pass unary and binary arithmetic operators (“+”, “-”, “*”, “/” and “^”) to the appropriate specialist function by coercing to spray objects.

For wedge products of k-forms, use wedge() or %^% or ^; and for tensor products of k-tensors, use tensorprod() or %X%.

Examples

Run this code
## dx_1 ^ dx_2 + 6dx_5 ^ dx_6:
as.kform(1) ^ as.kform(2) + 6*as.kform(5) ^ as.kform(6)

k1 <- kform_general(4,2,rnorm(6))
k2 <- kform_general(4,2,rnorm(6))

E <- matrix(rnorm(8),4,2)
as.function(k1+k2)(E)

## verify linearity, here 2*k1 + 3*k2:
as.function(2*k1+3*k2)(E)-(2*as.function(k1)(E) + 3*as.function(k2)(E))
## should be small

Run the code above in your browser using DataLab