print: Print freealg objects

printR Documentation

Print freealg objects

Description

Print methods for free algebra objects. The indeterminates are represented using lowercase letters a-z (currently hard coded).

Usage

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

Arguments

x

Object of class freealg in the print method

...

Further arguments, currently ignored

Note

The print method does not change the internal representation of a freealg object, which is a two-element list, the first of which is a list of integer vectors representing words, and the second is a numeric vector of coefficients.

The print method uses lowercase letters a-z to represent the indeterminates; this is currently hard coded:

> (x <- as.freealg("6abbbc + 7cax"))
free algebra element algebraically equal to
+ 6*abbbc + 7*cax
> unclass(x)
$indices
$indices[[1]]
[1] 1 2 2 2 3

$indices[[2]]
[1]  3  1 24


$coeffs
[1] 6 7

The print method has special dispensation for length-zero freealg objects but these are not handled entirely consistently.

The print method is sensitive to the value of getOption("usecaret"), defaulting to “FALSE”. The default is to use uppercase letters to represent multiplicative inverses. Thus, the inverse of a appears as either “a^-1” if usecaret is TRUE, and “A” if FALSE. Carets become cumbersome for powers above the first. For example, the default notation for aba^{-2} is abAA but becomes aba^-1a^-1 if usecaret is TRUE.

The symbols for the indeterminates are currently hardcoded as c(letters,LETTERS). The intent is to be able to signify 52 distinct indeterminates, a-z,A-Z. This works fine if option usecaret is TRUE. But if option usecaret is FALSE, this can be confusing: for example, indeterminate number 1 appears as a, and its inverse would appear as “A”. But indeterminate number 27 also appears as “A”. They look the same, but no warning is given: caveat emptor!

The method is also sensitive to getOption("mulsym"), defaulting to NULL. This is the multiplication symbol used between the coefficient and the indeterminate string. Sometimes an asterisk, * or a space, might be useful. If mulsym takes its default of NULL [or a length zero string], the print method suppresses coefficients of \pm 1.

Integers exceeding SHRT_MAX are reserved for infinitesimals, which are printed as “da”; see the note at deriv.Rd for details.

Author(s)

Robin K. S. Hankin

See Also

freealg,deriv

Examples


rfalg()

x <- rfalg(inc=TRUE)
x                           # default
options("usecaret" = TRUE)  # use caret
x
options("usecaret" = FALSE) # back to the default
x


x <- freealg(list(5,1:4,3,8,7),c(1,1,1,3,22))
x


options(mulsym = "*")
x
options(mulsym = NULL)  # restore default


RobinHankin/freealg documentation built on Dec. 24, 2024, 3:16 a.m.