ArrayFire is a fantastic library when it comes to speed and performance. One of the things that people overlook when evaluating ArrayFire is the indexing options available to the user.

The ArrayFire library exposes the array data structure to the user. The array stores the data in a column major order. This means that the following code:

<pre>
float[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
array A(3, 3, a);
</pre>

Will produce the following matrix:

<a href="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/CodeCogsEqn.gif"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2014/06/CodeCogsEqn.gif" alt="3x3 Column Major Matrix" width="72" height="67" class="alignnone size-full wp-image-5986" /></a>

Notice how the first three values make up the first column.

You can index into the elements of the matrix using the parenthesis notation. For example, you can access the middle element of the array by using:

<pre>A(1, 1); // == 5</pre>

T