Arithmetical Operators: +, -, *, /, ^, %%, %/%, %*% for hyperSpec objects
# S4 method for hyperSpec,hyperSpec
Arith(e1, e2)# S4 method for hyperSpec,numeric
Arith(e1, e2)
# S4 method for hyperSpec,matrix
Arith(e1, e2)
# S4 method for hyperSpec,missing
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)
or
either two hyperSpec objects or
one hyperSpec object and matrix of same size as hyperSpec[[]] or
a vector which length equalling either the number of rows or the number of wavelengths of the hyperSpec object, or
a scalar (numeric of length 1).
hyperSpec object with the new spectra matrix.
The arithmetical operators +, -, *, /, \^, %%,
%/%, and %*% for hyperSpec objects.
You can use these operators in different ways:
e1 + e2 `+` (e1, e2)x %*% y `%*%`(x, y)
-x
The arithmetical operators +, -, *, /, ^, %%,
%/%, and %*% work on the spectra matrix of the hyperSpec object. They
have their usual meaning (see Arithmetic). The operators work also with one
hyperSpec object and a numeric object or a matrices of the same size as the spectra matrix
of the hyperSpec object.
With numeric vectors sweep is most probably more appropriate.
If you want to calculate on the extra data as well, use the data.frame hyperSpec@data
directly or as.data.frame (x).
sweep-methods for calculations involving a vector and
the spectral matrix.
S4groupGeneric for group generic methods.
Arithmetic for the base arithmetic functions.
Comparison for comparison operators,
Math for mathematical group generic
functions (Math and Math2 groups) working on hyperSpec objects.
matmult for matrix multiplications with %*%.
# NOT RUN {
flu + flu
1 / flu
all((flu + flu - 2 * flu)[[]] == 0)
-flu
flu / flu$c
# }
Run the code above in your browser using DataLab