On the fly CudaMat programming guide

This guide describes the basic rule for constructing an on-the-fly cuda program.
On-the-fly programs can be of various types, depending on the type of function you want to implement.
Your code will go right into the core of the graphic card (and thus can easily crash it) but the matlab wrapper will deal with all the parameter conversion and data transport issues including calling the cuda function itself. Thus programming such a function is made really easy.

Function types

The following function types currently exist and hopefully many more will be added later.
See also "help cuda_define"

Write your program
In all code snippets you are writing a number of variables are predefined:
If you need to calculate with the position coordinates in the arrays, you can start your program with the line
CoordsNDFromIdx(idx,sSize)
wich will create the array "pos" assigning each processor directly the multidimensional coordinate of its pixel.
Furthermore the lines
int idd;IdxNDFromCoords(pos,sSize,idd)
will calculate the index corresponding to the position given in pos such that a result can for example be written to c[idd]=a[idx];