Vector Computation In C++

All this was made by a single person without any grant-money.
If you find it useful then please donate securely using PayPal.
Even a few dollars are appreciated. Thanks!

S&P 500

Video Talks
Deep Learning

Source Code


Hvass Labs


ArrayOps is a source-code library for performing vector computations in C++ and is conceptually similar to the valarray-class of the Standard Template Library (STL). However, ArrayOps employs socalled Template Meta-Programming along with other advanced object-oriented programming techniques to improve efficiency and flexibility. ArrayOps essentially provides syntactic sugar for vector-notation which automatically compiles into a single flattened loop for each assignment involving vector expressions.

ArrayOps has a number of advantages over similar existing libraries (e.g. Blitz++ and POOMA), including a much simpler framework that easens the maintenance and user-specialization, which means ArrayOps also provides different vector-datatypes that are tailored to specific needs, and all vector-datatypes may be combined arbitrarily in arithmetic expressions.


To illustrate the basic idea of ArrayOps, consider the following C++ source-code example where we create and manipulate three arrays, each containing 100 elements:

const unsigned int k = 100;
ArrayOps::Array<double> A(k), B(k), C(k);
double b, c;

// Read numbers b and c from somewhere ...
// Read arrays B and C from somewhere ...

A = b*B + c*C;

Here, due to the use of socalled meta-programming, the last line is automatically transformed at compile-time into the following loop:

for (unsigned int i=0; i<A.Size(); i++)
A[i] = b*B[i] + c*C[i];

Where the datatypes are ensured to be the same at compile-time and the sizes of the arrays are asserted to match in debug-mode. Note that no implicit allocations of socalled temporaries take place as would be the case if the valarray-class from the STL had been used.



Installing and using ArrayOps is incredibly simple, as there are no code-libraries that have to be compiled, and ArrayOps only consists of C++ header-files. Simply do the following:

  1. Download the ArrayOps source-code (see below).
  2. Unpack the ArrayOps source-code to a directory of your choice.
  3. Add that directory to the include-paths of your C++ project.
  4. Add #include statements to your source-code, for the ArrayOps datatypes that you need (e.g. Array, ArrayMini, or ArrayUse).
  5. Write your source-code using ArrayOps, and compile.


ArrayOps was developed in MS Visual C++ 2005, and as the source-code relies on fairly new programming techniques, it may not be compatible with all C++ compilers.

The parallel features of ArrayOps have not been tested beyond their ability to compile, but parallelism may be disabled during compilation, by either switching off OpenMP support in the C++ compiler, or by forcing all arrays to be non-parallel.


ArrayOps is published under the GNU Lesser General Public License, which essentially means that you may distribute commercial programs that link with the ArrayOps library, as well as make alterations to the ArrayOps library itself. There are certain terms to be met though, please see the license for details.

Hvass Laboratories