cern.colt.matrix.tint
Class IntFactory1D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.tint.IntFactory1D
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class IntFactory1D extends PersistentObject
Factory for convenient construction of 1-d matrices holding int cells. Use idioms like IntFactory1D.dense.make(1000) to construct dense matrices, IntFactory1D.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:IntFactory1D F = IntFactory1D.dense; F.make(1000); F.descending(10); F.random(3); ...
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static IntFactory1DdenseA factory producing dense matrices.static IntFactory1DsparseA factory producing sparse matrices.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description IntMatrix1Dappend(IntMatrix1D A, IntMatrix1D B)C = A||B; Constructs a new matrix which is the concatenation of two other matrices.IntMatrix1Dascending(int size)Constructs a matrix with cells having ascending values.IntMatrix1Ddescending(int size)Constructs a matrix with cells having descending values.IntMatrix1Dmake(AbstractIntList values)Constructs a matrix from the values of the given list.IntMatrix1Dmake(int size)Constructs a matrix with the given shape, each cell initialized with zero.IntMatrix1Dmake(int[] values)Constructs a matrix with the given cell values.IntMatrix1Dmake(int size, int initialValue)Constructs a matrix with the given shape, each cell initialized with the given value.IntMatrix1Dmake(IntMatrix1D[] parts)Constructs a matrix which is the concatenation of all given parts.IntMatrix1Drandom(int size)Constructs a matrix with uniformly distributed values in (0,1) (exclusive).IntMatrix1Drepeat(IntMatrix1D A, int repeat)C = A||A||..||A; Constructs a new matrix which is concatenated repeat times.IntMatrix1Dsample(int size, int value, int nonZeroFraction)Constructs a randomly sampled matrix with the given shape.IntArrayListtoList(IntMatrix1D values)Constructs a list from the given matrix.-
Methods inherited from class cern.colt.PersistentObject
clone
-
-
-
-
Field Detail
-
dense
public static final IntFactory1D dense
A factory producing dense matrices.
-
sparse
public static final IntFactory1D sparse
A factory producing sparse matrices.
-
-
Method Detail
-
append
public IntMatrix1D append(IntMatrix1D A, IntMatrix1D B)
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
public IntMatrix1D ascending(int size)
Constructs a matrix with cells having ascending values. For debugging purposes. Example: 0 1 2
-
descending
public IntMatrix1D descending(int size)
Constructs a matrix with cells having descending values. For debugging purposes. Example: 2 1 0
-
make
public IntMatrix1D make(int[] values)
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
public IntMatrix1D make(IntMatrix1D[] parts)
Constructs a matrix which is the concatenation of all given parts. Cells are copied.
-
make
public IntMatrix1D make(int size)
Constructs a matrix with the given shape, each cell initialized with zero.
-
make
public IntMatrix1D make(int size, int initialValue)
Constructs a matrix with the given shape, each cell initialized with the given value.
-
make
public IntMatrix1D make(AbstractIntList values)
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
public IntMatrix1D random(int size)
Constructs a matrix with uniformly distributed values in (0,1) (exclusive).
-
repeat
public IntMatrix1D repeat(IntMatrix1D A, int 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
public IntMatrix1D sample(int size, int value, int nonZeroFraction)
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:
java.lang.IllegalArgumentException- if nonZeroFraction < 0 || nonZeroFraction > 1.- See Also:
DoubleRandomSamplingAssistant
-
toList
public IntArrayList toList(IntMatrix1D values)
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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG