Extract.clifford {clifford} R Documentation

## Extract or Replace Parts of a clifford

### Description

Extract or replace subsets of cliffords.

### Usage

## S3 method for class 'clifford'
C[index, ...]
## S3 replacement method for class 'clifford'
C[index, ...] <- value
coeffs(x)
coeffs(x) <- value
list_modifier(B)
getcoeffs(C, B)


### Arguments

 C, x A clifford object index elements to extract or replace value replacement value B A list of integer vectors, terms ... Further arguments

### Details

Extraction and replacement methods. The extraction method uses getcoeffs() and the replacement method uses low-level helper function c_overwrite().

In the extraction function a[index], if index is a list, further arguments are ignored; if not, the dots are used. If index is a list, its elements are interpreted as integer vectors indicating which terms to be extracted (even if it is a disord object). If index is a disord object, standard consistency rules are applied. The extraction methods are designed so that idiom such as a[coeffs(a)>3] works.

For replacement methods, the standard use-case is a[i] <- b in which argument i is a list of integer vectors and b a length-one numeric vector. Otherwise, to manipulate parts of a clifford object, use coeffs(a) <- value; this effectively leverages disord formalism. Idiom such as a[coeffs(a)<2] <- 0 is not currently implemented (to do this, use coeffs(a)[coeffs(a)<2] <- 0). Replacement using a list-valued index, as in A[i] <- value uses an ugly hack if value is zero. Replacement methods are not yet finalised and not yet fully integrated with the disordR package.

Idiom such as a[] <- b follows the spray package. If b is a length-one scalar, then coeffs(a) <- b has the same effect as a[] <- b.

Functions terms() [see term.Rd] and coeffs() extract the terms and coefficients from a clifford object. These functions return disord objects but the ordering is consistent between them (an extended discussion of this phenomenon is presented in the mvp package).

Function coeffs<-() (idiom coeffs(a) <- b) sets all coefficients of a to b. This has the same effect as a[] <- b.

Extraction and replacement methods treat 0 specially, translating it (via list_modifier()) to numeric(0).

Extracting or replacing a list with a repeated elements is usually a Bad Idea (tm). However, if option warn_on_repeats is set to FALSE, no warning will be given (and the coefficient will be the sum of the coefficients of the term; see the examples).

Function getcoeffs() is a lower-level helper function that lacks the succour offered by [.clifford(). It returns a numeric vector [not a disord object: the order of the elements is determined by the order of argument B]. Compare standard extraction, eg a[index], which returns a clifford object.

Ops.clifford,clifford,term

### Examples

A <- clifford(list(1,1:2,1:3),1:3)
B <- clifford(list(1:2,1:6),c(44,45))

A[1,c(1,3,4)]

A[2:3, 4] <- 99
A[] <- B

# clifford(list(1,1:2,1:2),1:3)  # would give a warning

options("warn_on_repeats" = FALSE)
clifford(list(1,1:2,1:2),1:3)  # works; 1e1 + 5e_12