cern.colt.matrix.doc-files.semanticsOfViews.html Maven / Gradle / Ivy
Show all versions of parallelcolt Show documentation
Semantics of Views
Semantics of Views
Subranging
Subranging takes a number of range restrictions and produces a matrix view
which has the same number of dimensions but different shape. For example, restricting
the range to the last 5 indexes in each dimension again produces a 3-dimensional
matrix (view) but now with less extent.
Slicing
Slicing blends out one or more dimensions. It produces a matrix view which
is lower dimensional than the original. In the above picture, the second dimension
has been fixed to index 2, yielding a flat two-dimensional plate. Since the
view has a 2-dimensional type it will accept any operation defined on two-dimensional
matrices and may be used as argument to any external method operating on 2-dimensional
matrices.
Dicing
Dicing virtually rotates the matrix. It exchanges one or more axes of the coordinate
system. Thus, a 3 x 4 matrix can be seen as a 4 x 3 matrix, a 3 x 4 x 5 matrix
can be seen as a 5 x 3 x 4 matrix, and so on. Dicing produces a view with the
same dimensionality but different shape.
Flipping
Flipping mirrors coordinate systems. What used to be the first index becomes
the last, ..., what used to be the last index becomes the first. Thus, a matrix
can be seen from the "left", the "right", the "top",
the "bottom", the "front", the "backside", etc.
Flipping produces a view with the same dimensionality and the same shape.
Striding
Striding blends out all but every i-th cell. It produces a view with the same
dimensionality but smaller (or equal) shape.
Selecting
Selecting blends out all but certain indexes of slices, rows, columns. Indexes
may have arbitrary order and can occur multiple times. Selecting produces a
view with the same dimensionality but different shape (either larger or smaller).
Sorting
Sorting reorders cells along one given dimension. It produces a view with the
same dimensionality and the same shape but different cell order.
Combinations
All views are orthogonal to each other. They can be powerful tools, particularly
when applied in combination. Feeding the result of one view transformation into
another transformation can do complex things.
Copying, Assignment & Equality
Any matrix and view can be copied. Copying yields a new matrix equal
to the original (view) but entirely independent of the original. So changes
in the copy are not reflected in the original, and vice-versa.
Two matrices are equal if they have the same dimensionality (rank), value
type, shape and identical values in corresponding cells.
Assignment copies the cell values of one matrix into another matrix. Both matrices
must have the same dimensionality and shape.