Python* API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

uniform_dense_batch.py

1 # file: uniform_dense_batch.py
2 #===============================================================================
3 # Copyright 2014-2020 Intel Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #===============================================================================
17 
18 #
19 # ! Content:
20 # ! Python example of uniform distribution
21 # !
22 # !*****************************************************************************
23 
24 #
25 
26 
27 #
28 
29 import os
30 import sys
31 
32 import daal.algorithms.distributions as distributions
33 import daal.algorithms.distributions.uniform as uniform
34 from daal.algorithms.engines.mt19937 import Batch_Float64DefaultDense_create as create
35 from daal.data_management import HomogenNumericTable, NumericTableIface
36 
37 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
38 if utils_folder not in sys.path:
39  sys.path.insert(0, utils_folder)
40 from utils import printNumericTable
41 
42 if __name__ == "__main__":
43  # Create input table to fill with random numbers
44  dataTable = HomogenNumericTable(1, 10, NumericTableIface.doAllocate)
45 
46  # Create the algorithm
47  uniform = uniform.Batch()
48 
49  # Set the algorithm input
50  uniform.input.set(distributions.tableToFill, dataTable)
51 
52  # Set the Mersenne Twister engine to the distribution
53  uniform.parameter.engine = create(777)
54 
55  # Perform computations
56  uniform.compute()
57 
58  # Print the results
59  printNumericTable(dataTable, "Uniform distribution output:")

For more complete information about compiler optimizations, see our Optimization Notice.