Input and output

DAPPLE has some primitive I/O capabilities for vectors and matrices. In particular, vectors and matrices can be used with iostreams for input and output:

intVector A(N); intMatrix B(N,M); ... cin >> A; // it expects N whitespace-separated integers cin >> B; // it expects N*M whitespace-separated integers, row-major order ... cout << A; // prints N tab-separated integers (no newlines) cout << B; // prints N lines, each with M tab-separated integers Only the active elements are written, so it may actually print fewer than N (or N*M) elements. If entire rows of a matrix are inactive, fewer than N lines may be printed. Similarly, for reading, only the active elements are read from input, and thus only the active elements should be provided as input.

Boolean vectors and matrices are printed as 0 and 1. Character vectors and matrices are printed without tab separators, and read without expecting them.

Vectors and matrices can also be loaded from an array, or stored into an array:

intVector A(N); intMatrix B(N,N); int array1[N]; int array2[N][N]; ... A.load(array1); B.load(array2); ... A.store(array1); B.store(array2); Only the active elements are loaded or stored.