Deprecation Notice: With the introduction of daal4py, a package that supersedes PyDAAL, Intel is deprecating PyDAAL and will discontinue support starting with Intel® DAAL 2021 and Intel® Distribution for Python 2021. Until then Intel will continue to provide compatible pyDAAL pip and conda packages for newer releases of Intel DAAL and make it available in open source. However, Intel will not add the new features of Intel DAAL to pyDAAL. Intel recommends developers switch to and use daal4py.
Note: To find daal4py examples, refer to daal4py documentation or browse github repository.
25 from __future__
import print_function
32 from daal.data_management
import PackedTriangularMatrix, NumericTableIface, BlockDescriptor, readOnly, readWrite
34 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
35 if utils_folder
not in sys.path:
36 sys.path.insert(0, utils_folder)
37 from utils
import printArray
40 if __name__ ==
"__main__":
42 print(
"Packed triangular matrix example")
50 data = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4], dtype=np.float64)
52 dataTable = PackedTriangularMatrix(NumericTableIface.lowerPackedTriangularMatrix, data)
54 block = BlockDescriptor()
57 dataTable.getBlockOfRows(firstReadRow, nRead, readOnly, block)
58 print(
"{} rows are read".format(block.getNumberOfRows()))
60 printArray(block.getArray(), nDim, block.getNumberOfRows(), block.getNumberOfColumns(),
61 "Print 3 rows from packed triangular matrix as float:")
65 dataTable.getBlockOfColumnValues(readFeatureIdx, firstReadRow, nDim, readWrite, block)
66 printArray(block.getArray(), 1, block.getNumberOfRows(), block.getNumberOfColumns(),
67 "Print the third feature of packed triangular matrix:")
70 dataBlock = block.getArray()
71 dataBlock[readFeatureIdx - 1] = -1
72 dataBlock[readFeatureIdx + 1] = -2
73 dataTable.releaseBlockOfColumnValues(block)
76 dataTable.getBlockOfRows(firstReadRow, nRead, readOnly, block)
77 print(
"{} rows are read".format(block.getNumberOfRows()))
78 printArray(block.getArray(), nDim, block.getNumberOfRows(), block.getNumberOfColumns(),
79 "Print 3 rows from packed triangular matrix as float:")