kform.Rd
Functionality for dealing with k-forms
kform(S)
as.kform(M,coeffs,lose=TRUE)
kform_basis(n, k)
kform_general(W,k,coeffs,lose=TRUE)
is.kform(x)
d(i)
e(i,n)
# S3 method for class 'kform'
as.function(x,...)
Dimension of the vector space V=Rn
Integer
A k-form maps Vk to R
Integer vector of dimensions
Index matrix and coefficients for a k-form
Object of class spray
Boolean, with default TRUE
meaning to coerce a
0-form to a scalar and FALSE
meaning to return the
formal 0-form
Object of class kform
Further arguments, currently ignored
A k-form is an alternating k-tensor. In the
package, k-forms are represented as sparse arrays
(spray
objects), but with a class of c("kform",
"spray")
. The constructor function kform()
takes a
spray
object and returns a kform
object: it ensures that
rows of the index matrix are strictly nonnegative integers, have no
repeated entries, and are strictly increasing. Function
as.kform()
is more user-friendly.
kform()
is the constructor function. It takes a
spray
object and returns a kform
.
as.kform()
also returns a kform
but is a bit more
user-friendly than kform()
.
kform_basis()
is a low-level helper function that
returns a matrix whose rows constitute a basis for the vector space
Λk(Rn) of k-forms.
kform_general()
returns a kform
object with terms
that span the space of alternating tensors.
is.kform()
returns TRUE
if its argument is a
kform
object.
d()
is an easily-typed synonym for
as.kform()
. The idea is that d(1) = dx
,
d(2)=dy
, d(5)=dx^5
, etc. Also note that, for
example, d(1:3)=dx^dy^dz
, the volume form.
Recall that a k-tensor is a multilinear map from Vk to the reals, where V=Rn is a vector space. A multilinear k-tensor T is alternating if it satisfies
T(v1,…,vi,…,vj,…,vk)=−T(v1,…,vj,…,vi,…,vk)
In the package, an object of class kform
is an efficient
representation of an alternating tensor.
Function kform_basis()
is a low-level helper function that
returns a matrix whose rows constitute a basis for the vector space
Λk(Rn) of k-forms:
ϕ=∑1≤i1<⋯<ik≤nai1…ikdxi1∧⋯∧dxik
and indeed we have:
ai1…ik=ϕ(ei1,…,eik)
where ej,1≤j≤k is a basis for V.
All functions documented here return a kform
object except
as.function.kform()
, which returns a function, and
is.kform()
, which returns a Boolean, and e()
, which
returns a conjugate basis to that of d()
.
Hubbard and Hubbard; Spivak
Hubbard and Hubbard use the term “k-form”, but Spivak does not.
as.kform(cbind(1:5,2:6),rnorm(5))
#> An alternating linear map from V^2 to R with V=R^6:
#> val
#> 5 6 = 0.54448610
#> 4 5 = -1.08907888
#> 3 4 = 1.21604011
#> 2 3 = 0.32836490
#> 1 2 = 0.09588097
kform_general(1:4,2,coeffs=1:6) # used in electromagnetism
#> An alternating linear map from V^2 to R with V=R^4:
#> val
#> 3 4 = 6
#> 2 4 = 5
#> 1 4 = 4
#> 2 3 = 3
#> 1 3 = 2
#> 1 2 = 1
K1 <- as.kform(cbind(1:5,2:6),rnorm(5))
K2 <- kform_general(5:8,2,1:6)
K1^K2 # or wedge(K1,K2)
#> An alternating linear map from V^4 to R with V=R^8:
#> val
#> 3 4 5 6 = -0.69195268
#> 1 2 6 8 = 2.30636367
#> 3 4 6 7 = -2.07585805
#> 4 5 7 8 = 0.04131579
#> 2 3 7 8 = -8.92659065
#> 1 2 7 8 = 2.76763641
#> 3 4 6 8 = -3.45976341
#> 1 2 6 7 = 1.38381820
#> 3 4 5 8 = -2.76781073
#> 2 3 5 6 = -1.48776511
#> 3 4 5 7 = -1.38390536
#> 2 3 5 7 = -2.97553022
#> 2 3 6 7 = -4.46329533
#> 1 2 5 6 = 0.46127273
#> 1 2 5 8 = 1.84509094
#> 4 5 6 7 = 0.02065789
#> 5 6 7 8 = -0.92407972
#> 1 2 5 7 = 0.92254547
#> 3 4 7 8 = -4.15171609
#> 4 5 6 8 = 0.03442982
#> 2 3 6 8 = -7.43882554
#> 2 3 5 8 = -5.95106044
d(1:3)
#> An alternating linear map from V^3 to R with V=R^3:
#> val
#> 1 2 3 = 1
dx^dy^dz # same thing
#> An alternating linear map from V^3 to R with V=R^3:
#> val
#> 1 2 3 = 1
d(sample(9)) # coeff is +/-1 depending on even/odd permutation of 1:9
#> An alternating linear map from V^9 to R with V=R^9:
#> val
#> 1 2 3 4 5 6 7 8 9 = -1
f <- as.function(wedge(K1,K2))
E <- matrix(rnorm(32),8,4)
f(E) + f(E[,c(1,3,2,4)]) # should be zero by alternating property
#> [1] 0
options(kform_symbolic_print = 'd')
(d(5)+d(7)) ^ (d(2)^d(5) + 6*d(4)^d(7))
#> An alternating linear map from V^3 to R with V=R^7:
#> -6 dx4^dx5^dx7 + dx2^dx5^dx7
options(kform_symbolic_print = NULL) # revert to default