Book Image

Learning SciPy for Numerical and Scientific Computing Second Edition

Book Image

Learning SciPy for Numerical and Scientific Computing Second Edition

Overview of this book

Table of Contents (15 chapters)
Learning SciPy for Numerical and Scientific Computing Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 2. Working with the NumPy Array As a First Step to SciPy

At the top level, SciPy is basically NumPy, since both the object creation and basic manipulation of these objects are performed by functions of the latter library. This assures much faster computations, since the memory handling is done internally in an optimal way. For instance, if an operation must be made on the elements of a big multidimensional array, a novice user might be tempted to go over columns and rows with as many for loops as necessary. Loops run much faster when they access each consecutive element in the same order in which they are stored in memory. We should not be bothered with considerations of this kind when coding. The NumPy/SciPy operations assure that this is the case. As an added advantage, the names of operations in NumPy/SciPy are intuitive and self explanatory. Code written in this fashion is extremely easy to understand and maintain, faster to correct or change in case of need.

Let's illustrate...