An open API service indexing awesome lists of open source software.

https://github.com/hvass-labs/arrayops

Vector Computation in C++
https://github.com/hvass-labs/arrayops

Last synced: 6 months ago
JSON representation

Vector Computation in C++

Awesome Lists containing this project

README

          

# ArrayOps

ArrayOps is my old library from 2006 for performing vector computations in C++. It is conceptually similar to the valarray-class of the Standard Template Library (STL). However, ArrayOps employs socalled [Template Meta-Programming](http://en.wikipedia.org/wiki/Template_metaprogramming) 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 had a number of advantages over similar libraries from that time (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.

## Example

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 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