[petsc-users] ublas sparse matrix bindings?

Umut Tabak u.tabak at tudelft.nl
Tue Jun 29 10:11:20 CDT 2010


Luke Bloy wrote:
> Umut,
>
> Thanks for the offer I have the basics working with 
> MatCreateSeqAIJWithArrays in case you need it you can use something 
> like this.
>
>   using boost::numeric::ublas;
>   typedef  unbounded_array<PetscInt> IndexArrayType;
>   typedef  unbounded_array<PetscScalar> ValueArrayType;
>   typedef  
> compressed_matrix<PetscScalar,row_major,0,IndexArrayType,ValueArrayType> 
> MatrixType;
>   MatrixType  L(10,10);
>   //Fill L
>   ierr = MatCreateSeqAIJWithArrays(PETSC_COMM_WORLD, 10, 10, 
> L.index1_data().begin() 
> ,L.index2_data().begin(),L.value_data().begin(),&A);
>
> this works so long as you use petscInt and petscScalar as the template 
> parameters of MatrixType.
>
> -
This might be a bit off the topic, however, I had great difficulties 
when assigning some ranges to petsc matrices through the ublas 
interface, I used ublas for interfacing to petsc binary matrices, and on 
the level of interfacing I can tell that the combination of ublas, 
petsc, and PetscExt for block operations seems to be pretty fast... 
Thanks to Dave May for PetscExt ;)


More information about the petsc-users mailing list