← Back to team overview

dolfin team mailing list archive

Re: down_cast for Matrix

 

Ostien, Jakob T wrote:
> Hi,
>
> I got myself confused with the down_cast functionality.  Say I assemble three bilinear forms into Matrix A, B, and C, and then consider the expression:
>
> K  = A - A (B^-1) C
>
> (which I actually want to do, go figure).  I like the uBLAS backend so I would like to try
>
> A.mat() - ublas::prod( A.mat(), ublas::prod( B.invert(), C.mat() ) )
>
> But when I try and down_cast from dolfin::Matrix to uBLASMatrix with
>
> uBLASDenseMatrix AA = A.down_cast<uBLASDenseMatrix>();
>
> I get a message that down_cast doesn't live in the Matrix class (even though its in the GenericTensor class).
>
> So I ask, what is the intended usage to get a uBLASMatrix from a Matrix?
>

>You shouldn't be casting from Matrix to uBLASFooMatrix. Down casting is
intended for casting from a GenericMatrix to a derived class (e.g.
PETScMatrix, uBLASSparseMatrix, etc).

>You should create a uBLASSparseMatrix instead of a Matrix.

This was my problem.  I did not make the distinction between uBLASMatrix and uBLASSparseMatrix (which you can assemble into).

Thanks for the help everyone.

Jake


>Garth





References