AbstractLinAlgPack_MatrixZero.cpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include <assert.h>
00030 
00031 #include "AbstractLinAlgPack_MatrixZero.hpp"
00032 #include "AbstractLinAlgPack_MatrixSymOp.hpp"
00033 #include "AbstractLinAlgPack_VectorStdOps.hpp"
00034 #include "Teuchos_TestForException.hpp"
00035 
00036 namespace AbstractLinAlgPack {
00037 
00038 // Constructors/initializers
00039 
00040 MatrixZero::MatrixZero(
00041   const VectorSpace::space_ptr_t&    space_cols
00042   ,const VectorSpace::space_ptr_t&   space_rows
00043   )
00044 {
00045   this->initialize(space_cols,space_rows);
00046 }
00047 
00048 void MatrixZero::initialize(
00049   const VectorSpace::space_ptr_t&    space_cols
00050   ,const VectorSpace::space_ptr_t&   space_rows
00051   )
00052 {
00053   TEST_FOR_EXCEPTION(
00054     (space_cols.get() == NULL && space_rows.get() != NULL)
00055     || (space_cols.get() != NULL && space_rows.get() == NULL)
00056     , std::invalid_argument
00057     ,"MatrixZero::initialize(...) : Error, the space_cols.get() and "
00058     "space_rows.get() must both be != NULL or == NULL" );
00059   space_cols_ = space_cols;
00060   space_rows_ = space_rows;
00061 }
00062 
00063 // Overridden from MatrixBase
00064 
00065 size_type MatrixZero::rows() const
00066 {
00067   return space_cols_.get() ? space_cols_->dim() : 0;
00068 }
00069 
00070 size_type MatrixZero::cols() const
00071 {
00072   return space_rows_.get() ? space_rows_->dim() : 0;
00073 }
00074 
00075 size_type MatrixZero::nz() const
00076 {
00077   return 0;
00078 }
00079 
00080 // Overridden form MatrixOp
00081 
00082 const VectorSpace& MatrixZero::space_cols() const
00083 {
00084   assert_initialized();
00085   return *space_cols_;
00086 }
00087 
00088 const VectorSpace& MatrixZero::space_rows() const
00089 {
00090   assert_initialized();
00091   return *space_rows_;
00092 }
00093 
00094 void MatrixZero::zero_out()
00095 {
00096   assert_initialized();
00097   // Automatically satisfied!
00098 }
00099 
00100 void MatrixZero::Mt_S( value_type alpha )
00101 {
00102   assert_initialized();
00103   // Automatically satisfied!
00104 }
00105 
00106 MatrixOp& MatrixZero::operator=(const MatrixOp& M)
00107 {
00108   assert_initialized();
00109   TEST_FOR_EXCEPT(true); // ToDo: Implement!
00110   return *this;
00111 }
00112 
00113 std::ostream& MatrixZero::output(std::ostream& out) const
00114 {
00115   assert_initialized();
00116   return out << "Zero matrix of dimension " << rows() << " x " << cols() << std::endl;
00117 }
00118 
00119 // Level-1 BLAS
00120 
00121 bool MatrixZero::Mp_StM(
00122   MatrixOp* m_lhs, value_type alpha
00123   , BLAS_Cpp::Transp trans_rhs) const
00124 {
00125   assert_initialized();
00126   return true; // Nothing to do!
00127 }
00128 
00129 bool MatrixZero::Mp_StMtP(
00130   MatrixOp* m_lhs, value_type alpha
00131   , BLAS_Cpp::Transp M_trans
00132   , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00133   ) const
00134 {
00135   assert_initialized();
00136   return true; // Nothing to do!
00137 }
00138 
00139 bool MatrixZero::Mp_StPtM(
00140   MatrixOp* m_lhs, value_type alpha
00141   , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00142   , BLAS_Cpp::Transp M_trans
00143   ) const
00144 {
00145   assert_initialized();
00146   return true; // Nothing to do!
00147 }
00148 
00149 bool MatrixZero::Mp_StPtMtP(
00150   MatrixOp* m_lhs, value_type alpha
00151   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00152   , BLAS_Cpp::Transp M_trans
00153   , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
00154   ) const
00155 {
00156   assert_initialized();
00157   return true; // Nothing to do!
00158 }
00159 
00160 // Level-2 BLAS
00161 
00162 void MatrixZero::Vp_StMtV(
00163   VectorMutable* y, value_type a, BLAS_Cpp::Transp M_trans_in
00164   , const Vector& x, value_type b
00165   ) const
00166 {
00167   assert_initialized();
00168   Vt_S(y,b);
00169 }
00170 
00171 void MatrixZero::Vp_StMtV(
00172   VectorMutable* y, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00173   , const SpVectorSlice& x, value_type b) const
00174 {
00175   assert_initialized();
00176   Vt_S(y,b);
00177 }
00178 
00179 void MatrixZero::Vp_StPtMtV(
00180   VectorMutable* y, value_type alpha
00181   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00182   , BLAS_Cpp::Transp M_rhs2_trans
00183   , const Vector& x, value_type b) const
00184 {
00185   assert_initialized();
00186   Vt_S(y,b);
00187 }
00188 
00189 void MatrixZero::Vp_StPtMtV(
00190   VectorMutable* y, value_type alpha
00191   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00192   , BLAS_Cpp::Transp M_rhs2_trans
00193   , const SpVectorSlice& x, value_type b) const
00194 {
00195   assert_initialized();
00196   Vt_S(y,b);
00197 }
00198 
00199 value_type MatrixZero::transVtMtV(
00200   const Vector& v_rhs1, BLAS_Cpp::Transp trans_rhs2
00201   , const Vector& v_rhs3) const
00202 {
00203   assert_initialized();
00204   return 0.0; // Nothing to do!
00205 }
00206 
00207 value_type MatrixZero::transVtMtV(
00208   const SpVectorSlice& sv_rhs1, BLAS_Cpp::Transp trans_rhs2
00209   , const SpVectorSlice& sv_rhs3) const
00210 {
00211   assert_initialized();
00212   return 0.0; // Nothing to do!
00213 }
00214 
00215 void MatrixZero::syr2k(
00216   BLAS_Cpp::Transp M_trans, value_type alpha
00217   , const GenPermMatrixSlice& P1, BLAS_Cpp::Transp P1_trans
00218   , const GenPermMatrixSlice& P2, BLAS_Cpp::Transp P2_trans
00219   , value_type beta, MatrixSymOp* sym_lhs ) const
00220 {
00221   assert_initialized();
00222   sym_lhs->Mt_S(beta);
00223 }
00224 
00225 // Level-3 BLAS
00226 
00227 bool MatrixZero::Mp_StMtM(
00228   MatrixOp* m_lhs, value_type alpha
00229   , BLAS_Cpp::Transp trans_rhs1, const MatrixOp& mwo_rhs2
00230   , BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00231 {
00232   assert_initialized();
00233   m_lhs->Mt_S(beta);
00234   return true;
00235 }
00236 
00237 bool MatrixZero::Mp_StMtM(
00238   MatrixOp* m_lhs, value_type alpha
00239   , const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1
00240   , BLAS_Cpp::Transp trans_rhs2, value_type beta ) const
00241 {
00242   assert_initialized();
00243   m_lhs->Mt_S(beta);
00244   return true;
00245 }
00246 
00247 bool MatrixZero::syrk(
00248   BLAS_Cpp::Transp M_trans, value_type alpha
00249   , value_type beta, MatrixSymOp* sym_lhs ) const
00250 {
00251   assert_initialized();
00252   sym_lhs->Mt_S(beta);
00253   return true;
00254 }
00255 
00256 // private
00257 
00258 void MatrixZero::assert_initialized() const {
00259   TEST_FOR_EXCEPTION(
00260     space_cols_.get() == NULL, std::logic_error
00261     ,"Error, the MatrixZero object has not been initialized!" );
00262 }
00263 
00264 } // end namespace AbstractLinAlgPack

Generated on Wed May 12 21:50:43 2010 for AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects by  doxygen 1.4.7