E
- type of this abstract 2D matrixabstract class AbstractMatrix2D<E> extends Object implements Matrix2D<E>
Modifier and Type | Field and Description |
---|---|
protected long |
columns
Number of columns.
|
protected long |
columnStride
Number of columns between two elements.
|
protected long |
columnZero
Column of the first element.
|
protected boolean |
isView
True if this instance is a view.
|
protected long |
rows
Number of rows.
|
protected long |
rowStride
Number of rows between two elements.
|
protected long |
rowZero
Row of the first element.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMatrix2D()
Protected no-arg constructor, to support serialization.
|
protected |
AbstractMatrix2D(long rows,
long columns)
Create a new abstract 2D matrix with the specified number of
rows and columns.
|
protected |
AbstractMatrix2D(long rows,
long columns,
long rowZero,
long columnZero,
long rowStride,
long columnStride,
boolean isView)
Create a new abstract 2D matrix with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
E |
aggregate(BinaryFunction<E,E,E> aggr,
UnaryFunction<E,E> function)
Apply a function to each value in this 2D matrix and aggregate
the result.
|
E |
aggregate(Matrix2D<? extends E> other,
BinaryFunction<E,E,E> aggr,
BinaryFunction<E,E,E> function)
Apply a function to each value in this 2D matrix and the specified
matrix and aggregate the result.
|
Matrix2D<E> |
assign(E e)
Assign all values in this 2D matrix to
e (optional operation). |
Matrix2D<E> |
assign(Matrix2D<? extends E> other)
Assign all values in this 2D matrix to the values in the
specified matrix (optional operation).
|
Matrix2D<E> |
assign(Matrix2D<? extends E> other,
BinaryFunction<E,E,E> function)
Assign the result of the specified function of a value from
this 2D matrix and the specified matrix to each value in this
2D matrix (optional operation).
|
Matrix2D<E> |
assign(UnaryFunction<E,E> function)
Assign the result of the specified function to each value
in this 2D matrix (optional operation).
|
long |
cardinality()
Return the cardinality of this 2D matrix, the number
of non-null values.
|
void |
clear()
Clear all the values in this 2D matrix (optional operation).
|
long |
columns()
Return the number of columns in this 2D matrix.
|
protected long |
columnStride()
Return the number of columns between two elements.
|
protected long |
columnZero()
Return the column of the first element.
|
void |
forEach(TernaryPredicate<Long,Long,? super E> predicate,
TernaryProcedure<Long,Long,? super E> procedure)
Apply the specified procedures to each row and column
and to each value in this 2D matrix accepted by the specified predicate.
|
void |
forEach(TernaryProcedure<Long,Long,? super E> procedure)
Apply the specified procedures to each row and column and
to each value in this 2D matrix.
|
void |
forEach(UnaryPredicate<? super E> predicate,
UnaryProcedure<? super E> procedure)
Apply the specified procedure to each value in this 2D matrix
accepted by the specified predicate.
|
void |
forEach(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each value in this 2D matrix.
|
void |
forEachNonNull(UnaryProcedure<? super E> procedure)
Apply the specified procedure to each non-null value in this 2D matrix.
|
E |
get(long row,
long column)
Return the value at the specified row and column.
|
boolean |
isEmpty()
Return true if the cardinality of this 2D matrix is zero.
|
protected boolean |
isView()
Return true if this instance is a view.
|
Iterator<E> |
iterator()
Return an iterator over the values in this 2D matrix, including
null s. |
long |
rows()
Return the number of rows in this 2D matrix.
|
protected long |
rowStride()
Return the number of rows between two elements.
|
protected long |
rowZero()
Return the row of the first element.
|
void |
set(long row,
long column,
E e)
Set the value at the specified row and column to
e (optional
operation). |
void |
setQuick(long row,
long column,
E e)
Set the value at the specified row and column to
e without checking bounds (optional operation). |
long |
size()
Return the size of this 2D matrix.
|
String |
toString() |
protected AbstractMatrix2D<E> |
vColumnFlip()
Self-modifying version of
viewColumnFlip() . |
protected AbstractMatrix2D<E> |
vDice()
Self-modifying version of
viewDice() . |
protected AbstractMatrix2D<E> |
view()
Create a new view.
|
Matrix2D<E> |
viewColumnFlip()
Return a new 2D matrix flip view along the column axis.
|
Matrix2D<E> |
viewDice()
Return a new 2D matrix dice (transposition) view.
|
Matrix2D<E> |
viewPart(long row,
long column,
long height,
long width)
Return a new 2D matrix sub-range view that contains only those values
from
(row, column) to
(row + height - 1, column + width - 1) . |
Matrix2D<E> |
viewRowFlip()
Return a new 2D matrix flip view along the row axis.
|
Matrix2D<E> |
viewSelection(BitMatrix2D mask)
Return a new 2D matrix selection view that contains only those values
at the indices present in the specified bit mask.
|
Matrix2D<E> |
viewSelection(long[] rows,
long[] columns)
Return a new 2D matrix selection view that contains only those values at the
specified indices.
|
Matrix2D<E> |
viewSelection(UnaryPredicate<Matrix1D<E>> predicate)
Return a new 2D matrix selection view that contains only those rows
selected by the specified predicate.
|
Matrix2D<E> |
viewStrides(long rowStride,
long columnStride)
Return a new 2D matrix stride view which is a sub matrix consisting
of every
rowStride -th row and every columnStride -th
column. |
protected AbstractMatrix2D<E> |
vPart(long row,
long column,
long height,
long width)
Self-modifying version of
viewPart(long, long, long, long) . |
protected AbstractMatrix2D<E> |
vRowFlip()
Self-modifying version of
viewRowFlip() . |
protected AbstractMatrix2D<E> |
vStrides(long rowStride,
long columnStride)
Self-modifying version of
viewStrides(long, long) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getQuick, viewColumn, viewRow
protected long rows
protected long columns
protected long rowZero
protected long columnZero
protected long rowStride
protected long columnStride
protected boolean isView
protected AbstractMatrix2D()
protected AbstractMatrix2D(long rows, long columns)
rows
- rows, must be >= 0
columns
- columns, must be >= 0
IllegalArgumentException
- if either rows
or
columns
is negativeprotected AbstractMatrix2D(long rows, long columns, long rowZero, long columnZero, long rowStride, long columnStride, boolean isView)
rows
- rows, must be >= 0
columns
- columns, must be >= 0
rowZero
- row of the first elementcolumnZero
- column of the first elementrowStride
- number of rows between two elementscolumnStride
- number of columns between two elementsisView
- true if this instance is a viewpublic long size()
public long rows()
public long columns()
public long cardinality()
cardinality
in interface Matrix2D<E>
public boolean isEmpty()
public void clear()
public Iterator<E> iterator()
null
s.public E get(long row, long column)
public void set(long row, long column, E e)
e
(optional
operation).public void setQuick(long row, long column, E e)
e
without checking bounds (optional operation).public Matrix2D<E> assign(E e)
e
(optional operation).public Matrix2D<E> assign(UnaryFunction<E,E> function)
public Matrix2D<E> assign(Matrix2D<? extends E> other)
public Matrix2D<E> assign(Matrix2D<? extends E> other, BinaryFunction<E,E,E> function)
public E aggregate(BinaryFunction<E,E,E> aggr, UnaryFunction<E,E> function)
public E aggregate(Matrix2D<? extends E> other, BinaryFunction<E,E,E> aggr, BinaryFunction<E,E,E> function)
protected AbstractMatrix2D<E> view()
protected AbstractMatrix2D<E> vDice()
viewDice()
.this
public Matrix2D<E> viewDice()
view.get(row, column) == this.get(column, row)
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.protected AbstractMatrix2D<E> vRowFlip()
viewRowFlip()
.this
public Matrix2D<E> viewRowFlip()
0
is now row rows() - 1
,
..., what used to be row rows() - 1
is now row 0
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.viewRowFlip
in interface Matrix2D<E>
protected AbstractMatrix2D<E> vColumnFlip()
viewColumnFlip()
.this
public Matrix2D<E> viewColumnFlip()
0
is now column columns() - 1
,
..., what used to be column columns() - 1
is now column
0
. The view is backed by this matrix, so changes made to the
returned view are reflected in this matrix, and vice-versa.viewColumnFlip
in interface Matrix2D<E>
protected AbstractMatrix2D<E> vPart(long row, long column, long height, long width)
viewPart(long, long, long, long)
.row
- rowcolumn
- columnheight
- heightwidth
- widththis
public Matrix2D<E> viewPart(long row, long column, long height, long width)
(row, column)
to
(row + height - 1, column + width - 1)
.
The view is backed by this matrix, so changes made to the returned
view are reflected in this matrix, and vice-versa.public Matrix2D<E> viewSelection(long[] rows, long[] columns)
viewSelection
in interface Matrix2D<E>
rows
- row indicescolumns
- column indicespublic Matrix2D<E> viewSelection(UnaryPredicate<Matrix1D<E>> predicate)
viewSelection
in interface Matrix2D<E>
predicate
- predicate, must not be nullpublic Matrix2D<E> viewSelection(BitMatrix2D mask)
viewSelection
in interface Matrix2D<E>
mask
- 2D bit mask, must not be nullprotected AbstractMatrix2D<E> vStrides(long rowStride, long columnStride)
viewStrides(long, long)
.rowStride
- row stridecolumnStride
- column stridethis
public Matrix2D<E> viewStrides(long rowStride, long columnStride)
rowStride
-th row and every columnStride
-th
column. The view is backed by this matrix, so changes made to the returned view
are reflected in this matrix, and vice-versa.viewStrides
in interface Matrix2D<E>
rowStride
- row stride, must be > 0
columnStride
- column stride, must be > 0
rowStride
-th row and every columnStride
-th
columnpublic void forEach(UnaryProcedure<? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
public void forEach(UnaryPredicate<? super E> predicate, UnaryProcedure<? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new UnaryPredicate<String>() { public boolean test(final String value) { return (value != null); } }, new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
public void forEachNonNull(UnaryProcedure<? super E> procedure)
For example:
Matrix2D<String> m; m.forEachNonNull(new UnaryProcedure<String>() { public void run(final String value) { System.out.println(value); } });
forEachNonNull
in interface Matrix2D<E>
procedure
- procedure, must not be nullpublic void forEach(TernaryProcedure<Long,Long,? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new TernaryProcedure<Long, Long, String>() { public void run(final Long row, final Long column, final String value) { System.out.print("m[" + row + ", " + column + "]=" + value); } });
public void forEach(TernaryPredicate<Long,Long,? super E> predicate, TernaryProcedure<Long,Long,? super E> procedure)
For example:
Matrix2D<String> m; m.forEach(new TernaryPredicate<Long, Long, String>() { public boolean test(final Long row, final Long column, final String value) { return (value != null); } }, new TernaryProcedure<Long, Long, String>() { public void run(final Long row, final Long column, final String value) { System.out.print("m[" + row + ", " + column + "]=" + value); } });
protected long rowZero()
protected long columnZero()
protected long rowStride()
protected long columnStride()
protected boolean isView()
Copyright (c) 2004-2013 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).