Make constructor private and class final
Suppress warnings on unchecked cast and documented expected usage of the object array.
This commit is contained in:
parent
83d9e3ab39
commit
fed7dd881b
|
@ -29,7 +29,7 @@ import org.apache.commons.math4.legacy.linear.AnyMatrix;
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class FieldDenseMatrix<T>
|
public final class FieldDenseMatrix<T>
|
||||||
implements AnyMatrix {
|
implements AnyMatrix {
|
||||||
/** Field. */
|
/** Field. */
|
||||||
private final Field<T> field;
|
private final Field<T> field;
|
||||||
|
@ -37,7 +37,13 @@ public class FieldDenseMatrix<T>
|
||||||
private final int rows;
|
private final int rows;
|
||||||
/** Number of columns. */
|
/** Number of columns. */
|
||||||
private final int columns;
|
private final int columns;
|
||||||
/** Data storage (in row-major order). */
|
/**
|
||||||
|
* Data storage (in row-major order).
|
||||||
|
*
|
||||||
|
* <p>Note: This is an Object[] that has been cast to T[] for convenience. It should not be
|
||||||
|
* exposed to avoid heap pollution. It is expected all entries stored in the array are
|
||||||
|
* instances of T.
|
||||||
|
*/
|
||||||
private final T[] data;
|
private final T[] data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,9 +52,10 @@ public class FieldDenseMatrix<T>
|
||||||
* @param c Number of columns.
|
* @param c Number of columns.
|
||||||
* @throws IllegalArgumentException if {@code r <= 0} or {@code c <= 0}.
|
* @throws IllegalArgumentException if {@code r <= 0} or {@code c <= 0}.
|
||||||
*/
|
*/
|
||||||
protected FieldDenseMatrix(Field<T> f,
|
@SuppressWarnings("unchecked")
|
||||||
int r,
|
private FieldDenseMatrix(Field<T> f,
|
||||||
int c) {
|
int r,
|
||||||
|
int c) {
|
||||||
if (r <= 0 ||
|
if (r <= 0 ||
|
||||||
c <= 0) {
|
c <= 0) {
|
||||||
throw new IllegalArgumentException("Negative size");
|
throw new IllegalArgumentException("Negative size");
|
||||||
|
|
Loading…
Reference in New Issue