const: The constant term of a Clifford object

constR Documentation

The constant term of a Clifford object

Description

Get and set the constant term of a clifford object.

Usage

const(C,drop=TRUE)
is.real(C)
## S3 replacement method for class 'clifford'
const(x) <- value

Arguments

C,x

Clifford object

value

Replacement value

drop

Boolean, with default TRUE meaning to return the constant coerced to numeric, and FALSE meaning to return a (constant) Clifford object

Details

Extractor method for specific terms. Function const() returns the constant element of a Clifford object. Note that const(C) returns the same as grade(C,0), but is faster.

The R idiom in const<-() is slightly awkward:

> body(`const<-.clifford`)
{
  stopifnot(length(value) == 1)
  x <- x - const(x)
  return(x + value)
}

The reason that it is not simply return(x-const(x)+value) or return(x+value-const(x)) is to ensure numerical accuracy; see examples.

Author(s)

Robin K. S. Hankin

See Also

grade, clifford, getcoeffs, is.zero

Examples


X <- clifford(list(1,1:2,1:3,3:5),6:9)
X
X <- X + 1e300
X

const(X) # should be 1e300

const(X) <- 0.6
const(X) # should be 0.6, no numerical error

# compare naive approach:

X <- clifford(list(1,1:2,1:3,3:5),6:9)+1e300
X+0.6-const(X)  # constant gets lost in the numerics

X <- clifford(list(1,1:2,1:3,3:5),6:9)+1e-300
X-const(X)+0.6  # answer correct by virtue of left-associativity


x <- 2+rcliff(d=3,g=3)
jj <- x*cliffconj(x)
is.real(jj*rev(jj))   # should be TRUE

clifford documentation built on Aug. 14, 2022, 1:05 a.m.