Vectors and Matrices

DAPPLE provides two new classes of data: Vector and Matrix. You can define one- and two-dimensional data sets, and manipulate them with many of the usual C++ operators, in parallel. In addition, you can compute some functions of the entire vector or matrix, such as summing all the elements. Finally, you can move elements around, perhaps to sort them.


Vectors.

A vector is simply a one-dimensional collection of elements. Each element is a scalar value, and can be an integer, character, boolean, or single- or double-precision floating-point number. For example, a vector of N integers called "data" can be defined with intVector data(N); The elements in this vector are not initialized. Later, it should be initialized in an assignment statement. To initialize it when it is defined, so that all of the elements have the same value, you can include a second argument: intVector data(N, 3); Here, all N elements of vector "data" have the value 3.

There are other vector types, used the same way:

intVector A(N); charVector B(N); floatVector C(N); doubleVector D(N); booleanVector E(N);

Matrices.

Matrices are used much like vectors. For example, the following all define matrices with N rows and M columns: intMatrix A(N,M, 3); charMatrix B(N,M, 'x'); floatMatrix C(N,M); doubleMatrix D(N,M); booleanMatrix E(N,M, false); Integer matrix A is initialized so that every element's value is 3. All elements in character matrix B are initialized to the character 'x'. Float matrix C and double matrix D are uninitialized. Finally, all elements in boolean matrix E are initialized to false.