[Numpy-tickets] [NumPy] #649: numpy.linalg.lstsq segfaults on i686 32-bit and ia64 linux
NumPy
numpy-tickets@scipy....
Wed Jan 23 20:38:13 CST 2008
#649: numpy.linalg.lstsq segfaults on i686 32-bit and ia64 linux
------------------------+---------------------------------------------------
Reporter: psederberg | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0.5
Component: Other | Version: none
Severity: normal | Keywords:
------------------------+---------------------------------------------------
Howdy Everybody:
I am coding a simple ridge regression with numpy and seem to have
uncovered a bug that exists in numpy.linalg.lstsq, but NOT in
scipy.linalg,lstsq.
Running the following code gives rise to a segfault on 32-bit i686 and
64-bit ia64 linux, but not on a amd64 linux machine:
############ START CODE ##################
import numpy as N
# set dimensions
nsamples = 53
nfeatures = 1000
# create random data
data = N.random.rand(nsamples,nfeatures)
lab = N.random.rand(nsamples)
# run a ridge regression with constant term
Lambda = .05*nfeatures*N.eye(nfeatures)
a = N.concatenate( \
(N.concatenate((data, N.ones((nsamples, 1))), 1),
N.concatenate((Lambda, N.zeros((nfeatures, 1))), 1)))
b = N.concatenate((lab, N.zeros(nfeatures)))
w = N.linalg.lstsq(a,b)[0] # here is the segfault
################ END CODE ####################
All machines were tested with Debian testing and numpy version 1.0.4.
I've attached the results of running valgrind on the above code.
It should also be added that replacing the numpy lstsq with the
scipy.linalg.lstsq prevents the segfault and gives rise to the correct
result.
Thanks,
Per
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/649>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list