# GainBlock

Multiplication or convolution by a constant value.

## Description #

Multiplies/convolves input by a value (gain).

## Interface Definition #

GainBlock<TInput, TGain, TOps, TConv>

### Template Parameters #

IndexParameter typeNameDescriptionDefault value
0typenameTInputInput value type-
1typenameTGainGain value typeTInput
2GainBlockOperatorTOpsGain block operator type::Left
3GainBlockConvolutionModeTConvGain block convolution type::Reflect

### Inputs #

IndexParameter typeNameDescriptionDefault value
0<TInput>-Input value-

### Outputs #

IndexParameter typeNameDescriptionDefault value
0<TOutput>-Output value-

Determination of TOutput is not straightforward; in the case of multiplication, we must first check if multiplication is possible. In the case of a scalar gain, or convolution, the output type is the same as TInput.

### Parameters #

IndexParameter typeNameDescriptionDefault value
0<TGain>gainGain value-
1doubleconstantConstant value-

The function of gain varies with TOps; see Effects.

## Effects #

If TOps is:

• ::Left, left-multiply the input by the gain.
• ::Right, right-multiply the input by the gain.
• ::Convolution, convolve the input with the gain, where the boundary condition is determined by TConv.

If TOps is ::Convolution, and TConv is:

• ::Reflect, reflect about the edge of the last pixel. Also known as half-sample symmetric.
• ::Constant, fill all values beyond edges with a constant value (see parameter 1 in Parameters).
• ::Nearest, extend by replicating last pixel.
• ::Mirror, extend by reflecting about the center of the last pixel. Also known as whole-sample symmetric.
• ::Wrap, wrap around to the opposing edge.

## Static Asserts #

• Multiplicability in case of TOps in {::Left, ::Right}.
• Scalar type congruence in case of TOps = ::Convolution.