24 from daal.algorithms
import pivoted_qr
25 from daal.data_management
import FileDataSource, DataSourceIface
27 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
28 if utils_folder
not in sys.path:
29 sys.path.insert(0, utils_folder)
30 from utils
import printNumericTable
32 DAAL_PREFIX = os.path.join(
'..',
'data')
35 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'qr.csv')
37 if __name__ ==
"__main__":
40 dataSource = FileDataSource(
42 DataSourceIface.doAllocateNumericTable,
43 DataSourceIface.doDictionaryFromContext
47 dataSource.loadDataBlock()
50 algorithm = pivoted_qr.Batch()
53 algorithm.input.set(pivoted_qr.data, dataSource.getNumericTable())
56 res = algorithm.compute()
59 printNumericTable(res.get(pivoted_qr.matrixQ),
"Orthogonal matrix Q:", 10)
60 printNumericTable(res.get(pivoted_qr.matrixR),
"Triangular matrix R:")
61 printNumericTable(res.get(pivoted_qr.permutationMatrix),
"Permutation matrix P:")