Skip to Main Content
Cython
book

Cython

by Kurt W. Smith
January 2015
Intermediate to advanced content levelIntermediate to advanced
254 pages
6h 17m
English
O'Reilly Media, Inc.
Content preview from Cython

Chapter 11. Cython in Practice: Spectral Norm

The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.

E. Dijkstra

Like Chapter 4, this chapter’s intent is to reiterate concepts and techniques to show Cython’s use in context. Here we focus on using typed memoryviews to compute the spectral norm of a particular matrix. This is another example from the computer language benchmarks game, allowing us to compare the Cython solution’s performance to other highly optimized implementations in different languages. The focus here is how to use typed memoryviews to achieve much better performance with array-heavy operations. That said, we will first cover what the spectral norm is and explore a pure-Python version before using Cython to speed it up.

Overview of the Spectral Norm Python Code

The spectral norm of a matrix is defined to be the largest singular value of ; that is, the square root of the largest eigenvalue of the matrix , where is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Cython

Learning Cython

Caleb Hattingh
High Performance Python, 2nd Edition

High Performance Python, 2nd Edition

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9781491901731Errata PageSupplemental Content