`+`

, `-`

, `*`

, `/`

, `^`

, `%%`

, `%/%`

, `%*%`

for `hyperSpec`

objects`R/Arith.R`

`Arith.Rd`

The arithmetical operators `+`

, `-`

, `*`

, `/`

, `^`

, `%%`

, `%/%`

, and `%*%`

`hyperSpec`

objects.

```
# S4 method for hyperSpec,hyperSpec
Arith(e1, e2)
# S4 method for hyperSpec,missing
Arith(e1, e2)
# S4 method for hyperSpec,numeric
Arith(e1, e2)
# S4 method for hyperSpec,matrix
Arith(e1, e2)
# S4 method for numeric,hyperSpec
Arith(e1, e2)
# S4 method for matrix,hyperSpec
Arith(e1, e2)
# S4 method for hyperSpec,hyperSpec
%*%(x, y)
# S4 method for hyperSpec,matrix
%*%(x, y)
# S4 method for matrix,hyperSpec
%*%(x, y)
```

- e1, e2
or

- x, y
either two

`hyperSpec`

objects orone

`hyperSpec`

object and matrix of same size as`x[[]]`

ora vector which length equaling either the number of rows or the number of wavelengths of the

`hyperSpec`

object, ora scalar (numeric of length 1).

`hyperSpec`

object with the new spectra matrix.
If the `e2`

is a `hyperSpec`

object, its extra data columns will be dropped
silently.

You can use these operators in different ways:

```
e1 + e2
`+`(e1, e2)
x
-x
```

The arithmetical operators `+`

, `-`

, `*`

, `/`

, `^`

, `%%`

, `%/%`

, and
`%*%`

work on the spectra matrix of the `hyperSpec`

object. They have their
usual meaning (see base::Arithmetic). The operators work also with
one `hyperSpec`

object and a numeric object or a matrix of the same
size as the spectra matrix of the `hyperSpec`

object.

With numeric vectors `sweep()`

may be more explicit.

If you want to calculate on the extra data as well, use the data.frame
`hyperSpec@data`

directly or `as.data.frame(x)`

.

`sweep()`

for calculations with a vector and the spectra matrix.

methods::S4groupGeneric for group generic methods.

base::Arithmetic for the base arithmetic functions.

Comparison for comparison operators, Math for mathematical group generic functions (Math and Math2 groups) working on hyperSpec objects.

base::matmult for matrix multiplications with `%*%`

.

```
flu + flu
#> hyperSpec object
#> 6 spectra
#> 3 data columns
#> 181 data points / spectrum
1 / flu
#> hyperSpec object
#> 6 spectra
#> 3 data columns
#> 181 data points / spectrum
all((flu + flu - 2 * flu)[[]] == 0)
#> [1] TRUE
-flu
#> hyperSpec object
#> 6 spectra
#> 3 data columns
#> 181 data points / spectrum
flu / flu$c
#> hyperSpec object
#> 6 spectra
#> 3 data columns
#> 181 data points / spectrum
```