/** * <p> * Sets each element in the matrix to a value drawn from an uniform distribution from 0 to 1 inclusive. * </p> * * @param mat The matrix who is to be randomized. Modified. * @param rand Random number generator used to fill the matrix. */ public static void setRandom( DenseMatrix64F mat , Random rand ) { setRandom(mat,0,1,rand); }
/** * <p> * Sets each element in the matrix to a value drawn from an uniform distribution from 0 to 1 inclusive. * </p> * * @param mat The matrix who is to be randomized. Modified. * @param rand Random number generator used to fill the matrix. */ public static void setRandom( DenseMatrix64F mat , Random rand ) { setRandom(mat,0,1,rand); }
/** * <p> * Sets each element in the matrix to a value drawn from an uniform distribution from 0 to 1 inclusive. * </p> * * @param mat The matrix who is to be randomized. Modified. * @param rand Random number generator used to fill the matrix. */ public static void setRandom( DenseMatrix64F mat , Random rand ) { setRandom(mat,0,1,rand); }
public static BlockMatrix64F createRandom( int numRows , int numCols , double min , double max , Random rand , int blockLength ) { BlockMatrix64F ret = new BlockMatrix64F(numRows,numCols,blockLength); RandomMatrices.setRandom(ret,min,max,rand); return ret; }
public static BlockMatrix64F createRandom( int numRows , int numCols , double min , double max , Random rand , int blockLength ) { BlockMatrix64F ret = new BlockMatrix64F(numRows,numCols,blockLength); RandomMatrices.setRandom(ret,min,max,rand); return ret; }
public static BlockMatrix64F createRandom( int numRows , int numCols , double min , double max , Random rand ) { BlockMatrix64F ret = new BlockMatrix64F(numRows,numCols); RandomMatrices.setRandom(ret,min,max,rand); return ret; }
public static BlockMatrix64F createRandom( int numRows , int numCols , double min , double max , Random rand ) { BlockMatrix64F ret = new BlockMatrix64F(numRows,numCols); RandomMatrices.setRandom(ret,min,max,rand); return ret; }
public static BlockMatrix64F createRandom( int numRows , int numCols , double min , double max , Random rand ) { BlockMatrix64F ret = new BlockMatrix64F(numRows,numCols); RandomMatrices.setRandom(ret,min,max,rand); return ret; }
public static BlockMatrix64F createRandom( int numRows , int numCols , double min , double max , Random rand , int blockLength ) { BlockMatrix64F ret = new BlockMatrix64F(numRows,numCols,blockLength); RandomMatrices.setRandom(ret,min,max,rand); return ret; }
/** * Returns a matrix where all the elements are selected independently from * a uniform distribution between 0 and 1 inclusive. * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static DenseMatrix64F createRandom( int numRow , int numCol , Random rand ) { DenseMatrix64F mat = new DenseMatrix64F(numRow,numCol); setRandom(mat,0,1,rand); return mat; }
/** * Returns a matrix where all the elements are selected independently from * a uniform distribution between 0 and 1 inclusive. * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static DenseMatrix64F createRandom( int numRow , int numCol , Random rand ) { DenseMatrix64F mat = new DenseMatrix64F(numRow,numCol); setRandom(mat, 0, 1, rand); return mat; }
/** * Returns a matrix where all the elements are selected independently from * a uniform distribution between 0 and 1 inclusive. * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static DenseMatrix64F createRandom( int numRow , int numCol , Random rand ) { DenseMatrix64F mat = new DenseMatrix64F(numRow,numCol); setRandom(mat,0,1,rand); return mat; }
/** * <p> * Returns a matrix where all the elements are selected independently from * a uniform distribution between 'min' and 'max' inclusive. * </p> * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param min The minimum value each element can be. * @param max The maximum value each element can be. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static DenseMatrix64F createRandom( int numRow , int numCol , double min , double max , Random rand ) { DenseMatrix64F mat = new DenseMatrix64F(numRow,numCol); setRandom(mat,min,max,rand); return mat; }
/** * <p> * Returns a matrix where all the elements are selected independently from * a uniform distribution between 'min' and 'max' inclusive. * </p> * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param min The minimum value each element can be. * @param max The maximum value each element can be. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static DenseMatrix64F createRandom( int numRow , int numCol , double min , double max , Random rand ) { DenseMatrix64F mat = new DenseMatrix64F(numRow,numCol); setRandom(mat,min,max,rand); return mat; }
/** * <p> * Creates a new SimpleMatrix with random elements drawn from a uniform distribution from minValue to maxValue. * </p> * * @see org.ejml.ops.RandomMatrices#setRandom(DenseMatrix64F,java.util.Random) * * @param numRows The number of rows in the new matrix * @param numCols The number of columns in the new matrix * @param minValue Lower bound * @param maxValue Upper bound * @param rand The random number generator that's used to fill the matrix. @return The new random matrix. */ public static SimpleMatrix random(int numRows, int numCols, double minValue, double maxValue, Random rand) { SimpleMatrix ret = new SimpleMatrix(numRows,numCols); RandomMatrices.setRandom(ret.mat,minValue,maxValue,rand); return ret; }
/** * <p> * Creates a new SimpleMatrix with random elements drawn from a uniform distribution from minValue to maxValue. * </p> * * @see org.ejml.ops.RandomMatrices#setRandom(DenseMatrix64F,java.util.Random) * * @param numRows The number of rows in the new matrix * @param numCols The number of columns in the new matrix * @param minValue Lower bound * @param maxValue Upper bound * @param rand The random number generator that's used to fill the matrix. @return The new random matrix. */ public static SimpleMatrix random(int numRows, int numCols, double minValue, double maxValue, Random rand) { SimpleMatrix ret = new SimpleMatrix(numRows,numCols); RandomMatrices.setRandom(ret.mat,minValue,maxValue,rand); return ret; }
/** * <p> * Returns a matrix where all the elements are selected independently from * a uniform distribution between 'min' and 'max' inclusive. * </p> * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param min The minimum value each element can be. * @param max The maximum value each element can be. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static DenseMatrix64F createRandom( int numRow , int numCol , double min , double max , Random rand ) { DenseMatrix64F mat = new DenseMatrix64F(numRow,numCol); setRandom(mat,min,max,rand); return mat; }
public static void setRandomVelocities(InverseDynamicsJoint[] joints, Random random) { for (InverseDynamicsJoint joint : joints) { DenseMatrix64F jointVelocity = new DenseMatrix64F(joint.getDegreesOfFreedom(), 1); RandomMatrices.setRandom(jointVelocity, random); joint.setVelocity(jointVelocity, 0); } }
@ContinuousIntegrationTest(estimatedDuration = 0.3) @Test(timeout=300000) public void testBackAndForthMatrix() { List<List<YoDouble>> yoArray = new ArrayList<List<YoDouble>>(); int nRows = 50; int nColumns = 60; String prefix = "test"; YoVariableRegistry registry = new YoVariableRegistry("test"); DenseMatrix64F matrix = new DenseMatrix64F(nRows, nColumns); Random random = new Random(1235612L); RandomMatrices.setRandom(matrix, random); DenseMatrix64F matrixBack = new DenseMatrix64F(nRows, nColumns); MatrixYoVariableConversionTools.populateYoVariablesMatrix(yoArray, nRows, nColumns, prefix, registry); MatrixYoVariableConversionTools.storeInYoVariablesMatrix(matrix, yoArray); MatrixYoVariableConversionTools.getFromYoVariablesMatrix(matrixBack, yoArray); EjmlUnitTests.assertEquals(matrix, matrixBack, 1e-12); }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout=300000) public void testBackAndForthVector() { List<YoDouble> yoArray = new ArrayList<YoDouble>(); int size = 50; String prefix = "test"; YoVariableRegistry registry = new YoVariableRegistry("test"); DenseMatrix64F matrix = new DenseMatrix64F(size, 1); Random random = new Random(1235612L); RandomMatrices.setRandom(matrix, random); DenseMatrix64F matrixBack = new DenseMatrix64F(size, 1); MatrixYoVariableConversionTools.populateYoVariablesVector(yoArray, size, prefix, registry); MatrixYoVariableConversionTools.storeInYoVariablesVector(matrix, yoArray); MatrixYoVariableConversionTools.getFromYoVariablesVector(matrixBack, yoArray); EjmlUnitTests.assertEquals(matrix, matrixBack, 1e-12); }