package com.intel.daal.examples.pivoted_qr;
import com.intel.daal.algorithms.pivoted_qr.Batch;
import com.intel.daal.algorithms.pivoted_qr.InputId;
import com.intel.daal.algorithms.pivoted_qr.Method;
import com.intel.daal.algorithms.pivoted_qr.Result;
import com.intel.daal.algorithms.pivoted_qr.ResultId;
import com.intel.daal.data_management.data.NumericTable;
import com.intel.daal.data_management.data_source.DataSource;
import com.intel.daal.data_management.data_source.FileDataSource;
import com.intel.daal.examples.utils.Service;
import com.intel.daal.services.DaalContext;
class PivotedQRBatch {
private static final String dataset = "../data/batch/qr.csv";
private static DaalContext context = new DaalContext();
public static void main(String[] args) throws java.io.FileNotFoundException, java.io.IOException {
FileDataSource dataSource = new FileDataSource(context, dataset,
DataSource.DictionaryCreationFlag.DoDictionaryFromContext,
DataSource.NumericTableAllocationFlag.DoAllocateNumericTable);
dataSource.loadDataBlock();
NumericTable input = dataSource.getNumericTable();
Batch pivotedQRAlgorithm = new Batch(context, Double.class, Method.defaultDense);
pivotedQRAlgorithm.input.set(InputId.data, input);
Result res = pivotedQRAlgorithm.compute();
NumericTable matrixQ = res.get(ResultId.matrixQ);
NumericTable matrixR = res.get(ResultId.matrixR);
NumericTable permutationMatrix = res.get(ResultId.permutationMatrix);
printResults(input, matrixQ, matrixR, permutationMatrix);
context.dispose();
}
private static void printResults(NumericTable data, NumericTable Q, NumericTable R, NumericTable P) {
Service.printNumericTable("Input matrix (10 first vectors):", data, 10);
Service.printNumericTable("Orthogonal matrix Q (10 first vectors):", Q, 10);
Service.printNumericTable("Triangular matrix R:", R);
Service.printNumericTable("Permutation matrix P:", P);
}
}