[Trilinos-Users] Thyra::scale interface changes

Hoemmen, Mark mhoemme at sandia.gov
Tue Dec 11 14:55:44 MST 2012

On Dec 11, 2012, at 11:22 AM, <trilinos-users-request at software.sandia.gov>
> From: David Day <dmday at sandia.gov<mailto:dmday at sandia.gov>>
> Date: Tuesday, December 11, 2012 11:52 AM
> To: "trilinos-users-bounces at software.sandia.gov<mailto:trilinos-users-bounces at software.sandia.gov>" <trilinos-users-bounces at software.sandia.gov<mailto:trilinos-users-bounces at software.sandia.gov>>
> Subject: teuchos
> I am trying to upgrade from an old version of Trilinos to a new version of Trilinos.
> void aXDpbY(
>    Real alpha,
>    const Thyra::MultiVectorBase<Real> &X_r,
>    const Thyra::MultiVectorBase<Real> &X_i,
>    std::vector<Real> &D_r,
>    std::vector<Real> &D_i,
>    Real beta,
>    Thyra::MultiVectorBase<Real> &Y_r,
>    Thyra::MultiVectorBase<Real> &Y_i)
> {
>  // (x_r + i*x_i)*(d_r + i*d_i)
>  // = (x_r*d_r - x_i*d_i)
>  // + i*(x_r*d_i + x_i*d_r)
>  // Y_r = beta*Y_r + alpha*X_r*D_r - alpha*X_i*D_i
>  //Thyra::scale(beta,&Y_r);   // old Trilinos   ,  this is what used to work
>  Thyra::scale(beta,Y_r.col(0).ptr());  //   This is what compiles now.
> ?
> Is this the right way to pass a multi ? vector to Thyra::scale ?

This is acceptable if Y_r only has one column.  Otherwise, it will only scale the first column of Y_r.

The issue is that Thyra's nonmember functions (like Thyra::scale()) used to accept raw pointers in some cases.  This has been deprecated for a long time, and was removed in the 11.0 release.  

You can fix this by passing a Ptr<MultiVectorBase<Real> > instead of a MultiVectorBase<Real>*.  In your example, this would be:

Thyra::scale (beta, Teuchos::ptr (&Y_r));

The interface changed because in debug mode, Ptr<T> checks whether the T* is NULL before dereferencing.  (I would have preferred passing in a T& instead of a Ptr<T>, but it wasn't my decision.)

Hope this helps!  Please feel free to ask any more questions you might have about this.


More information about the Trilinos-Users mailing list