|
EpetraExt Development
|
00001 #include "GenSQP_YUEpetraVector.hpp" 00002 00003 namespace GenSQP { 00004 00005 YUEpetraVector::YUEpetraVector( const Teuchos::RefCountPtr<Epetra_MultiVector> &y_epetra_vec, 00006 const Teuchos::RefCountPtr<Epetra_MultiVector> &u_epetra_vec ) 00007 :y_epetra_vec_(y_epetra_vec), u_epetra_vec_(u_epetra_vec) 00008 {} 00009 00010 // Overridden from Vector 00011 00012 double YUEpetraVector::innerProd( const Vector &x ) const 00013 { 00014 double ydot[1]; 00015 double udot[1]; 00016 YUEpetraVector &ex = Teuchos::dyn_cast<YUEpetraVector>(const_cast <Vector&>(x)); 00017 y_epetra_vec_->Dot( *ex.y_epetra_vec_, ydot ); 00018 if (u_epetra_vec_.get() == 0) 00019 udot[0] = 0.0; 00020 else 00021 u_epetra_vec_->Dot( *ex.u_epetra_vec_, udot ); 00022 return (ydot[0] + udot[0]); 00023 } 00024 00025 void YUEpetraVector::linComb( const double &alpha, const Vector &x, const double &beta ) 00026 { 00027 YUEpetraVector &ex = Teuchos::dyn_cast<YUEpetraVector>(const_cast <Vector&>(x)); 00028 y_epetra_vec_->Update( alpha, *ex.y_epetra_vec_, beta ); 00029 if (u_epetra_vec_.get() != 0) 00030 u_epetra_vec_->Update( alpha, *ex.u_epetra_vec_, beta ); 00031 } 00032 00033 void YUEpetraVector::Scale( const double &alpha ) 00034 { 00035 y_epetra_vec_->Scale( alpha ); 00036 if (u_epetra_vec_.get() != 0) 00037 u_epetra_vec_->Scale( alpha ); 00038 } 00039 00040 void YUEpetraVector::Set( const double &alpha ) 00041 { 00042 y_epetra_vec_->PutScalar( alpha ); 00043 if (u_epetra_vec_.get() != 0) 00044 u_epetra_vec_->PutScalar( alpha ); 00045 } 00046 00047 void YUEpetraVector::Set( const double &alpha, const Vector &x ) 00048 { 00049 YUEpetraVector &ex = Teuchos::dyn_cast<YUEpetraVector>(const_cast <Vector&>(x)); 00050 y_epetra_vec_->Scale( alpha, *ex.y_epetra_vec_ ); 00051 if (u_epetra_vec_.get() != 0) 00052 u_epetra_vec_->Scale( alpha, *ex.u_epetra_vec_ ); 00053 } 00054 00055 Teuchos::RefCountPtr<Vector> YUEpetraVector::createVector() const 00056 { 00057 Teuchos::RefCountPtr<Epetra_MultiVector> yptr = 00058 Teuchos::rcp(new Epetra_MultiVector(y_epetra_vec_->Map(),1,false)); 00059 Teuchos::RefCountPtr<Epetra_MultiVector> uptr = Teuchos::null; 00060 if (u_epetra_vec_.get() != 0) 00061 uptr = Teuchos::rcp(new Epetra_MultiVector(u_epetra_vec_->Map(),1,false)); 00062 00063 return Teuchos::rcp( new YUEpetraVector( yptr, uptr )); 00064 } 00065 00066 Teuchos::RefCountPtr<const Epetra_MultiVector> YUEpetraVector::getYVector() const 00067 { 00068 return y_epetra_vec_; 00069 } 00070 00071 Teuchos::RefCountPtr<const Epetra_MultiVector> YUEpetraVector::getUVector() const 00072 { 00073 return u_epetra_vec_; 00074 } 00075 00076 } // namespace GenSQP
1.7.4