Components

Matrices

The Matrices component defines matrix containers that are optimized for parallelism and parallel versions of common matrix operations (e.g. Add, Transform, Multiply). PTL's matrix operations work on matrices of primitive types (e.g. int, long, float, double).

RowMajor and ColumnMajor Layout

PTL matrices can have RowMajor or ColumnMajor layout (see the MatrixLayout enumeration in the documentation). PTL's matrix operations do not support all combinations of matrix layouts because some combinations do not lend themselves to fast and efficient parallel execution due to processor and memory architecture. Please read the class and method documentation to understand which layout combinations are supported for each operation.

The Matrix class offers very fast conversion between RowMajor and ColumnMajor layout using the Copy and PCopy methods. PTL does not do these conversions automatically when a specific layout is required for a method because even if the conversions don't add a significant overhead in speed, they add a significant overhead in memory allocation. Often, the new matrix is reused many times in subsequent operations, so we let the user control the matrix layout and conversions.

Better by Design

  • PTL offers parallel versions of all of its matrix operations (e.g. addition, multiplication) that are extremely easy to use. PTL's parallel methods are always prefixed with a "P" (e.g. PMultiply) and have the exact same parameters and usage as their sequential counterparts (e.g. Multiply).
  • PTL's MatrixOper classes contain both matrix-matrix multiplication and specialized matrix-vector multiplication methods for better performance.
  • If the number of matrix rows/columns is much greater than the number of processor cores on your system, PTL's matrix operations scale extremely well with the number of cores.
  • PTL's Matrices component for Java contains both the generic Matrix<T> class and specialized Matrix classes — MatrixInt32, MatrixInt64, MatrixFloat, MatrixDouble — in order to achieve maximum performance for its matrix operations in Java. These specializations are necessary because Java's generics implementation does not support value types (e.g. int, long, float, double), so we cannot instantiate Matrix<int> in Java (like in C#). PTL's specialized Matrix classes are much faster than using Matrix<Integer>, Matrix<Long>, etc.