af_grad

The C interface for Gradient along a dimension. More...

afError af_grad_B (bool *d_dx, bool *d_dy, unsigned nx, unsigned ny, const bool *d_in, unsigned batch)
 
afError af_grad_U (unsigned *d_dx, unsigned *d_dy, unsigned nx, unsigned ny, const unsigned *d_in, unsigned batch)
 Unsigned integer gradient function. More...
 
afError af_grad_I (int *d_dx, int *d_dy, unsigned nx, unsigned ny, const int *d_in, unsigned batch)
 Integer gradient function. More...
 
afError af_grad_S (float *d_dx, float *d_dy, unsigned nx, unsigned ny, const float *d_in, unsigned batch)
 Single precision, floating point gradient function. More...
 
afError af_grad_D (double *d_dx, double *d_dy, unsigned nx, unsigned ny, const double *d_in, unsigned batch)
 Double precision, floating point gradient function. More...
 

Detailed Description

The C interface for Gradient along a dimension.

grad computes the gradient of a matrix using a central difference along a given dimension. For an interior point in the matrix, \( n_i \), the central difference is computed as \( \frac{n_{i+1} - n_{i-1}}{2} \). For exterior points (those along the edge of the matrix), a one-sided difference is used.

array a; //a = [4 5 3]
// [8 10 9]
// [9 15 20]
array dx,dy;
grad(dcol,drow,a);
// Vertical gradient (along columns)
// dcol = [4 5 6]
// [2.5 5 8.5]
// [1 5 11]
// Horizontal gradient (along rows)
// drow = [1 -0.5 -2]
// [2 0.5 -1]
// [6 5.5 5]

Function Documentation

afError af_grad_B ( bool *  d_dx,
bool *  d_dy,
unsigned  nx,
unsigned  ny,
const bool *  d_in,
unsigned  batch 
)
Parameters
[out]d_dxOutput gradient along the first dimension
[out]d_dyOutput gradient along the second dimension
[in]nxNumber of elements in the first dimension
[in]nyNumber of elements in the second dimension
[in]d_inThe input the the gradient function
[in]batchThe number of input tiles being handledBoolean gradient function
afError af_grad_U ( unsigned *  d_dx,
unsigned *  d_dy,
unsigned  nx,
unsigned  ny,
const unsigned *  d_in,
unsigned  batch 
)

Unsigned integer gradient function.

afError af_grad_I ( int *  d_dx,
int *  d_dy,
unsigned  nx,
unsigned  ny,
const int *  d_in,
unsigned  batch 
)

Integer gradient function.

afError af_grad_S ( float *  d_dx,
float *  d_dy,
unsigned  nx,
unsigned  ny,
const float *  d_in,
unsigned  batch 
)

Single precision, floating point gradient function.

afError af_grad_D ( double *  d_dx,
double *  d_dy,
unsigned  nx,
unsigned  ny,
const double *  d_in,
unsigned  batch 
)

Double precision, floating point gradient function.