[Trilinos-Users] RCP Epetra_Vector
Bartlett, Roscoe A.
bartlettra at ornl.gov
Wed Oct 1 05:07:24 MDT 2014
Antonella,
Use the function Teuchos::rcpFromRef():
http://trilinos.org/docs/r11.10/packages/teuchos/doc/html/classTeuchos_1_1RCP.html#a6c754d72d6d232c97e38bc359ab6ef82
For example, if 'myVec' is an Epetra_Vector (or reference to an Epetra_Vector), use:
const Teuchos::RCP<Epetra_Vector> myVec_rcp = Teuchos::rcpFromRef(myVec);
(and the 'const' inside of <> if it is const).
Note that the new 'myVec_rcp' will *not* own the memory so you have to make sure that 'myVec' stays around long enough. It is much safer to use:
const Teuchos::RCP<Epetra_Vector> myVec_rcp(new Epetra_Vector(...));
and then replace myVec. something() with myVec_rcp->something() and 'myVec' with '*myVec_rcp' when passing to functions (i.e. like a pointer).
For issues associated with using rcpFromRef(), see the section "Converting from non-persisting to persisting references to satisfy the defined idioms" at:
http://trilinos.org/docs/r11.10/packages/teuchos/doc/html/TeuchosMemoryManagementSAND.pdf
Cheers,
-Ross
> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-
> bounces at software.sandia.gov] On Behalf Of Antonella Longo
> Sent: Wednesday, October 01, 2014 5:36 AM
> To: trilinos-users at software.sandia.gov
> Cc: Deepak Garg
> Subject: [Trilinos-Users] RCP Epetra_Vector
>
> We are having an Epetra_Vector, and we want
> to change it into an RCP<Epetra_Vector> to
> use it in LSQR.
> Is there any way to make this conversion?
>
> Deepak Garg and Antonella Longo
>
> -----------------------------------------------
> Antonella Longo
> Istituto Nazionale di Geofisica e Vulcanologia
> Sezione di Pisa
> Via Uguccione della Faggiola, 32
> Pisa, Italy
> Tel. office: 050 8311939
> Cell.: 339 7532089
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> https://software.sandia.gov/mailman/listinfo/trilinos-users
More information about the Trilinos-Users
mailing list