A high-performance general-purpose compute library

Calculate the gradients of the input. More...

Functions

AFAPI void grad (array &dx, array &dy, const array &in)
 C++ Interface for calculating the gradients. More...
 
AFAPI af_err af_gradient (af_array *dx, af_array *dy, const af_array in)
 C Interface for calculating the gradients. More...
 

Detailed Description

Calculate the gradients of the input.

dx is the gradient along the 1st dimension of in. dy is the gradient along the 2nd dimension of in.

The gradients along the first and second dimensions are calculated simultaneously

array in = randu(dim4(5, 3));
array dx, dy;
grad(dx, dy, in);
// in [5 3 1 1]
// 0.0000 0.2190 0.3835
// 0.1315 0.0470 0.5194
// 0.7556 0.6789 0.8310
// 0.4587 0.6793 0.0346
// 0.5328 0.9347 0.0535
//
// dx [5 3 1 1]
// 0.1315 -0.1719 0.1359
// 0.3778 0.2300 0.2237
// 0.1636 0.3161 -0.2424
// -0.1114 0.1279 -0.3888
// 0.0741 0.2554 0.0189
//
// dy [5 3 1 1]
// 0.2190 0.1917 0.1645
// -0.0845 0.1939 0.4724
// -0.0767 0.0377 0.1521
// 0.2206 -0.2120 -0.6447
// 0.4019 -0.2397 -0.8812

Function Documentation

◆ af_gradient()

AFAPI af_err af_gradient ( af_array dx,
af_array dy,
const af_array  in 
)

C Interface for calculating the gradients.

Parameters
[out]dxthe gradient along first dimension
[out]dythe gradient along second dimension
[in]inis the input array
Returns
AF_SUCCESS if the color transformation is successful, otherwise an appropriate error code is returned.

◆ grad()

AFAPI void grad ( array dx,
array dy,
const array in 
)

C++ Interface for calculating the gradients.

Parameters
[out]dxthe gradient along first dimension
[out]dythe gradient along second dimension
[in]inis the input array