Programming for Computations - Python by Svein Linge & Hans Petter Langtangen

Programming for Computations - Python by Svein Linge & Hans Petter Langtangen

Author:Svein Linge & Hans Petter Langtangen
Language: eng
Format: epub, pdf
ISBN: 9783030168773
Publisher: Springer International Publishing


The code is found in the file integration_​methods_​vec.​py.

Let us test the code interactively in a Python shell by computing . The file with the code above has the name integration_methods_vec.py and is a valid module from which we can import the vectorized function:

Note the necessity to use exp from numpy: our v function will be called with x as an array, and the exp function must be capable of working with an array.

The vectorized code performs all loops very efficiently in compiled code, resulting in much faster execution. Moreover, many readers of the code will also say that the algorithm looks clearer than in the loop-based implementation.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.