[Trilinos-Users] Trouble with Teuchos Epetra_CrsMatrix

Hoemmen, Mark mhoemme at sandia.gov
Wed Mar 6 12:56:59 MST 2013


On Mar 6, 2013, at 12:00 PM, <trilinos-users-request at software.sandia.gov>
 wrote:
> Message: 1
> Date: Wed, 6 Mar 2013 20:42:01 +0900
> From: "SungHwan Choi" <sunghwanchoi91 at gmail.com>
> Subject: [Trilinos-Users] Trouble with Teuchos Epetra_CrsMatrix
> To: trilinos-users at software.sandia.gov
> Message-ID:
> 	<CAF=G9Hw=oSxGtab3KBh_Jka6Nj3yK6YSuaj9Xk9rPNGZGhhZyQ at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Dear all,
> 
> I'm confusing how to use teuchos epetra_crsmatrix in the following case.
> (using c++)
> 
> ------------------------------------------------------------------------------------------------------
> class A{
>  Teuchos::RCP<Epetra_CrsMatrix> matrix;
>  A::A(){
>    matrix=Teuchos::rcp(new Epetra_CrsMatrix(blah, blah, ...));
>    B* b=new B();
>    B->compute(matrix);
>    xxxxx
>    xxxxx
>  }
> }
> 
> class B{
>  void B::compute(Teuchos::RCP<Epetra_CrsMatrix> matrix){
>    matrix->InsertGlobalValues(blah, blah, ...);
>  }
> }
> ------------------------------------------------------------------------------------------------------
> 
> I declare "Teuchos::RCP<Epetra_CrsMatrix> matrix" in class A, and insert
> values of matrix using the function in class B.
> Also, xxxxx in class A, I want to calculate something with "matrix" (For
> example, calculate another value with "matrix").
> The above description is right or wrong?
> Thank you.

I don't understand what you mean by this question.  Are you asking whether the code is syntactically correct?  It looks syntactically correct to me, but I don't think you need so many pointers.  For example:

A::A () {
  matrix = Teuchos::rcp (new Epetra_CrsMatrix (…));
  B b;
  b.compute (matrix);
}

You don't even need an RCP if the class A never shares the matrix with anything else, though using an RCP means that you don't have to worry about deallocating the matrix in the destructor of class A.

mfh


More information about the Trilinos-Users mailing list