Package cern.colt.matrix
Class DoubleFactory1D
java.lang.Object
cern.colt.PersistentObject
cern.colt.matrix.DoubleFactory1D
- All Implemented Interfaces:
Serializable
,Cloneable
Factory for convenient construction of 1-d matrices holding double cells.
Use idioms like DoubleFactory1D.dense.make(1000) to construct dense matrices,
DoubleFactory1D.sparse.make(1000) to construct sparse matrices.
If the factory is used frequently it might be useful to streamline the notation.
For example by aliasing:
DoubleFactory1D F = DoubleFactory1D.dense; F.make(1000); F.descending(10); F.random(3); ... |
- Version:
- 1.0, 09/24/99
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DoubleFactory1D
A factory producing dense matrices.static final DoubleFactory1D
A factory producing sparse matrices.Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Makes this class non instantiable, but still let's others inherit from it. -
Method Summary
Modifier and TypeMethodDescriptionC = A||B; Constructs a new matrix which is the concatenation of two other matrices.ascending
(int size) Constructs a matrix with cells having ascending values.descending
(int size) Constructs a matrix with cells having descending values.make
(double[] values) Constructs a matrix with the given cell values.make
(int size) Constructs a matrix with the given shape, each cell initialized with zero.make
(int size, double initialValue) Constructs a matrix with the given shape, each cell initialized with the given value.make
(AbstractDoubleList values) Constructs a matrix from the values of the given list.make
(DoubleMatrix1D[] parts) Constructs a matrix which is the concatenation of all given parts.random
(int size) Constructs a matrix with uniformly distributed values in (0,1) (exclusive).repeat
(DoubleMatrix1D A, int repeat) C = A||A||..||A; Constructs a new matrix which is concatenated repeat times.sample
(int size, double value, double nonZeroFraction) Constructs a randomly sampled matrix with the given shape.toList
(DoubleMatrix1D values) Constructs a list from the given matrix.Methods inherited from class cern.colt.PersistentObject
clone
-
Field Details
-
dense
A factory producing dense matrices. -
sparse
A factory producing sparse matrices.
-
-
Constructor Details
-
DoubleFactory1D
protected DoubleFactory1D()Makes this class non instantiable, but still let's others inherit from it.
-
-
Method Details
-
append
C = A||B; Constructs a new matrix which is the concatenation of two other matrices. Example: 0 1 append 3 4 --> 0 1 3 4. -
ascending
Constructs a matrix with cells having ascending values. For debugging purposes. Example: 0 1 2 -
descending
Constructs a matrix with cells having descending values. For debugging purposes. Example: 2 1 0 -
make
Constructs a matrix with the given cell values. The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.- Parameters:
values
- The values to be filled into the new matrix.
-
make
Constructs a matrix which is the concatenation of all given parts. Cells are copied. -
make
Constructs a matrix with the given shape, each cell initialized with zero. -
make
Constructs a matrix with the given shape, each cell initialized with the given value. -
make
Constructs a matrix from the values of the given list. The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.- Parameters:
values
- The values to be filled into the new matrix.- Returns:
- a new matrix.
-
random
Constructs a matrix with uniformly distributed values in (0,1) (exclusive). -
repeat
C = A||A||..||A; Constructs a new matrix which is concatenated repeat times. Example:0 1 repeat(3) --> 0 1 0 1 0 1
-
sample
Constructs a randomly sampled matrix with the given shape. Randomly picks exactly Math.round(size*nonZeroFraction) cells and initializes them to value, all the rest will be initialized to zero. Note that this is not the same as setting each cell with probability nonZeroFraction to value.- Throws:
IllegalArgumentException
- if nonZeroFraction invalid input: '<' 0 || nonZeroFraction > 1.- See Also:
-
toList
Constructs a list from the given matrix. The values are copied. So subsequent changes in values are not reflected in the list, and vice-versa.- Parameters:
values
- The values to be filled into the new list.- Returns:
- a new list.
-