Print methods for objects with options for printing in matrix form or multivariate polynomial form

# S3 method for class 'kform'
print(x, ...)
# S3 method for class 'ktensor'
print(x, ...)

Arguments

x

\(k\)-form or \(k\)-tensor

...

Further arguments (currently ignored)

Details

Printing is dispatched to print.ktensor() and print.kform() depending on its argument. Special dispensation is given for the zero object.

Although \(k\)-forms are alternating tensors and thus mathematically are tensors, they are handled differently.

The default print method uses the spray print methods, and as such respects the polyform option. However, setting polyform to TRUE can give misleading output, because spray objects are interpreted as multivariate polynomials not differential forms (and in particular uses the caret to signify powers).

It is much better to use options ktensor_symbolic_print or kform_symbolic_print instead: the bespoke print methods print.kform() and print.ktensor() are sensitive to these options.

For kform objects, if option kform_symbolic_print is non-null, the print method uses as.symbolic() to give an alternate way of displaying \(k\)-tensors and \(k\)-forms. The generic non-null value for this option would be “x” which gives output like “dx1 ^ dx2”. However, it has two special values: set kform_symbolic_print to “dx” for output like “dx ^ dz” and “txyz” for output like “dt ^ dx”, useful in relativistic physics with a Minkowski metric. See the examples.

For ktensor objects, if option ktensor_symbolic_print is TRUE, a different system is used. Given a tensor \(3\phi_4\otimes\phi_1 -5\phi_2\otimes\phi_2\), for example (where \(\phi_i(x^j)=\delta_i^j\)), the method will give output that looks like “+3 d4*d1 -5 d2*d2”. I am not entirely happy with this and it might change in future.

More detail is given at symbolic.Rd and the dx vignette.

Value

Returns its argument invisibly.

Author

Robin K. S. Hankin

Note

For both kform and ktensor objects, the print method asserts that its argument is a map from \(V^k\) to \(\mathbb{R}\) with \(V=\mathbb{R}^n\). Here, \(n\) is the largest element in the index matrix. However, such a map naturally furnishes a map from \((\mathbb{R}^m)^k\) to \(\mathbb{R}\), provided that \(m\geq n\) via the natural projection from \(\mathbb{R}^n\) to \(\mathbb{R}^m\). Formally this would be \(\left(x_1,\ldots,x_n\right)\mapsto\left(x_1,\ldots,x_n,0,\ldots,0\right)\in\mathbb{R}^m\). In the case of the zero \(k\)-form or \(k\)-tensor, “n” is to be interpreted as “any \(n\geq 0\)”. See also dovs().

See also

Examples


a <- rform()
a
#> An alternating linear map from V^3 to R with V=R^7:
#>            val
#>  1 2 5  =   -8
#>  1 2 3  =   -6
#>  1 3 6  =    7
#>  4 5 6  =    9
#>  4 5 7  =   -2
#>  2 4 5  =    1
#>  2 4 7  =   -3
#>  2 3 5  =    1

options(kform_symbolic_print = "x")
a
#> An alternating linear map from V^3 to R with V=R^7:
#>  -8 dx1^dx2^dx5 -6 dx1^dx2^dx3 +7 dx1^dx3^dx6 +9 dx4^dx5^dx6 -2 dx4^dx5^dx7 + dx2^dx4^dx5 -3 dx2^dx4^dx7 + dx2^dx3^dx5 


options(kform_symbolic_print = "dx")
kform(spray(kform_basis(3,2),1:3))
#> An alternating linear map from V^2 to R with V=R^3:
#>  +3 dy^dz +2 dx^dz + dx^dy 


kform(spray(kform_basis(4,2),1:6))  # runs out of symbols
#> An alternating linear map from V^2 to R with V=R^4:
#>  +6 dz^dNA +5 dy^dNA +4 dx^dNA +3 dy^dz +2 dx^dz + dx^dy 


options(kform_symbolic_print = "txyz")
kform(spray(kform_basis(4,2),1:6))  # standard notation
#> An alternating linear map from V^2 to R with V=R^4:
#>  +6 dy^dz +5 dx^dz +4 dt^dz +3 dx^dy +2 dt^dy + dt^dx 


options(kform_symbolic_print = NULL) # revert to default
a
#> An alternating linear map from V^3 to R with V=R^7:
#>            val
#>  1 2 5  =   -8
#>  1 2 3  =   -6
#>  1 3 6  =    7
#>  4 5 6  =    9
#>  4 5 7  =   -2
#>  2 4 5  =    1
#>  2 4 7  =   -3
#>  2 3 5  =    1