[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Help-gsl] Blitz library and GSL

**From**: |
Paul Schneider |

**Subject**: |
[Help-gsl] Blitz library and GSL |

**Date**: |
Tue, 08 Jun 2004 16:53:58 +0200 |

**User-agent**: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 |

Hello,

`I would like to use blitz::Arrays (because of a couple of very
``convenient features) with the GSL linear algebra routines. What's the
``best way of doing that? Blitz arrays provide a member function .data()
``which returns a pointer to the first element in the blitz array. I tried
``the following code to create a GSL view of the data in the blitz::array :
`
#include <iostream>
#include <cstdlib>
#include <blitz/array.h>
#include <gsl/gsl_linalg.h>
using namespace std;
int main(int argc, char *argv[])
{
blitz::Array<double, 1> X(5);
X = 1.08, 1.07, 0.97, 0.77, 0.84;
cout << "A : " << X << endl;
cout << "A data: " << X.data() << endl;

` gsl_vector_view m = gsl_vector_view_array (X.data(),
``X.extent(blitz::firstDim));
`
cout << &m.vector.data << endl;
for( int i = 0; i < m.vector.size ; ++i ){
cout << gsl_vector_get(&m.vector, i) << endl;
}
return EXIT_SUCCESS;
}

`Since I will have to work with huge matrices and vectors I would like to
``avoid copying as much as possible. Is there a better approach how to get
``stuff into GSL than the above code?
`

`Second question: What's the most efficient way of constructing a GSL
``matrix out of raw C vectors ?
`
Thanks very much for your help,
Paul

**[Help-gsl] Blitz library and GSL**,
*Paul Schneider* **<=**