Skip to content

Instantly share code, notes, and snippets.

@osdf
Forked from bayerj/gist:2397894
Created April 16, 2012 11:35
Show Gist options
  • Save osdf/2397975 to your computer and use it in GitHub Desktop.
Save osdf/2397975 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
import numpy
import time
import scipy.linalg as linalg
try:
import numpy.core._dotblas
print 'Using ATLAS:'
except ImportError:
print 'No ATLAS:'
print numpy.__version__
N = 10
x = numpy.random.random((1000,1000))
y = numpy.random.random((1000,1000))
t = time.time()
for i in range(N):
numpy.dot(x, y)
u = time.time()
print 'dot', (u-t) / N
z = numpy.dot(x, x.T) + 2*numpy.eye(1000)
t = time.time()
for i in range(N):
c = linalg.svd(z)
u = time.time()
print 'svd', (u - t) / N
t = time.time()
for i in range(N):
c = linalg.cholesky(z, lower=True)
u = time.time()
print 'cholesky', (u - t) / N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment