CUDALink provides you with carefully tuned linear algebra, discrete Fourier transforms, and image processing algorithms. You can also write your own CUDALink modules with minimal effort. Using CUDALink from within the Wolfram Language gives you access to the Wolfram Language's features, including visualization, import/export, and programming capabilities.
CUDALink list processing functions are designed to mimic the existing Wolfram Language functions, and, while less general than the Wolfram Language's implementation, they do provide the most commonly used functions. CUDALink implements the following list processing functions.
|CUDAMap||map a function to each element of an input list|
|CUDAFold||given an initial value and a function , this returns|
|CUDAFoldList||given an initial value and a function , this returns|
|CUDASort||sort a given list|
|CUDATotal||find the total value of a given list|
Once loaded, the above functions can be used. This maps the function Cos to a random list.
Computation can be strung together. Here you can find the total of the above list using CUDAFold (called reduction in the GPU programming field).
Given a height map, the line of sight problem finds all points on the height map visible from a single point. It does so by first transforming the height map to an angular map, and then performing a Max fold on the angular map. The results from the maxAngle list can then be easily used to determine if a point is visible or not.
The maxAngle list is computed using CUDAFoldList.
Random walk is a common tool used in many applications, such as the analysis of Brownian motion in physics. This shows a random walk in one dimension using CUDAFoldList.
Histograms are commonly used in many applications to place elements in bins. Here, you can use CUDASort to simplify the histogram calculation. This sorts the input image.
Once sorted, given a value to count the number of its occurrences, you need to scan the sorted list until its value changes. To find the first element, you have to count the number of elements until the element is not equal to the first.
This resulting histogram is plotted using ListLinePlot.
The CUDALink Image Processing module can be classified into three categories. The first is convolution, which is optimized for CUDA. The second is morphology, which contains abilities such as erosion, dilation, opening, and closing. Finally, there are the binary operators. These are the image multiplication, division, subtraction, and addition operators. All operations work on either images or lists.
|CUDAImageConvolve||convolve the kernel with the specified kernel|
|CUDABoxFilter||convolve the kernel with the BoxMatrix kernel|
|CUDAErosion||perform morphological erosion|
|CUDADilation||perform morphological dilation|
|CUDAOpening||perform morphological opening|
|CUDAClosing||perform morphological closing|
|CUDAClamp||clamp the values between a range|
|CUDAColorNegate||invert the values of input|
|CUDAImageAdd||add two inputs|
|CUDAImageSubtract||subtract two inputs|
|CUDAImageMultiply||multiply two inputs|
|CUDAImageDivide||divide two inputs|
Since the CUDA image processing functions behave like Wolfram Language functions, you can combine them with existing Wolfram Language functions. Here, you can apply CUDAImageMultiply to all combinations of a set of images.
The CUDA image processing functions work with the Wolfram Language's dynamic evaluators, such as Manipulate, Dynamic, and Animate. Here, you can use Animate to create an animation of how an image behaves as it is convolved with different GaussianMatrix radius sizes.
CUDALink's image processing operators are building blocks to more complicated operators. Here, you can define the CUDADarker operator, which is similar to the Darker operator in the Wolfram Language.
Since all image processing functions are also list processing functions, you can process any data that can be represented by a Wolfram Language list. In this example, you can use CUDAClamp to process geographic elevation data by clamping values in the elevation map.
The following example requires a web camera. CurrentImage returns an error if no camera is detected.
|CUDADot||give product of vectors and matrices|
|CUDATranspose||tranpose input matrix|
|CUDAArgMaxList||give the index with maximum absolute element|
|CUDAArgMinList||give the index with minimum absolute element|
|CUDAFourier||find the Fourier transform|
|CUDAInverseFourier||find the inverse Fourier transform|
This shows the result in MatrixForm.
|CUDAFluidDynamics||compute and render a fluid dynamics simulation|
|CUDAVolumetricRender||render volumetric data|