EC Lecture Notes - Lecture 1: Numpy, Main Diagonal
Document Summary
They are available both as operator overloads and as functions in the. Numpy module. import numpy numpy. array is to convert list to array a = numpy. array([1,2,3,4], float) = numpy. array([5,6,7,8], float) print a + b #[ 6. 32. ] print a / b #[ 0. 2 0. 33333333 0. 42857143 0. 5 ] print numpy. divide(a, b) #[ 0. 2 0. 33333333 0. 42857143 0. 5 ] print a % b #[ 1. 4. ] print a**b #[ 1. 00000000e+00 6. 40000000e+01 2. 18700000e+03 6. 55360000e+04] print numpy. power(a, b) #[ 1. 00000000e+00 6. 40000000e+01 2. 18700000e+03 6. 55360000e+04] numpy1. Therefore, it performs a sum over all the dimensions of the input array. Therefore, it performs the product over all the dimensions of the input array. numpy2 numpy3 zeros. The zeros tool returns a new array with a given shape and type filled with "s. import numpy print numpy. zeros((1,2)) #default type is float #output : [[ 0. 0. ]] print numpy. zeros((1,2), dtype = numpy. int) #type changes to int #output : [[0 0]] ones.