[Trilinos-Users] Different type RCPs on same data

Bartlett, Roscoe A. bartlettra at ornl.gov
Mon Aug 27 10:05:36 MDT 2012


Holger,

I think what you are asking is supported, as long as the underlying data is stored contiguously (or at least the portion you want to provide an ArrayRCP<> view of).  Assuming you are creating an RCP<boost::multi_array_ref<double, dom> > first and want to create an ArrayRCP<double>, I think what you want is:

  http://trilinos.sandia.gov/packages/docs/dev/packages/teuchos/doc/html/classTeuchos_1_1ArrayRCP.html#aa267b3ac040c53a9962be92d086e84bb

where you would pass in the RCP<boost::multi_array_ref<double, dom> > object post-destroy object.  That would make sure that the boost::multi_array_ref<double, dom> object will not be deleted until all of the ArrayRCP objects are removed.

If you provide a little more code describing what you are doing, I can write the exact code to create the ArrayRCP<double>, I think in one statement.

-Ross


> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-
> bounces at software.sandia.gov] On Behalf Of Holger Brandsmeier
> Sent: Monday, August 27, 2012 4:15 AM
> To: trilinos-users at software.sandia.gov
> Subject: [Trilinos-Users] Different type RCPs on same data
> 
> Dear list,
> 
> I have a list of values stored as `linearList`, an ArrayRCP<double>.
> Now I have a function that returns the same list of values as
> `tensorList`, an RCP of boost::multi_array_ref<double, dim>. For dim=2
> that would be interpreted as a matrix, otherwise a tensor.
> 
> How do I have to setup the RCP of multi_array_ref so that no matter if
> `linearList` or `tensorList` is destroyed first, I don't get memory
> leaks nor memory corruptions.
> 
> Best regards,
> Holger
> 
> --
> Holger Brandsmeier, SAM, ETH Zürich
> http://www.sam.math.ethz.ch/people/bholger
> 
> 
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users



More information about the Trilinos-Users mailing list