In this blog we will review the benefit of using element-wise operations for your computations. Element-wise operations are operations that are applied to every element in an array and allow the user to avoid coding loops and nested loops for rudimentary operations. In a simple example of an element-wise operation, we use both the addition (+) and multiply (*)operations:
<pre>array A = randu(1024, 1024), B = randu(1024, 1024);
array C=A*A+B+B;</pre>
An element-wise operator that is applied to a single element is unary operator. An operator that works on two elements is a binary operator. ArrayFire has implemented a large number element-wise operations that are applied to the elements of an array. These operators can help reduce the programming overhead for an application designer as:
<ul>
	<li>Performance - the application designed need not worry about implementing the operator. As these are implemented in OpenCL (with a focus on achieving high utilization), the programmer does not have deal with the partitioning of the work and load-balancing.</li>
	<li>Completeness - the array data type is no different than any other C scalar data type.</li>
	<li>Readability and maintenance - high performance computing becomes as simple as writing a script.</li>
</ul>
Our element-wise operations also include operations between an array and a scalar value. For example:
<pre>array A=randu(1024, 1024),B; 
B=A+1;</pre>
A small subset of these operators include:
<ul>
	<li>sin - computes the sine for each element in the array.</li>
	<li>cosine - computes the sine for each element in the array.</li>
	<li>abs - computes the absolute value for each element in the array.</li>
	<li>trunc - truncates every element in the array.</li>
</ul>
A full list of element-wise operators can also be found in our document under: <a href="http://sandbox.arrayfire.com/docs/group__arith.htm"><span style="text-decoration: underline;">element-wise operators</span></a> and <span style="text-decoration: underline;"><a title="operator overloading" href="http://sandbox.arrayfire.com/docs/group__array__operator.htm" target="_blank">operator-overloading functions</a></span>. These include trigonometric, arithmetic, and utility functions. We will extend the discussion on these in future posts.

&nbsp;

&nbsp;

&nbsp;

&nbsp;