--- layout: stdlib-reference --- # mad ## Description Computes multiply-add. ## Signature
/// Requires Capability Set 1:
T mad<T>(
    T mvalue,
    T avalue,
    T bvalue)
    where T : __BuiltinFloatingPointType;

/// Requires Capability Set 1:
vector<T, N> mad<T, int N>(
    vector<T, N> mvalue,
    vector<T, N> avalue,
    vector<T, N> bvalue)
    where T : __BuiltinFloatingPointType;

/// Requires Capability Set 2:
matrix<T, N, M> mad<T, int N, int M>(
    matrix<T, N, M> mvalue,
    matrix<T, N, M> avalue,
    matrix<T, N, M> bvalue)
    where T : __BuiltinFloatingPointType;

/// Requires Capability Set 3:
T mad<T>(
    T mvalue,
    T avalue,
    T bvalue)
    where T : __BuiltinIntegerType;

/// Requires Capability Set 3:
vector<T, N> mad<T, int N>(
    vector<T, N> mvalue,
    vector<T, N> avalue,
    vector<T, N> bvalue)
    where T : __BuiltinIntegerType;

/// Requires Capability Set 3:
matrix<T, N, M> mad<T, int N, int M>(
    matrix<T, N, M> mvalue,
    matrix<T, N, M> avalue,
    matrix<T, N, M> bvalue)
    where T : __BuiltinIntegerType;

## Generic Parameters #### T: [\_\_BuiltinFloatingPointType](../interfaces/0_builtinfloatingpointtype-029hm/index.html) #### N : int #### M : int #### T: [\_\_BuiltinIntegerType](../interfaces/0_builtinintegertype-029g/index.html) ## Parameters #### mvalue : [T](mad.html#typeparam-T) The multiplier. #### avalue : [T](mad.html#typeparam-T) The multiplicand. #### bvalue : [T](mad.html#typeparam-T) The addend. #### mvalue : [vector](../types/vector/index.html)\<[T](../types/vector/index.html#typeparam-T), [N](../types/vector/index.html#decl-N)\> The multiplier. #### avalue : [vector](../types/vector/index.html)\<[T](../types/vector/index.html#typeparam-T), [N](../types/vector/index.html#decl-N)\> The multiplicand. #### bvalue : [vector](../types/vector/index.html)\<[T](../types/vector/index.html#typeparam-T), [N](../types/vector/index.html#decl-N)\> The addend. #### mvalue : [matrix](../types/matrix/index.html)\<[T](../types/matrix/t-0.html), [N](../types/matrix/index.html#decl-N), [M](../types/matrix/index.html#decl-M)\> The multiplier. #### avalue : [matrix](../types/matrix/index.html)\<[T](../types/matrix/t-0.html), [N](../types/matrix/index.html#decl-N), [M](../types/matrix/index.html#decl-M)\> The multiplicand. #### bvalue : [matrix](../types/matrix/index.html)\<[T](../types/matrix/t-0.html), [N](../types/matrix/index.html#decl-N), [M](../types/matrix/index.html#decl-M)\> The addend. ## Return value The result of mvalue*avalue+bvalue. ## Availability and Requirements ### Capability Set 1 Defined for the following targets: #### hlsl Available in all stages. #### glsl Available in all stages. #### cpp Available in all stages. #### cuda Available in all stages. #### metal Available in all stages. #### wgsl Available in all stages. #### spirv Available in all stages. #### llvm Available in all stages. ### Capability Set 2 Defined for the following targets: #### hlsl Available in all stages. #### glsl Available in all stages. #### cpp Available in all stages. #### cuda Available in all stages. #### metal Available in all stages. #### spirv Available in all stages. #### llvm Available in all stages. ### Capability Set 3 Defined for the following targets: #### hlsl Available in all stages. #### glsl Available in all stages. #### cpp Available in all stages. #### cuda Available in all stages. #### spirv Available in all stages. #### llvm Available in all stages.