|
AlgART Home | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Matrix<T extends Array>
AlgART matrix: multidimensional array.
Unlike AlgART array, AlgART matrix is a very simple thing.
The matrix is just a pair:
The product of all dimensions must be equal to the array length. Moreover,
the array must be unresizable: so, the array length
cannot be changed after creating the matrix.
It is supposed that all matrix elements are stored in the AlgART array. The storing scheme is traditional. For 2D matrix, the matrix element (x,y) is stored at the position y*dim[0]+x of the array (dim[0] is the first matrix dimension: the "width"). For 3D matrix, the matrix element (x,y,z) is stored at the position z*dim[1]*dim[0]+y*dim[0]+x (dim[0] is the x-dimension, dim[1] is the y-dimension). In the common case, the element of n-dimensional matrix with coordinates i0,i1,...,in-1 is stored at the position
in-1dn-2...d1d0 + ... + i2d1d0 + i1d0 + i0,
where dk=dim[k] (k=0,1,...,n-1) is the dimension #k.
There are 3 basic ways to create a new matrix.
MemoryModel.newMatrix(Class, Class, long[])
method or one of more concrete methods MemoryModel.newByteMatrix(long[]),
MemoryModel.newShortMatrix(long[]), etc.Matrices.matrix(Array, long[]) method.matrix(Array) method of the matrix instance;
the new matrix instance will be created.
It is the basic way to change some properties of the built-in array,
for example, to convert it to immutable
or copy-on-next-write form.We do not provide special tools for accessing matrix elements by several indexes,
as "getByte(x,y)" or similar methods. But there is the index
method, that transforms a set of multidimensional indexes
i0, i2, ..., in-1
into the position in the corresponded array, as described above.
Also you can get a reference to the built-in array by the array() method.
The typical example of access to matrix elements is the following:
Matrix<UpdatableFloatArray> m = ...; m.array().setFloat(m.index(x, y, z), myValue);
There are two important notes concerning usage of matrices.
First, the matrix indexes in all methods (index,
dim(n), dim argument in MemoryModel.newMatrix, etc.) are ordered from the lowest index to the highest.
Please compare: for numeric matrix m, m.array().getDouble(m.index(15,10))
returns the element #15 of the row #10. However, for usual 2-dimentional Java array,
declared as "double[][] a", the same element is accessed as a[10][15]!
Second, the number of indexes in the index method
may differ from the number of dimensions (dimCount()).
In any case, the returned position in calculated by the formula listed above
(dimCount().
The matrix object is immutable, that means that there are no ways to change
any dimension or the reference to the built-in AlgART array.
But the matrix elements can be modified, if the AlgART array is not
immutable.
So, the matrix object is thread-safe or thread-compatible
in the same situation as the built-in AlgART array: see comments to Array interface.
The generic argument T specifies the type of the built-in AlgART array.
Any array type can be declared here, but the contract of this interface
requires that the array must be unresizable.
So, there are no ways to create a matrix with MutableArray (or its subinterface)
as the type argument, alike Matrix<MutableByteArray>:
all creation methods throw IllegalArgumentException in this case.
AlgART Laboratory 2007-2008
Array,
UpdatableArray,
MutableArray| Method Summary | ||
|---|---|---|
T |
array()
Returns a reference to the built-in AlgART array. |
|
|
arrayType(java.lang.Class<U> arraySupertype)
Returns array().getClass(),
if it is subtype of (or same type as) the passed arraySupertype,
or throws ClassCastException in other case. |
|
|
cast(java.lang.Class<U> arrayClass)
Returns this matrix, cast to the specified generic array type, or throws ClassCastException if the built-in AlgART array cannot be cast to the required type (because the array type is not its subclass). |
|
long[] |
coordinates(long index,
long[] result)
Returns the coordinates in the matrix, corresponding to the given linear index in the built-in AlgART array. |
|
long |
cyclicIndex(long... coordinates)
An analog of index(long[]) method, that does not check,
whether the passed coordinates are in the required ranges,
and also replaces the resulting shift by the positive remainder
from division of it by the length of the built-in array. |
|
long |
dim(int n)
Returns the dimension #n of this matrix or 1 if n>= dimCount(). |
|
int |
dimCount()
Returns the number of dimensions of this matrix. |
|
long[] |
dimensions()
Returns an array containing all dimensions of this matrix. |
|
boolean |
dimEquals(Matrix<?> m)
Indicates whether the other matrix has the same dimension array. |
|
long |
dimX()
Equivalent to dim(0). |
|
long |
dimY()
Equivalent to dim(1). |
|
long |
dimZ()
Equivalent to dim(2). |
|
java.lang.Class<?> |
elementType()
Equivalent to array().elementType(). |
|
boolean |
equals(java.lang.Object obj)
Indicates whether some other matrix is equal to this one. |
|
void |
flushResources()
Equivalent to array().flushResources(). |
|
void |
freeResources()
Equivalent to array().freeResources(). |
|
int |
hashCode()
Returns the hashcode of this matrix. |
|
|
immutableArrayType(java.lang.Class<U> arraySupertype)
Returns array().asImmutable().getClass(),
if it is subtype of (or same type as) the passed arraySupertype,
or throws ClassCastException in other case. |
|
long |
index(long... coordinates)
Returns the linear index in the built-in AlgART array of the matrix element with specified coordinates. |
|
long |
index(long x,
long y)
The simplified version of the full index method for the case
of 2-dimensional matrix. |
|
long |
index(long x,
long y,
long z)
The simplified version of the full index method for the case
of 3-dimensional matrix. |
|
boolean |
inside(long... coordinates)
Returns true if all specified coordinates ik are inside the ranges 0..dk-1. |
|
boolean |
inside(long x,
long y)
The simplified version of the full index method for the case
of 2-dimensional matrix. |
|
boolean |
inside(long x,
long y,
long z)
The simplified version of the full index method for the case
of 3-dimensional matrix. |
|
boolean |
isCopyOnNextWrite()
Equivalent to array().isCopyOnNextWrite(). |
|
boolean |
isDirectAccessible()
Returns true if and only if the built-in AlgART array implements DirectAccessible
interface and ((DirectAccessible)array()).hasJavaArray() method returns true. |
|
boolean |
isFresh()
Returns true if this matrix instance is fresh, that is if it was created by MemoryModel.newMatrix(Class, Class, long[]) method or by one of methods
MemoryModel.newBitMatrix(long[]),
MemoryModel.newByteMatrix(long[]), ..., and if the built-in AlgART array
is also fresh. |
|
boolean |
isImmutable()
Equivalent to array().isImmutable(). |
|
|
matrix(U anotherArray)
Returns the new matrix backed by the specified AlgART array with the same dimensions as this one. |
|
long |
size()
Equivalent to array().length(). |
|
Matrix<T> |
subMatr(long... positionAndDimensions)
Equivalent to subMatr(long[] position, long[] dimensions) method, where
position is the first half of positionAndDimensions array and
dimensions is it's second half. |
|
Matrix<T> |
subMatr(long[] position,
long[] dimensions)
Equivalent to subMatrix(long[] from, long[] to) method, where
from[k]=position[k] and to[k]=position[k]+dimensions[k] for all k. |
|
Matrix<T> |
subMatr(long[] position,
long[] dimensions,
java.lang.Object outsideValue)
Equivalent to subMatrix(long[] from, long[] to, Object outsideValue) method, where
from[k]=position[k] and to[k]=position[k]+dimensions[k] for all k. |
|
Matrix<T> |
subMatr(long x,
long y,
long z,
long dimX,
long dimY,
long dimZ,
java.lang.Object outsideValue)
Equivalent to subMatr(new long[]{x,y,z}, new long[]{dimX,dimY,dimZ}, outsideValue) |
|
Matrix<T> |
subMatr(long x,
long y,
long dimX,
long dimY,
java.lang.Object outsideValue)
Equivalent to subMatr(new long[]{x,y}, new long[]{dimX,dimY}, outsideValue) |
|
Matrix<T> |
subMatrix(long... fromAndTo)
Equivalent to subMatrix(long[] from, long[] to) method, where
from is the first half of fromAndTo array and
to is it's second half. |
|
Matrix<T> |
subMatrix(long[] from,
long[] to)
Returns a view of the rectangular fragment of this matrix between from, inclusive, and to, exclusive. |
|
Matrix<T> |
subMatrix(long[] from,
long[] to,
java.lang.Object outsideValue)
An extended analog of subMatrix(long[], long[]) method, allowing to get a rectangular fragment
which is not fully inside this matrix. |
|
Matrix<T> |
subMatrix(long fromX,
long fromY,
long fromZ,
long toX,
long toY,
long toZ,
java.lang.Object outsideValue)
Equivalent to subMatrix(new long[]{fromX,fromY,fromZ}, new long[]{toX,toY,toZ}, outsideValue) |
|
Matrix<T> |
subMatrix(long fromX,
long fromY,
long toX,
long toY,
java.lang.Object outsideValue)
Equivalent to subMatrix(new long[]{fromX,fromY}, new long[]{toX,toY}, outsideValue) |
|
java.lang.String |
toString()
Returns a brief string description of this object. |
|
long |
uncheckedIndex(long... coordinates)
An analog of index(long[]) method, that does not check,
whether the passed coordinates are in the required ranges. |
|
| Method Detail |
|---|
T array()
There is a guarantee that this method works very quickly (usually it just returns a value of some private field).
java.lang.Class<?> elementType()
array().elementType().
long size()
array().length().
<U extends Array> java.lang.Class<? extends U> arrayType(java.lang.Class<U> arraySupertype)
array().getClass(),
if it is subtype of (or same type as) the passed arraySupertype,
or throws ClassCastException in other case.
arraySupertype - the required supertype of the built-in AlgART array.
java.lang.NullPointerException - if the passed argument is null.
java.lang.ClassCastException - if arraySupertype does not allow storing
the built-in AlgART array.<U extends Array> java.lang.Class<? extends U> immutableArrayType(java.lang.Class<U> arraySupertype)
array().asImmutable().getClass(),
if it is subtype of (or same type as) the passed arraySupertype,
or throws ClassCastException in other case.
This method is useful if you need to get the class of immutable arrays,
corresponding to the type of the built-in AlgART array.
arraySupertype - the required supertype of the built-in AlgART array.
java.lang.NullPointerException - if the passed argument is null.
java.lang.ClassCastException - if arraySupertype does not allow storing
the immutable version of the built-in AlgART array.long[] dimensions()
The returned array is a clone of the internal dimension array stored in this object. The returned array is never empty (its length cannot be zero).
int dimCount()
dimensions().length, but works faster.
There is a guarantee that this method works very quickly (usually it just returns a value of some private field).
long dim(int n)
dimCount().
Equivalent to n<dimCount()?dimensions()[n]:1, but works faster.
There is a guarantee that this method works very quickly.
n - the index of dimension.
java.lang.IndexOutOfBoundsException - if n<0 (but not if n is too large).long dimX()
dim(0).
long dimY()
dim(1).
long dimZ()
dim(2).
long index(long... coordinates)
in-1dn-2...d1d0 + ... + i2d1d0 + i1d0 + i0,where dk=
dim(k).
All passed indexes ik must be in ranges 0..dk-1.
All elements of coordinates array are always used, regardless of the number of matrix dimensions.
But the extra elements of coordinates array must be zero,
because dk=1 for k>=dimCount().
Good algorithms processing the matrix should use this method rarely: usually there are more optimal ways to calculate necessary linear index. For example, if you just need to calculate something for all matrix elements, the best way is the following:
Array a = m.array();
for (long disp = 0, n = a.length(); disp < n; disp++)
// process the element #k of the array
coordinates - all coordinates.
java.lang.NullPointerException - if the passed array is null.
java.lang.IllegalArgumentException - if the passed array is empty (no coordinates are passed).
java.lang.IndexOutOfBoundsException - if some coordinate ik is out of range
0..dk-1.cyclicIndex(long[]),
coordinates(long, long[])
long index(long x,
long y)
index method for the case
of 2-dimensional matrix.
x - the first coordinate.y - the second coordinate.
dimX() + x.
java.lang.IndexOutOfBoundsException - if x<0, x>=dimX(),
y<0 or y>=dimX().
long index(long x,
long y,
long z)
index method for the case
of 3-dimensional matrix.
x - the first coordinate.y - the second coordinate.z - the third coordinate.
dimY() * dimX() + y * dimX() + x.
java.lang.IndexOutOfBoundsException - if x<0, x>=dimX(),
y<0, y>=dimX(),
z<0 or z>=dimZ().
long[] coordinates(long index,
long[] result)
index(long[]): for any index,
index(coordinates(index, null)) == index.
The result argument may be null or some array, containing at least dimCount()
elements. If the first case, this method allocates new Java array long[dimCount()]
for storing coordinates and returns it.
In the second case, this method stores the found coordinates in result array and returns it.
index - the linear index in the built-in AlgART array.result - the array where you want to store results; may be null.
java.lang.IllegalArgumentException - if result!=null, but result.length<dimCount().
java.lang.IndexOutOfBoundsException - if index<0 or index>=dim(0)*dim(1)*...=array().length().long uncheckedIndex(long... coordinates)
index(long[]) method, that does not check,
whether the passed coordinates are in the required ranges. More precisely,
uncheckedIndex(i0,i1,...,in-1)
always returns the following value:
in-1dn-2...d1d0 + ... + i2d1d0 + i1d0 + i0,where dk=
dim(k).
All calculations are performed with long type without any overflow checks.
All elements of coordinates array are always used, regardless of the number of matrix dimensions.
Please remember that dk=dim(k)=1
for k>=dimCount()
(extra elements of coordinates array)..
coordinates - all coordinates.
java.lang.NullPointerException - if the passed array is null.
java.lang.IllegalArgumentException - if the passed array is empty (no coordinates are passed).long cyclicIndex(long... coordinates)
index(long[]) method, that does not check,
whether the passed coordinates are in the required ranges,
and also replaces the resulting shift by the positive remainder
from division of it by the length of the built-in array.
More precisely, let i0,i1,...,in-1
are the arguments of the method, and index is the following value
(as in index(long[]) method):
index = in-1dn-2...d1d0 + ... + i2d1d0 + i1d0 + i0,where dk=
dim(k).
Here we do no require that the passed indexes ik
are in ranges 0..dk-1.
Then, let len=array().length()=dn-1...d1d0.
The result of this method is the following:
index >= 0 ? index % len ? index % len + len(It is in the 0..len-1 range always.) In other words, the resulting index is "pseudo-cyclical", as the resulting shift in
Matrices.asShifted(MemoryModel, Matrix, long[]) method.
All calculations are performed with long type without any overflow checks. All elements of coordinates array are always used, regardless of the number of matrix dimensions. (You may note that extra elements of coordinates array are ignored in fact: they add k*len summand, where k is an integer.)
coordinates - all coordinates.
java.lang.NullPointerException - if the passed array is null.
java.lang.IllegalArgumentException - if the passed array is empty (no coordinates are passed).boolean inside(long... coordinates)
This method allows simply check that the arguments of
the index method are correct and will not lead to
IndexOutOfBoundsException:
if (matrix.inside(i1, i2, ...)) {
long index = matrix.index(i1, i2, ...);
// processing an element at this index
} else {
// special branche for positions outside the matrix
}
coordinates - all coordinates.
java.lang.NullPointerException - if the passed array is null.
java.lang.IllegalArgumentException - if the passed array is empty (no coordinates are passed).
boolean inside(long x,
long y)
index method for the case
of 2-dimensional matrix.
x - the first coordinate.y - the second coordinate.
boolean inside(long x,
long y,
long z)
index method for the case
of 3-dimensional matrix.
x - the first coordinate.y - the second coordinate.z - the third coordinate.
<U extends Array> Matrix<U> matrix(U anotherArray)
Matrices.matrix(anotherArray, dimensions()).
The array anotherArray must be unresizable,
and its length must be equal to the length of the array built-in this matrix.
anotherArray - some another AlgART array with the same length as array().
java.lang.NullPointerException - if anotherArray argument is null.
java.lang.IllegalArgumentException - if the passed array is resizable
(for example, implements MutableArray).
SizeMismatchException - if the product of all dimensions is not equal to the passed array length.<U extends Array> Matrix<U> cast(java.lang.Class<U> arrayClass)
matrix((U)array), but returns
the reference to this instance (and, so, preserves the "fresh status")
and is compiled without "unchecked cast" warning.
This method is useful when you need to cast the type of AlgART array, built in this matrix, to to its sub- or superinterface.
arrayClass - the type of built-in array in the new matrix.
java.lang.NullPointerException - if the argument is null.
java.lang.ClassCastException - if the built-in AlgART array cannot be cast to the required type.
Matrix<T> subMatrix(long[] from,
long[] to)
dimCount(),
matching the following conditions:
from[0] <= i0 < to[0],
from[1] <= i1 < to[1],
. . .
from[n-1] <= in-1 < to[n-1]
So, every dimension dim(k) in the returned matrix will be equal to to[k]-from[k].
The following condition must be fulfilled for all k:
0<=from[k]<=to[k]<=thisMatrix.dim(k).
The element type of the returned matrix is identical to the element type
of this matrix.
The built-in AlgART array of the returned matrix is backed by the built-in array of this matrix,
so - if this matrix is not immutable -
- any changes of the elements of the returned matrix are reflected in this matrix, and vice-versa.
The returned matrix is immutable if, and only if,
the built-in array of this matrix does not implement UpdatableArray.
The Array.asTrustedImmutable() method
in the built-in array of the returned matrix is equivalent to Array.asImmutable(),
and Array.asCopyOnNextWrite() method just returns the full copy of the array.
In the built-in array of the returned matrix,
the following methods: newCompatibleEmptyArray(),
newCompatibleEmptyArray(Class elementType),
newCompatibleArray(long initialLength),
newCompatibleArray(Class elementType, long initialLength),
newCompatibleUnresizableArray(long length),
newCompatibleUnresizableArray(Class elementType, long length),
asCopyOnNextWrite(),
shallowClone(),
updatableClone(),
mutableClone()
are based on the calls of the corresponding newCompatible... method of the built-in
array of this matrix. It is the reason why this method does not use MemoryModel argument,
unlike, for example, Arrays.asShifted(MemoryModel, Array, long).
from - low endpoints (inclusive) of all coordinates.to - high endpoints (exclusive) of all coordinates.
java.lang.NullPointerException - if from or to argument is null.
java.lang.IllegalArgumentException - if from.length or to.length
is not equal to dimCount().
java.lang.IndexOutOfBoundsException - if, for some k,
from[k]<0 || to[k]>dim(k) ||
from[k]>to[k].subMatrix(long[], long[], Object),
subMatrix(long[]),
subMatr(long[], long[], Object),
subMatr(long[], long[])Matrix<T> subMatrix(long... fromAndTo)
subMatrix(long[] from, long[] to) method, where
from is the first half of fromAndTo array and
to is it's second half.
(In other words, from[k]=fromAndTo[k] and to[k]=fromAndTo[k+fromAndTo.length/2].)
The length of fromAndTo array must be equal to 2*dimCount().
fromAndTo - low endpoints (inclusive) and then high endpoints (exclusive) of all coordinates.
java.lang.NullPointerException - if fromAndTo argument is null.
java.lang.IllegalArgumentException - if fromAndTo.length is not equal to 2*dimCount().
java.lang.IndexOutOfBoundsException - in the same situations as in subMatrix(long[], long[]).
Matrix<T> subMatrix(long[] from,
long[] to,
java.lang.Object outsideValue)
subMatrix(long[], long[]) method, allowing to get a rectangular fragment
which is not fully inside this matrix.
More precisely, unlike that method, here the only requirement for the from and to
coordinate boundaries is from[k]<=to[k],
but from[k] may be negative and to[k] may be greater than dim(k).
The elements of the returned matrix, that do not correspond to any elements of this one
(i.e. "lie outside" of this matrix), are considered to be equal outsideValue:
any attempt to read them returns this value. Attempts to write to such elements of the returned matrix
are just ignored.
For non-primitive element types, the outsideValue argument
must be some instance of the the class elementType(), or its superclass, or null.
For primitive element types, outsideValue may be null or any
wrapper for primitive types: Boolean, Byte, etc. In this case,
it is automatically cast to the required element type (while reading elements)
according the following rules:
from - low endpoints (inclusive) of all coordinates.to - high endpoints (exclusive) of all coordinates.outsideValue - the value returned while reading elements, lying outside this matrix.
java.lang.NullPointerException - if from or to argument is null.
java.lang.IllegalArgumentException - if from.length or to.length
is not equal to dimCount(),
or if the product of all differences to[k]-from[k]
(i.e. desired total size of the new matrix)
is greater than Long.MAX_VALUE.
java.lang.IndexOutOfBoundsException - if, for some k,
from[k]>to[k] or to[k]-from[k]>Long.MAX_VALUE.subMatr(long[], long[], Object),
subMatr(long[], long[])
Matrix<T> subMatrix(long fromX,
long fromY,
long toX,
long toY,
java.lang.Object outsideValue)
subMatrix(new long[]{fromX,fromY}, new long[]{toX,toY}, outsideValue)
fromX - low endpoints (inclusive) of the first coordinate.fromY - low endpoints (inclusive) of the second coordinate.toX - high endpoints (exclusive) of the first coordinate.toY - high endpoints (exclusive) of the second coordinate.outsideValue - the value returned while reading elements, lying outside this matrix.
java.lang.IllegalArgumentException - if dimCount()!=2
or if the product (toX-fromX)*(toY-fromY)
(i.e. desired total size of the new matrix)
is greater than Long.MAX_VALUE.
java.lang.IndexOutOfBoundsException - if fromX>toX or toX-fromX>Long.MAX_VALUE,
or if fromY>toY or toY-fromY>Long.MAX_VALUE.
Matrix<T> subMatrix(long fromX,
long fromY,
long fromZ,
long toX,
long toY,
long toZ,
java.lang.Object outsideValue)
subMatrix(new long[]{fromX,fromY,fromZ}, new long[]{toX,toY,toZ}, outsideValue)
fromX - low endpoints (inclusive) of the first coordinate.fromY - low endpoints (inclusive) of the second coordinate.fromZ - low endpoints (inclusive) of the third coordinate.toX - high endpoints (exclusive) of the first coordinate.toY - high endpoints (exclusive) of the second coordinate.toZ - high endpoints (exclusive) of the third coordinate.outsideValue - the value returned while reading elements, lying outside this matrix.
java.lang.IllegalArgumentException - if dimCount()!=3
or if the product (toX-fromX)*(toY-fromY)*(toZ-fromZ)
(i.e. desired total size of the new matrix)
is greater than Long.MAX_VALUE.
java.lang.IndexOutOfBoundsException - if fromX>toX or toX-fromX>Long.MAX_VALUE,
or if fromY>toY or toY-fromY>Long.MAX_VALUE,
or if fromZ>toZ or toZ-fromZ>Long.MAX_VALUE.
Matrix<T> subMatr(long[] position,
long[] dimensions)
subMatrix(long[] from, long[] to) method, where
from[k]=position[k] and to[k]=position[k]+dimensions[k] for all k.
This method is convenient for copying rectangular fragment of one matrix to another, for example:
Matrix<? extends Array> srcSm = src.subMatr(srcPos, dim); Matrix<? extends UpdatableArray> destSm = dest.subMatr(destPos, dim); Matrices.copy(someContext, destSm, srcSm);
position - low endpoints (inclusive) of all coordinates.dimensions - dimensions of the returned submatrix.
java.lang.NullPointerException - if position or dimensions argument is null.
java.lang.IllegalArgumentException - if position.length or dimensions.length
is not equal to dimCount().
java.lang.IndexOutOfBoundsException - if, for some k,
position[k]<0 || dimensions[k]<0 ||
position[k]+dimensions[k]>dim(k).subMatr(long[], long[], Object),
subMatr(long[])Matrix<T> subMatr(long... positionAndDimensions)
subMatr(long[] position, long[] dimensions) method, where
position is the first half of positionAndDimensions array and
dimensions is it's second half.
(In other words, position[k]=positionAndDimensions[k] and
dimensions[k]=positionAndDimensions[k+positionAndDimensions.length/2].)
The length of positionAndDimensions array must be equal to 2*dimCount().
positionAndDimensions - low endpoints (inclusive) of all coordinates and then dimensions of the result.
java.lang.NullPointerException - if positionAndDimensions argument is null.
java.lang.IllegalArgumentException - if positionAndDimensions.length is not equal
to 2*dimCount().
java.lang.IndexOutOfBoundsException - in the same situations as in subMatr(long[], long[]).
Matrix<T> subMatr(long[] position,
long[] dimensions,
java.lang.Object outsideValue)
subMatrix(long[] from, long[] to, Object outsideValue) method, where
from[k]=position[k] and to[k]=position[k]+dimensions[k] for all k.
position - low endpoints (inclusive) of all coordinates.dimensions - dimensions of the returned submatrix.outsideValue - the value returned while reading elements, lying outside this matrix.
java.lang.NullPointerException - if position or dimensions argument is null.
java.lang.IllegalArgumentException - if position.length or dimensions.length
is not equal to dimCount(),
or if the product of all dimensions[k]
(i.e. desired total size of the new matrix)
is greater than Long.MAX_VALUE.
java.lang.IndexOutOfBoundsException - if, for some k, dimensions[k]<0.subMatr(long[], long[])
Matrix<T> subMatr(long x,
long y,
long dimX,
long dimY,
java.lang.Object outsideValue)
subMatr(new long[]{x,y}, new long[]{dimX,dimY}, outsideValue)
x - low endpoint (inclusive) of the first coordinate.y - low endpoint (inclusive) of the second coordinate.dimX - th first dimension of the returned submatrix.dimY - the second dimension of the returned submatrix.outsideValue - the value returned while reading elements, lying outside this matrix.
java.lang.IllegalArgumentException - if dimCount()!=2,
or if the product dimX*dimY
(i.e. desired total size of the new matrix)
is greater than Long.MAX_VALUE.
java.lang.IndexOutOfBoundsException - if dimX<0 or dimY<0.
Matrix<T> subMatr(long x,
long y,
long z,
long dimX,
long dimY,
long dimZ,
java.lang.Object outsideValue)
subMatr(new long[]{x,y,z}, new long[]{dimX,dimY,dimZ}, outsideValue)
x - low endpoint (inclusive) of the first coordinate.y - low endpoint (inclusive) of the second coordinate.z - low endpoint (inclusive) of the third coordinate.dimX - th first dimension of the returned submatrix.dimY - the second dimension of the returned submatrix.dimZ - the third dimension of the returned submatrix.outsideValue - the value returned while reading elements, lying outside this matrix.
java.lang.IllegalArgumentException - if dimCount()!=3,
or if the product dimX*dimY*dimZ
(i.e. desired total size of the new matrix)
is greater than Long.MAX_VALUE.
java.lang.IndexOutOfBoundsException - if dimX<0, dimY<0 or dimZ<0.boolean isImmutable()
array().isImmutable().
There is a guarantee that this method works very quickly.
boolean isCopyOnNextWrite()
array().isCopyOnNextWrite().
There is a guarantee that this method works very quickly.
boolean isDirectAccessible()
DirectAccessible
interface and ((DirectAccessible)array()).hasJavaArray() method returns true.
There is a guarantee that this method works very quickly.
boolean isFresh()
MemoryModel.newMatrix(Class, Class, long[]) method or by one of methods
MemoryModel.newBitMatrix(long[]),
MemoryModel.newByteMatrix(long[]), ..., and if the built-in AlgART array
is also fresh.
If the matrix is fresh, you can be sure that both it and its built-in AlgART array are not views of another matrix / array, but are the original objects created by the memory model.
The matrices, created by matrix(Array) and Matrices.matrix(Array, long[])
methods, are never fresh. The matrix, returned by cast(Class) method,
is fresh if and only if the source matrix is fresh.
There is a guarantee that this method works very quickly.
void freeResources()
array().freeResources().
void flushResources()
array().flushResources().
java.lang.String toString()
The result of this method may depend on implementation and usually contains a short description of the built-in AlgART array and all matrix dimensions.
toString in class java.lang.Objectint hashCode()
Array.hashCode() and all matrix dimensions.
hashCode in class java.lang.Objectboolean equals(java.lang.Object obj)
Matrix),dimCount())
and the same corresponding dimensions;array()) are equal (see Array.equals(Object)).
equals in class java.lang.Objectobj - the object to be compared for equality with this matrix.
boolean dimEquals(Matrix<?> m)
dimCount())
and the corresponding dimensions (dim(k)) are equal.
m - the matrix to be compared for equal dimensions with this matrix.
java.lang.NullPointerException - if the passed argument is null.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||