Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Numpy Beginner's Guide (Update)
  • Toc
  • feedback
Numpy Beginner's Guide (Update)

Numpy Beginner's Guide (Update)

By : Ivan Idris
2 (1)
close
Numpy Beginner's Guide (Update)

Numpy Beginner's Guide (Update)

2 (1)
By: Ivan Idris

Overview of this book

This book is for the scientists, engineers, programmers, or analysts looking for a high-quality, open source mathematical library. Knowledge of Python is assumed. Also, some affinity, or at least interest, in mathematics and statistics is required. However, I have provided brief explanations and pointers to learning resources.
Table of Contents (16 chapters)
close
14
C. NumPy Functions' References
15
Index

Time for action – creating matrices

The mat() function does not make a copy if the input is already a matrix or an ndarray. Calling this function is equivalent to calling matrix(data, copy=False). We will also demonstrate transposing and inverting matrices.

  1. Rows are delimited by a semicolon and values by a space. Call the mat() function with the following string to create a matrix:
    A = np.mat('1 2 3; 4 5 6; 7 8 9')
    print("Creation from string", A)

    The matrix output should be the following matrix:

    Creation from string [[1 2 3]
     [4 5 6]
     [7 8 9]]
    
  2. Transpose the matrix with the T attribute as follows:
    print("transpose A", A.T)

    The following is the transposed matrix:

    transpose A [[1 4 7]
     [2 5 8]
     [3 6 9]]
    
  3. The matrix can be inverted with the I attribute as follows (see https://www.khanacademy.org/math/precalculus/precalc-matrices/inverting_matrices/v/inverse-matrix-part-1):
    print("Inverse A", A.I)

    The inverse matrix is printed as follows (be warned that...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete