47 from daal.algorithms
import pivoted_qr
48 from daal.data_management
import FileDataSource, DataSourceIface
50 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
51 if utils_folder
not in sys.path:
52 sys.path.insert(0, utils_folder)
53 from utils
import printNumericTable
55 DAAL_PREFIX = os.path.join(
'..',
'data')
58 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'qr.csv')
60 if __name__ ==
"__main__":
63 dataSource = FileDataSource(
65 DataSourceIface.doAllocateNumericTable,
66 DataSourceIface.doDictionaryFromContext
70 dataSource.loadDataBlock()
73 algorithm = pivoted_qr.Batch()
76 algorithm.input.set(pivoted_qr.data, dataSource.getNumericTable())
79 res = algorithm.compute()
82 printNumericTable(res.get(pivoted_qr.matrixQ),
"Orthogonal matrix Q:", 10)
83 printNumericTable(res.get(pivoted_qr.matrixR),
"Triangular matrix R:")
84 printNumericTable(res.get(pivoted_qr.permutationMatrix),
"Permutation matrix P:")