arrays.txt
changeset 61 38ef280b1408
parent 56 86c862b3dbef
child 67 806cca3b7231
equal deleted inserted replaced
56:86c862b3dbef 61:38ef280b1408
     1 Hello and welcome to the tutorial on Matrices.
     1 Hello and welcome to the tutorial on Matrices.
     2 All matrices operations are done using arrays.
     2 All matrices operations are done using arrays.
     3 We have already seen in previous session that how arrays are better suited for particular mathematical operations. In this session we are going to cover more details on Arrays, how to create/initialize them, how to manipulate and use them for solving given problem.
     3 We have already seen in previous session that how arrays are better suited for particular mathematical operations. In this session we are going to cover more details on Arrays(matrices), how to create/initialize them, how to manipulate and use them for solving given problem.
     4 
     4 
     5 First thing first, we start with creating a normal array by:
     5 First thing first, we start with creating a normal array by:
     6 a (equal to)= array([5, 8, 10, 13])
     6 a (equal to)= array([5, 8, 10, 13])
     7 
     7 
     8 and we have a as array. we can cross the content by
     8 and we have a as array, check the value by
     9 a
     9 a
    10 
    10 
    11 Here a is single dimension array, that is it has only one row. We can create multi-dimensional arrays by
    11 Here a is single dimension array, that is it has only one row. We can create multi-dimensional arrays by
    12 
    12 
    13 c = array([[11,12,13], [21,22,23], [31,32,33]])
    13 c = array([[11,12,13], [21,22,23], [31,32,33]])
    16 we can check shape of arrays by using shape attribute of arrays.
    16 we can check shape of arrays by using shape attribute of arrays.
    17 a.shape
    17 a.shape
    18 c.shape
    18 c.shape
    19 
    19 
    20 some other handy array initialization methods are also available to make life easier.
    20 some other handy array initialization methods are also available to make life easier.
    21 say we want to create a array of size 3x4 with all values initialized to be 1, we can use
    21 say we want to create an array of size 3x4 with all the values initialized to be 1, we can use
    22 b = ones((3, 4))
    22 b = ones((3, 4))
    23 check value by
    23 and b will be
    24 b
    24 b
    25 similarly, we already have a array, and we want to create one more array with same shape and initial values to be one, for that we will use
    25 similarly, if we already have an array, and we want to create one more array with the same shape and initial values to be one, for that we will use
    26 d = ones_like(c)
    26 d = ones_like(c)
    27 and d will be 3x3 array with all values 1
    27 and d will be 3x3 array with all values 1
    28 
    28 
    29 Similarly there are functions like zeros and zeros_like which initialize array with all values being 0. One more useful function available is 'identity', it create identity matrix(array) of given order
    29 Similarly there are functions like zeros and zeros_like which initialize array with all values being 0. One more useful function available is 'identity', it create identity matrix(array) of given order
    30 i = identity(3)
    30 i = identity(3)
   166 Initialization
   166 Initialization
   167 Slicing
   167 Slicing
   168 Striding
   168 Striding
   169 A bit of image processing
   169 A bit of image processing
   170 Functions available for arrays
   170 Functions available for arrays
       
   171 
   171 Thank you
   172 Thank you
   172 
   173 
   173 ----------------
   174 ----------------
   174 We have seen 
   175 We have seen 
   175     Welcome to the Tutorial on arrays. 
   176     Welcome to the Tutorial on arrays.