Skip to contents

Operators performing operations in the simplex.

Usage

# S4 method for CompositionMatrix,CompositionMatrix
+(e1, e2)

# S4 method for CompositionMatrix,CompositionMatrix
-(e1, e2)

# S4 method for CompositionMatrix,numeric
*(e1, e2)

# S4 method for numeric,CompositionMatrix
*(e1, e2)

Arguments

e1

A CompositionMatrix object.

e2

A CompositionMatrix object or a numeric vector.

Value

A CompositionMatrix object or a numeric vector (same as e1).

See also

Other operations in the simplex: closure(), perturbation(), powering(), scalar()

Author

N. Frerebeau

Examples

x <- as_composition(c(1, 2, 3))
y <- as_composition(c(1, 2, 1))

## Perturbation
perturbation(x, y)
#> <CompositionMatrix: 1 x 3>
#>       V1  V2    V3
#> S1 0.125 0.5 0.375
x + y
#> <CompositionMatrix: 1 x 3>
#>       V1  V2    V3
#> S1 0.125 0.5 0.375

## Powering
powering(y, 2)
#> <CompositionMatrix: 1 x 3>
#>           V1        V2        V3
#> S1 0.1666667 0.6666667 0.1666667
y * 2
#> <CompositionMatrix: 1 x 3>
#>           V1        V2        V3
#> S1 0.1666667 0.6666667 0.1666667

## Scalar product
scalar(x, y)
#> [1] 0.06646867