const | R Documentation |
Get and set the constant term of a clifford object.
const(C,drop=TRUE) is.real(C) ## S3 replacement method for class 'clifford' const(x) <- value
C,x |
Clifford object |
value |
Replacement value |
drop |
Boolean, with default |
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.
Robin K. S. Hankin
grade
,
clifford
,
getcoeffs
,
is.zero
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.