← Back to team overview

dolfin team mailing list archive

Re: matrix-matrix multiplication

 

---- Original message ----
>Date: Mon, 13 Apr 2009 10:25:44 +0800
>From: "Garth N. Wells" <gnw20@xxxxxxxxx>  
>Subject: Re: [DOLFIN-dev] matrix-matrix multiplication  
>To: arizumi@xxxxxxxxxxxx
>Cc: dolfin-dev@xxxxxxxxxx
>
>
>
>arizumi@xxxxxxxxxxxx wrote:
>> hi,  
>> I've been having a problem of calculating sparse matrix-matrix multiplication using uBLASSparseMatrix.  
>> 
>> I declare matrices A and B as following.
>> 
>> Matrix A0;
>> uBLASSparseMatrix& A(A0.down_cast<uBLASSparseMatrix>());
>> Matrix B0;
>> uBLASSparseMatrix& B(B0.down_cast<uBLASSparseMatrix>());
>> 
>> After assigning matrix values, use "prod" from boost to multiply.  but, I don't know where to return.  From compiler error 'ublas_sparse_matrix' is not a member of ‘boost::numeric::ublas’.  even if I use 'matrix' as follows, I don't know how to make this into uBLASSparseMatrix.
>> 
>> boost::numeric::ublas::matrix<double> C;
>> C = boost::numeric::ublas::prod(A.mat(), B.mat()); 
>> 
>> My first guess was to declare 
>> uBLASSpareseMatrix& C1(C); 
>> but this will give a compiler error "‘uBLASSpareseMatrix’ was not declared in this scope"
>> 
>> I would greatly appreciate any helpful suggestion.
>
>Try
>
>    uBLASSpare Matrix A;
>     ublas_sparse_matrix& B = A.mat();
>
>B will be a uBLAS object (ublas_sparse_matrix is a DOLFIN typedef for 
>the uBLAS matrix which underlies uBLASSpareMatrix).
>
>Garth
>
>
>> Thank you,
>> Nana Arizumi
>> _______________________________________________
>> DOLFIN-dev mailing list
>> DOLFIN-dev@xxxxxxxxxx
>> http://www.fenics.org/mailman/listinfo/dolfin-dev
>
>

Thank you,
I am still having a problem.  What I want to solve is
(A+B^(-1)*C) u = f
where A, B, and C are the matrices from bilinear form, u and f are vectors.

I realized there are no inverse or matrix-matrix multiplication in GenericMatrix, so I am trying to use uBLASSparseMatrix.

I have a couple of questions related to this, and I was wondering if anybody could provide any assistance/clarity.

1.   
uBLASSpare Matrix A;
ublas_sparse_matrix& B = A.mat(); 
uBLASSparseMatrix C(ublas_sparse_matrix& B);

Is this how I should construct C using Boost matrix?

2.
LUSolver is not usable for uBLAS matrices as I understand from manual.  I should use solve function from uBLASSParseMatrix or I can use uBLASKrylovMatrix.  Both of the cases I need uBLASVector, but my u vector is a GenericVector, so I need to down_cast this. 
I tried two ways
uBLASVector& u1(u.down_cast<uBLASVector>());
uBLASVector& u1(static_cast<uBLASVector&>(u));
but, none of the solve are working.  What am I missing?

3.
I set linear algebra backend as uBLAS and following code 
cout << "Matrix backend = " << dolfin_get("linear algebra backend") << endl;
also say uBLAS, but when I try to use solve function from uBLASSparseMatrix I am receiving PETSC ERROR and crush.  Why is it?

Any help would be greatly appreciated.
Thank you,
nana

Follow ups