# multiply: multiply a colorSpec object by scalar, vector, or matrix In colorSpec: Color Calculations with Emphasis on Spectral Data

## Description

multiply spectra by coefficients and return modified object

## Usage

 ```1 2 3 4 5``` ```## S3 method for class 'colorSpec' multiply( x, s ) ## S3 method for class 'colorSpec' normalize( x, norm='L1' ) ```

## Arguments

 `x` a colorSpec object with M spectra `s` a scalar, an M-vector, or an MxP matrix `norm` one of `'L1'`, `'L2'`, or `'Linf'`, specifying one of the standard vector norms L_1, L_2, or L_{inf}. `norm` can also be a numeric wavelength (e.g. 560 nm), and then the spectrum is scaled to have value 1 at this wavelength. Of course, this is not a true vector norm.

## Details

For `multiply()`:
If `s` is an MxP matrix, say S, and one thinks of the spectra as organized in an NxM matrix X, then the new spectra are defined by the matrix XS, which is NxP. If the P column names of `s` are set, then they are copied to the spectrum names of the output. Otherwise, default spectrum names are assigned as in `colorSpec`.
If `s` is an M-vector, then S=`diag(s)` is computed and used in the previous sentence. This has the effect of multiplying spectrum i by `s`[i].
If `s` is a scalar then every spectrum is multiplied by `s`.
The multiplication may produce negative entries, but no check is made for this.
WARNING: An M-vector and an Mx1 matrix may yield quite different results.

For `normalize()`:
`normalize()` calls `multiply` with `s` = an M-vector. If the norm of a spectrum is 0, then it is left unchanged.

## Value

`multiply` returns a colorSpec object with the matrix of spectra of `x` multiplied by `s`.

`normalize` returns a colorSpec object with each spectrum of `x` scaled to have given norm equal to 1.

In both functions, the `quantity` and `wavelength` are preserved.

## Note

If `x` is organized as a matrix, and `s` is a scalar, the one can use the simpler and equivalent `s*x`.

`product`, `quantity`, `wavelength`, `colorSpec`