48 from daal.algorithms
import pivoted_qr
49 from daal.data_management
import FileDataSource, DataSourceIface
51 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
52 if utils_folder
not in sys.path:
53 sys.path.insert(0, utils_folder)
54 from utils
import printNumericTable
56 DAAL_PREFIX = os.path.join(
'..',
'data')
59 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'qr.csv')
61 if __name__ ==
"__main__":
64 dataSource = FileDataSource(
66 DataSourceIface.doAllocateNumericTable,
67 DataSourceIface.doDictionaryFromContext
71 dataSource.loadDataBlock()
74 algorithm = pivoted_qr.Batch()
77 algorithm.input.set(pivoted_qr.data, dataSource.getNumericTable())
80 res = algorithm.compute()
83 printNumericTable(res.get(pivoted_qr.matrixQ),
"Orthogonal matrix Q:", 10)
84 printNumericTable(res.get(pivoted_qr.matrixR),
"Triangular matrix R:")
85 printNumericTable(res.get(pivoted_qr.permutationMatrix),
"Permutation matrix P:")