public class LibMatrixDatagen extends Object
Modifier and Type | Method and Description |
---|---|
static LongStream |
computeNNZperBlock(long nrow,
long ncol,
int brlen,
int bclen,
double sparsity) |
static RandomMatrixGenerator |
createRandomMatrixGenerator(String pdfStr,
int r,
int c,
int rpb,
int cpb,
double sp,
double min,
double max,
String distParams) |
static void |
generateRandomMatrix(MatrixBlock out,
RandomMatrixGenerator rgen,
LongStream nnzInBlocks,
org.apache.commons.math3.random.Well1024a bigrand,
long bSeed)
Function to generate a matrix of random numbers.
|
static void |
generateRandomMatrix(MatrixBlock out,
RandomMatrixGenerator rgen,
LongStream nnzInBlocks,
org.apache.commons.math3.random.Well1024a bigrand,
long bSeed,
int k)
Function to generate a matrix of random numbers.
|
static void |
generateSample(MatrixBlock out,
long range,
int size,
boolean replace,
long seed)
Generates a sample of size
size from a range of values [1,range]. |
static void |
generateSequence(MatrixBlock out,
double from,
double to,
double incr)
Method to generate a sequence according to the given parameters.
|
static String |
generateUniqueSeedPath(String basedir) |
static boolean |
isShortcutRandOperation(double min,
double max,
double sparsity,
org.apache.sysml.runtime.matrix.data.RandomMatrixGenerator.PDF pdf) |
static org.apache.commons.math3.random.Well1024a |
setupSeedsForRand(long seed)
A matrix of random numbers is generated by using multiple seeds, one for each
block.
|
static double |
updateSeqIncr(double seq_from,
double seq_to,
double seq_incr) |
public static boolean isShortcutRandOperation(double min, double max, double sparsity, org.apache.sysml.runtime.matrix.data.RandomMatrixGenerator.PDF pdf)
public static double updateSeqIncr(double seq_from, double seq_to, double seq_incr)
public static org.apache.commons.math3.random.Well1024a setupSeedsForRand(long seed)
seed
- seed for random generatorpublic static LongStream computeNNZperBlock(long nrow, long ncol, int brlen, int bclen, double sparsity) throws DMLRuntimeException
DMLRuntimeException
public static RandomMatrixGenerator createRandomMatrixGenerator(String pdfStr, int r, int c, int rpb, int cpb, double sp, double min, double max, String distParams) throws DMLRuntimeException
DMLRuntimeException
public static void generateRandomMatrix(MatrixBlock out, RandomMatrixGenerator rgen, LongStream nnzInBlocks, org.apache.commons.math3.random.Well1024a bigrand, long bSeed) throws DMLRuntimeException
bigrand
is passed so that block-level
seeds are generated internally. In case of MR, it generates a single
block for given block-level seed bSeed
.
When pdf="uniform", cell values are drawn from uniform distribution in
range [min,max]
.
When pdf="normal", cell values are drawn from standard normal
distribution N(0,1). The range of generated values will always be
(-Inf,+Inf).out
- output matrix blockrgen
- random matrix generatornnzInBlocks
- number of non-zeros in blocksbigrand
- Well1024a pseudo-random number generatorbSeed
- seed for random generatorDMLRuntimeException
- if DMLRuntimeException occurspublic static void generateRandomMatrix(MatrixBlock out, RandomMatrixGenerator rgen, LongStream nnzInBlocks, org.apache.commons.math3.random.Well1024a bigrand, long bSeed, int k) throws DMLRuntimeException
bigrand
is passed so that block-level
seeds are generated internally. In case of MR, it generates a single
block for given block-level seed bSeed
.
When pdf="uniform", cell values are drawn from uniform distribution in
range [min,max]
.
When pdf="normal", cell values are drawn from standard normal
distribution N(0,1). The range of generated values will always be
(-Inf,+Inf).out
- output matrix blockrgen
- random matrix generatornnzInBlocks
- number of non-zeros in blocksbigrand
- Well1024a pseudo-random number generatorbSeed
- seed for random generatork
- ?DMLRuntimeException
- if DMLRuntimeException occurspublic static void generateSequence(MatrixBlock out, double from, double to, double incr) throws DMLRuntimeException
from
and to
must be
included in the generated sequence i.e., [from,to] both inclusive. Note
that, to
is included only if (to-from) is perfectly
divisible by incr
.
For example, seq(0,1,0.5) generates (0.0 0.5 1.0)
whereas seq(0,1,0.6) generates (0.0 0.6) but not (0.0 0.6 1.0)out
- output matrix blockfrom
- lower end pointto
- upper end pointincr
- increment valueDMLRuntimeException
- if DMLRuntimeException occurspublic static void generateSample(MatrixBlock out, long range, int size, boolean replace, long seed) throws DMLRuntimeException
size
from a range of values [1,range].
replace
defines if sampling is done with or without replacement.out
- output matrix blockrange
- range upper boundsize
- sample sizereplace
- if true, sample with replacementseed
- seed for random generatorDMLRuntimeException
- if DMLRuntimeException occursCopyright © 2017 The Apache Software Foundation. All rights reserved.