package mikera.example;
import mikera.indexz.Index;
import mikera.indexz.Indexz;
import mikera.matrixx.AMatrix;
import mikera.matrixx.Matrixx;
import mikera.matrixx.Matrix;
import mikera.matrixx.impl.SparseRowMatrix;
import mikera.util.Rand;
import mikera.vectorz.AVector;
import mikera.vectorz.impl.RepeatedElementVector;
import mikera.vectorz.impl.SparseIndexedVector;
/**
* Demonstration class showing usage of sparse matrix functionality.
*
* @author Mike
*
*/
public class SparseMatrix {
private static int SIZE=32000; // size of large NxN matrix
private static int DSIZE=100; // dense elements per row in large matrix
private static int CSIZE=200; // dense elements per row for target matrix
private static int SSIZE=2000; // size of smaller NxN matrix
private static long start=0;
private static void printTime(String msg) {
long now=System.currentTimeMillis();
System.out.println(msg+(now-start)+"ms");
startTimer();
}
private static void startTimer() {
start=System.currentTimeMillis();
}
public static void main(String[] args) {
// We want a SparseRowMatrix, because we are going to multiply it with a second dense matrix
// This means that a row-oriented sparse format is better for the first matrix
SparseRowMatrix m=SparseRowMatrix.create(SIZE,SIZE);
// First task is to construct the large sparse matrix
startTimer();
for (int i=0; i
Ads help maintain this website.