Parallel Colt 0.7.2

cern.colt.matrix.tfloat
Class FloatFactory1D

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.colt.matrix.tfloat.FloatFactory1D
All Implemented Interfaces:
Serializable, Cloneable

public class FloatFactory1D
extends PersistentObject

Factory for convenient construction of 1-d matrices holding float cells. Use idioms like FloatFactory1D.dense.make(1000) to construct dense matrices, FloatFactory1D.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:

  FloatFactory1D F = FloatFactory1D.dense;
  F.make(1000);
  F.descending(10);
  F.random(3);
  ...
 

Version:
1.0, 09/24/99
Author:
wolfgang.hoschek@cern.ch
See Also:
Serialized Form

Field Summary
static FloatFactory1D dense
          A factory producing dense matrices.
static FloatFactory1D sparse
          A factory producing sparse matrices.
 
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
 
Method Summary
 FloatMatrix1D append(FloatMatrix1D A, FloatMatrix1D B)
          C = A||B; Constructs a new matrix which is the concatenation of two other matrices.
 FloatMatrix1D ascending(int size)
          Constructs a matrix with cells having ascending values.
 FloatMatrix1D descending(int size)
          Constructs a matrix with cells having descending values.
 FloatMatrix1D make(AbstractFloatList values)
          Constructs a matrix from the values of the given list.
 FloatMatrix1D make(float[] values)
          Constructs a matrix with the given cell values.
 FloatMatrix1D make(FloatMatrix1D[] parts)
          Constructs a matrix which is the concatenation of all given parts.
 FloatMatrix1D make(int size)
          Constructs a matrix with the given shape, each cell initialized with zero.
 FloatMatrix1D make(int size, float initialValue)
          Constructs a matrix with the given shape, each cell initialized with the given value.
 FloatMatrix1D random(int size)
          Constructs a matrix with uniformly distributed values in (0,1) (exclusive).
 FloatMatrix1D repeat(FloatMatrix1D A, int repeat)
          C = A||A||..||A; Constructs a new matrix which is concatenated repeat times.
 FloatMatrix1D sample(int size, float value, float nonZeroFraction)
          Constructs a randomly sampled matrix with the given shape.
 FloatArrayList toList(FloatMatrix1D values)
          Constructs a list from the given matrix.
 
Methods inherited from class cern.colt.PersistentObject
clone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dense

public static final FloatFactory1D dense
A factory producing dense matrices.


sparse

public static final FloatFactory1D sparse
A factory producing sparse matrices.

Method Detail

append

public FloatMatrix1D append(FloatMatrix1D A,
                            FloatMatrix1D 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 FloatMatrix1D ascending(int size)
Constructs a matrix with cells having ascending values. For debugging purposes. Example: 0 1 2


descending

public FloatMatrix1D descending(int size)
Constructs a matrix with cells having descending values. For debugging purposes. Example: 2 1 0


make

public FloatMatrix1D make(float[] 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 FloatMatrix1D make(FloatMatrix1D[] parts)
Constructs a matrix which is the concatenation of all given parts. Cells are copied.


make

public FloatMatrix1D make(int size)
Constructs a matrix with the given shape, each cell initialized with zero.


make

public FloatMatrix1D make(int size,
                          float initialValue)
Constructs a matrix with the given shape, each cell initialized with the given value.


make

public FloatMatrix1D make(AbstractFloatList 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 FloatMatrix1D random(int size)
Constructs a matrix with uniformly distributed values in (0,1) (exclusive).


repeat

public FloatMatrix1D repeat(FloatMatrix1D 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 FloatMatrix1D sample(int size,
                            float value,
                            float 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:
IllegalArgumentException - if nonZeroFraction < 0 || nonZeroFraction > 1.
See Also:
FloatRandomSampler

toList

public FloatArrayList toList(FloatMatrix1D 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.

Parallel Colt 0.7.2

Jump to the Parallel Colt Homepage