@Override public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) { DenseMatrix matA = inputs[0].getOriginal(); no.uib.cipr.matrix.QR qr = new no.uib.cipr.matrix.QR(matA.numRows(),matA.numColumns()); DenseMatrix tmp = new DenseMatrix(matA); DenseMatrix Q = null; UpperTriangDenseMatrix R = null; long prev = System.nanoTime(); for( long i = 0; i < numTrials; i++ ) { // the input matrix is over written tmp.set(matA); qr.factor(tmp); Q = qr.getQ(); R = qr.getR(); } long elapsedTime = System.nanoTime()-prev; if( outputs != null ) { outputs[0] = new MtjBenchmarkMatrix(Q); outputs[1] = new MtjBenchmarkMatrix(R); } return elapsedTime; } }
public Matrix[] qr() { if (getRowCount() >= getColumnCount()) { try { QR qr = QR.factorize(getWrappedObject()); Matrix q = new MTJDenseDoubleMatrix2D(qr.getQ()); Matrix r = new MTJDenseDoubleMatrix2D(qr.getR()); return new Matrix[] { q, r }; } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("only allowed for matrices m>=n"); } }
public Matrix[] qr() { if (getRowCount() >= getColumnCount()) { try { QR qr = QR.factorize(getWrappedObject()); Matrix q = new MTJDenseDoubleMatrix2D(qr.getQ()); Matrix r = new MTJDenseDoubleMatrix2D(qr.getR()); return new Matrix[] { q, r }; } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("only allowed for matrices m>=n"); } }