Discussion:
[Pyublas] pyublas + lapack problem?
John Edmiston
2009-09-15 05:35:16 UTC
Permalink
Hello,

Thanks very much for your response on my last question. I have come
across another issue which I have been unable to solve based on my
normal essentially clueless method of piecing together things from
online postings.

I want to be able to implement some things from the boost bindings, eg.
lapack functions. But when I have #include <pyublas/numpy.hpp> I
get segmentation faults before entering main().
For example:

lapack_test.cc:



#define PYUBLAS_HAVE_BOOST_BINDINGS

#include <iostream>

#include <pyublas/numpy.hpp>

#include <boost/numeric/ublas/matrix.hpp>

#include <boost/numeric/bindings/traits/ublas_matrix.hpp>

#include <boost/numeric/ublas/io.hpp>

#include <boost/numeric/bindings/lapack/geev.hpp>

#include <complex>



namespace ublas = boost::numeric::ublas;

namespace lapack = boost::numeric::bindings::lapack;



int main() {

int n=3;

ublas::matrix < double, ublas::column_major> A (n,n);

for(unsigned int i=0; i<n; i++){

for(unsigned int j=0; j<n; j++){

A(i,j)=i*j+1;

}

}

ublas::matrix<std::complex<double>, ublas::column_major> Vl(n,n),Vr(n,n);

ublas::vector<std::complex<double> > w(n);

lapack::geev(A, w, &Vl, &Vr, lapack::optimal_workspace());

std::cout<<"Vl "<<Vl<<std::endl;

std::cout<<"Vr "<<Vr<<std::endl;

return 0;

}



I attempt to compile this with

g++ lapack_test.cc -I/usr/apps/python2.6/include/python2.6/ -L/usr/apps/python2.6/lib/ -lpython2.6 -L/g/g23/edmiston/BOOST_INSTALL_LIB/ -lboost_python-gcc41-mt-1_39 -I/usr/apps/python2.6/lib/python2.6/site-packages/numpy/core/include/ -I/g/g23/edmiston/PYUBLAS/lib/python2.6/site-packages/PyUblas-0.93.1-py2.6-linux-x86_64.egg/include -I/g/g23/edmiston/BOOST_NUMERIC_BINDINGS/include/boost-numeric-bindings -L/usr/lib64 -llapack




which compiles, but the executable seg faults. If I leave out the
#include <pyublas/numpy.hpp> it works. It seems to be a problem
with having both that particular include file and the linking to
liblapack.so (just from trying out different combinations to the g++
command ).



I obviously have a very low level understanding of compiling and
linking but have tried my quota of things blindly. Have you come across this problem before? Or is there a
different way suggested to get lapack functions to operate with
pyublas? What is the meaning of life?



Thanks,

John
_________________________________________________________________
Insert movie times and more without leaving Hotmail?.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20090915/f1384d74/attachment.htm>
Andreas Klöckner
2009-09-15 13:43:07 UTC
Permalink
Post by John Edmiston
Hello,
Thanks very much for your response on my last question. I have come
across another issue which I have been unable to solve based on my
normal essentially clueless method of piecing together things from
online postings.
Including pyublas/numpy.hpp in something that isn't a module loaded by Python
doesn't make sense, as it depends on talking to a numpy module being loaded.
In particular, it contains static initializers that initialize a numpy API
pointer (which I assume is causing your crash before main).

HTH,
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20090915/04b699e1/attachment.pgp>
Loading...