22 from daal.algorithms
import pivoted_qr
23 from daal.data_management
import FileDataSource, DataSourceIface
25 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
26 if utils_folder
not in sys.path:
27 sys.path.insert(0, utils_folder)
28 from utils
import printNumericTable
30 DAAL_PREFIX = os.path.join(
'..',
'data')
33 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'qr.csv')
35 if __name__ ==
"__main__":
38 dataSource = FileDataSource(
40 DataSourceIface.doAllocateNumericTable,
41 DataSourceIface.doDictionaryFromContext
45 dataSource.loadDataBlock()
48 algorithm = pivoted_qr.Batch()
51 algorithm.input.set(pivoted_qr.data, dataSource.getNumericTable())
54 res = algorithm.compute()
57 printNumericTable(res.get(pivoted_qr.matrixQ),
"Orthogonal matrix Q:", 10)
58 printNumericTable(res.get(pivoted_qr.matrixR),
"Triangular matrix R:")
59 printNumericTable(res.get(pivoted_qr.permutationMatrix),
"Permutation matrix P:")