org.apache.mahout.math
Class Matrices

java.lang.Object
  extended by org.apache.mahout.math.Matrices

public final class Matrices
extends Object

Author:
dmitriy

Constructor Summary
Matrices()
           
 
Method Summary
static Matrix functionalMatrixView(int rows, int columns, IntIntFunction gf)
          Shorter form of functionalMatrixView(int, int, org.apache.mahout.math.function.IntIntFunction, boolean).
static Matrix functionalMatrixView(int rows, int columns, IntIntFunction gf, boolean denseLike)
          Create a matrix view based on a function generator.
static IntIntFunction gaussianGenerator(long seed)
          Generator for a matrix populated by random Gauissian values (Gaussian matrix view)
static Matrix gaussianView(int rows, int columns, long seed)
          Random Gaussian matrix view.
static Matrix symmetricUniformView(int rows, int columns, int seed)
          Matrix view based on uniform [-1,1) distribution.
static Matrix transposedView(Matrix m)
          A read-only transposed view of a matrix argument.
static IntIntFunction uniformGenerator(int seed)
          Uniform [0,1) matrix generator function
static IntIntFunction uniformSymmetricGenerator(int seed)
          Uniform [-1,1) matrix generator function.
static Matrix uniformView(int rows, int columns, int seed)
          Matrix view based on uniform [0,1) distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Matrices

public Matrices()
Method Detail

functionalMatrixView

public static final Matrix functionalMatrixView(int rows,
                                                int columns,
                                                IntIntFunction gf,
                                                boolean denseLike)
Create a matrix view based on a function generator.

The generator needs to be idempotent, i.e. returning same value for each combination of (row, column) argument sent to generator's IntIntFunction.apply(int, int) call.

Parameters:
rows - Number of rows in a view
columns - Number of columns in a view.
gf - view generator
denseLike - type of matrix returne dby Matrix.like().
Returns:
new matrix view.

functionalMatrixView

public static final Matrix functionalMatrixView(int rows,
                                                int columns,
                                                IntIntFunction gf)
Shorter form of functionalMatrixView(int, int, org.apache.mahout.math.function.IntIntFunction, boolean).


transposedView

public static final Matrix transposedView(Matrix m)
A read-only transposed view of a matrix argument.

Parameters:
m - original matrix
Returns:
transposed view of original matrix

gaussianView

public static final Matrix gaussianView(int rows,
                                        int columns,
                                        long seed)
Random Gaussian matrix view.

Parameters:
seed - generator seed

symmetricUniformView

public static final Matrix symmetricUniformView(int rows,
                                                int columns,
                                                int seed)
Matrix view based on uniform [-1,1) distribution.

Parameters:
seed - generator seed

uniformView

public static final Matrix uniformView(int rows,
                                       int columns,
                                       int seed)
Matrix view based on uniform [0,1) distribution.

Parameters:
seed - generator seed

gaussianGenerator

public static final IntIntFunction gaussianGenerator(long seed)
Generator for a matrix populated by random Gauissian values (Gaussian matrix view)

Parameters:
seed - The seed for the matrix.
Returns:
Gaussian IntIntFunction generating matrix view with normal values

uniformSymmetricGenerator

public static final IntIntFunction uniformSymmetricGenerator(int seed)
Uniform [-1,1) matrix generator function.

WARNING: to keep things performant, it is stateful and so not thread-safe. You'd need to create a copy per thread (with same seed) if shared between threads.

Parameters:
seed -
Returns:
Uniform IntIntFunction generator

uniformGenerator

public static final IntIntFunction uniformGenerator(int seed)
Uniform [0,1) matrix generator function

Parameters:
seed - generator seed


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.