Dear Stephan,

     I answer in English so that this information can be useful for non 
german speaking users ..

Mapping a pygsl array to gsl_matrix is not that difficult but one has to 
take some subtle
differences into account:

-- numpy counts strides in byte offsets
-- gsl counts strides in offsets of the basic type

-- gsl vectors can have strides while gsl matrices are contiguous or a 
submatrix
     of a contiguous matrix.

If you want to roll your own, you have to take the differences above 
into account.
Then take an numpy two dimensional array from user space and use
gsl_matrix_view to generate an appropriate gsl matrix structure.


Or you use what pygsl provides. Then in your swig file  import

http://pygsl.cvs.sourceforge.net/viewvc/pygsl/pygsl/typemaps/gsl_block_typemaps.i

Please do not forget to add
<snip>
%init %{
     init_pygsl();
%}
</snip>
in your swig file.


Please note that the respective search paths must be available for
swig and the C compiler.

If you use setup.py you can use the _swig_Extension provided by pygsl.

This should get you started. Happy to answer if there are more questions

Sincerely yours
     PIerre







> Hallo,
>
> ich schreibe mal gleich deutsch, ich glaube ihr sie sind von hier. Ich habe 
> folgendes kleines Problem
> und konnte leider dazu bis jetzt in der Doku keine Lösung finden.
> Ich habe unter Nutzung der GNU scientific library einige C Quellen erstellt, 
> die für Berechnungen
> gebraucht werden. Datentyp ist dort immer gsl_matrix in 2d. Nun sind mir 
> einige Dinge in C zu
> aufwändig und ich wollte daher ein python script drüber setzen. Sollte ja an 
> sich gehen. Dazu habe
> ich meine ganzen Quellen mittels SWIG in eine .so gelinkt, die ich vom python 
> script aus nutzen
> kann. Soweit geht das erst mal. Mein Problem entsteht nun an der Stelle, wo 
> ich eine C Routine
> von python aus aufrufen möchte, die den Datentyp gsl_matrix als Übergabewert 
> nutzt. Im reinen
> C ging das. Aber wie nun in python?
> Ich dachte dazu die pygsl lib zu nehmen und hoffte, dass man dort diesen Typ 
> definieren und
> im Aufruf übergeben kann. Ist der Gedanke richtig? Wenn ja, wie geht das? 
> Bekomme ich einfach
> nicht hin. Oder braucht man pygsl an dieser Stelle gar nicht und muss es 
> anders erledigen?
> Ich würde mich sehr freuen, eine Rückmeldung zu erhalten.
> Bis dahin beste Grüße und ein schönes Wochenende...
>
> Stephan
>
>
>


-- 
+---------------------------------------------------------------------+
   Pierre Schnizer  <[email protected]>
   Telephon : +49 6159 71 1557
   Fax      : +49 6159 71 3099

GSI Helmholtzzentrum für Schwerionenforschung GmbH

Planckstraße 1
64291 Darmstadt
www.gsi.de

Gesellschaft mit beschränkter Haftung
Sitz der Gesellschaft: Darmstadt
Handelsregister: Amtsgericht Darmstadt, HRB 1528

Geschäftsführung:
Ursula Weyrich
Professor Dr. Karlheinz Langanke

Vorsitzender des Aufsichtsrates: St Dr. Georg Schütte
Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt
+---------------------------------------------------------------------+


------------------------------------------------------------------------------
_______________________________________________
pygsl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pygsl-discuss

Reply via email to