Created
March 15, 2014 15:35
-
-
Save anonymous/9569105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import org.ejml.simple.SimpleMatrix; | |
public class EJMLTest { | |
private static SimpleMatrix getRandomMatrix(int rowCount, int columnCount) { | |
Random random = new Random(); | |
int cellValueLimit = 9; | |
SimpleMatrix matrix = new SimpleMatrix(rowCount, rowCount); | |
for (int r = 0; r < rowCount; r++) { | |
for (int c = 0; c < columnCount; c++) { | |
matrix.set(r, c, random.nextInt(cellValueLimit)); | |
} | |
} | |
return matrix; | |
} | |
public static void main(String[] args) { | |
int rows = 300; | |
int cols = rows; | |
SimpleMatrix matrix1 = getRandomMatrix(rows, cols); | |
SimpleMatrix matrix2 = getRandomMatrix(rows, cols); | |
long computationStartTime = System.currentTimeMillis(); | |
SimpleMatrix multipliedMatrix = matrix1.mult(matrix2); | |
long computationEndTime = System.currentTimeMillis(); | |
System.out.println(new StringBuilder("Multiplication took ").append(computationEndTime - computationStartTime).append(" ms")); | |
System.out.println(multipliedMatrix.determinant()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment