MOOCHO (Single Doxygen Collection) Version of the Day
AbstractLinAlgPack_MatrixZero.cpp
Go to the documentation of this file.
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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #include <assert.h>
00043 
00044 #include "AbstractLinAlgPack_MatrixZero.hpp"
00045 #include "AbstractLinAlgPack_MatrixSymOp.hpp"
00046 #include "AbstractLinAlgPack_VectorStdOps.hpp"
00047 #include "Teuchos_Assert.hpp"
00048 
00049 namespace AbstractLinAlgPack {
00050 
00051 // Constructors/initializers
00052 
00053 MatrixZero::MatrixZero(
00054   const VectorSpace::space_ptr_t&    space_cols
00055   ,const VectorSpace::space_ptr_t&   space_rows
00056   )
00057 {
00058   this->initialize(space_cols,space_rows);
00059 }
00060 
00061 void MatrixZero::initialize(
00062   const VectorSpace::space_ptr_t&    space_cols
00063   ,const VectorSpace::space_ptr_t&   space_rows
00064   )
00065 {
00066   TEUCHOS_TEST_FOR_EXCEPTION(
00067     (space_cols.get() == NULL && space_rows.get() != NULL)
00068     || (space_cols.get() != NULL && space_rows.get() == NULL)
00069     , std::invalid_argument
00070     ,"MatrixZero::initialize(...) : Error, the space_cols.get() and "
00071     "space_rows.get() must both be != NULL or == NULL" );
00072   space_cols_ = space_cols;
00073   space_rows_ = space_rows;
00074 }
00075 
00076 // Overridden from MatrixBase
00077 
00078 size_type MatrixZero::rows() const
00079 {
00080   return space_cols_.get() ? space_cols_->dim() : 0;
00081 }
00082 
00083 size_type MatrixZero::cols() const
00084 {
00085   return space_rows_.get() ? space_rows_->dim() : 0;
00086 }
00087 
00088 size_type MatrixZero::nz() const
00089 {
00090   return 0;
00091 }
00092 
00093 // Overridden form MatrixOp
00094 
00095 const VectorSpace& MatrixZero::space_cols() const
00096 {
00097   assert_initialized();
00098   return *space_cols_;
00099 }
00100 
00101 const VectorSpace& MatrixZero::space_rows() const
00102 {
00103   assert_initialized();
00104   return *space_rows_;
00105 }
00106 
00107 void MatrixZero::zero_out()
00108 {
00109   assert_initialized();
00110   // Automatically satisfied!
00111 }
00112 
00113 void MatrixZero::Mt_S( value_type alpha )
00114 {
00115   assert_initialized();
00116   // Automatically satisfied!
00117 }
00118 
00119 MatrixOp& MatrixZero::operator=(const MatrixOp& M)
00120 {
00121   assert_initialized();
00122   TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
00123   return *this;
00124 }
00125 
00126 std::ostream& MatrixZero::output(std::ostream& out) const
00127 {
00128   assert_initialized();
00129   return out << "Zero matrix of dimension " << rows() << " x " << cols() << std::endl;
00130 }
00131 
00132 // Level-1 BLAS
00133 
00134 bool MatrixZero::Mp_StM(
00135   MatrixOp* m_lhs, value_type alpha
00136   , BLAS_Cpp::Transp trans_rhs) const
00137 {
00138   assert_initialized();
00139   return true; // Nothing to do!
00140 }
00141 
00142 bool MatrixZero::Mp_StMtP(
00143   MatrixOp* m_lhs, value_type alpha
00144   , BLAS_Cpp::Transp M_trans
00145   , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00146   ) const
00147 {
00148   assert_initialized();
00149   return true; // Nothing to do!
00150 }
00151 
00152 bool MatrixZero::Mp_StPtM(
00153   MatrixOp* m_lhs, value_type alpha
00154   , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00155   , BLAS_Cpp::Transp M_trans
00156   ) const
00157 {
00158   assert_initialized();
00159   return true; // Nothing to do!
00160 }
00161 
00162 bool MatrixZero::Mp_StPtMtP(
00163   MatrixOp* m_lhs, value_type alpha
00164   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00165   , BLAS_Cpp::Transp M_trans
00166   , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
00167   ) const
00168 {
00169   assert_initialized();
00170   return true; // Nothing to do!
00171 }
00172 
00173 // Level-2 BLAS
00174 
00175 void MatrixZero::Vp_StMtV(
00176   VectorMutable* y, value_type a, BLAS_Cpp::Transp M_trans_in
00177   , const Vector& x, value_type b
00178   ) const
00179 {
00180   assert_initialized();
00181   Vt_S(y,b);
00182 }
00183 
00184 void MatrixZero::Vp_StMtV(
00185   VectorMutable* y, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00186   , const SpVectorSlice& x, value_type b) const
00187 {
00188   assert_initialized();
00189   Vt_S(y,b);
00190 }
00191 
00192 void MatrixZero::Vp_StPtMtV(
00193   VectorMutable* y, value_type alpha
00194   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00195   , BLAS_Cpp::Transp M_rhs2_trans
00196   , const Vector& x, value_type b) const
00197 {
00198   assert_initialized();
00199   Vt_S(y,b);
00200 }
00201 
00202 void MatrixZero::Vp_StPtMtV(
00203   VectorMutable* y, value_type alpha
00204   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00205   , BLAS_Cpp::Transp M_rhs2_trans
00206   , const SpVectorSlice& x, value_type b) const
00207 {
00208   assert_initialized();
00209   Vt_S(y,b);
00210 }
00211 
00212 value_type MatrixZero::transVtMtV(
00213   const Vector& v_rhs1, BLAS_Cpp::Transp trans_rhs2
00214   , const Vector& v_rhs3) const
00215 {
00216   assert_initialized();
00217   return 0.0; // Nothing to do!
00218 }
00219 
00220 value_type MatrixZero::transVtMtV(
00221   const SpVectorSlice& sv_rhs1, BLAS_Cpp::Transp trans_rhs2
00222   , const SpVectorSlice& sv_rhs3) const
00223 {
00224   assert_initialized();
00225   return 0.0; // Nothing to do!
00226 }
00227 
00228 void MatrixZero::syr2k(
00229   BLAS_Cpp::Transp M_trans, value_type alpha
00230   , const GenPermMatrixSlice& P1, BLAS_Cpp::Transp P1_trans
00231   , const GenPermMatrixSlice& P2, BLAS_Cpp::Transp P2_trans
00232   , value_type beta, MatrixSymOp* sym_lhs ) const
00233 {
00234   assert_initialized();
00235   sym_lhs->Mt_S(beta);
00236 }
00237 
00238 // Level-3 BLAS
00239 
00240 bool MatrixZero::Mp_StMtM(
00241   MatrixOp* m_lhs, value_type alpha
00242   , BLAS_Cpp::Transp trans_rhs1, const MatrixOp& mwo_rhs2
00243   , BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00244 {
00245   assert_initialized();
00246   m_lhs->Mt_S(beta);
00247   return true;
00248 }
00249 
00250 bool MatrixZero::Mp_StMtM(
00251   MatrixOp* m_lhs, value_type alpha
00252   , const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1
00253   , BLAS_Cpp::Transp trans_rhs2, value_type beta ) const
00254 {
00255   assert_initialized();
00256   m_lhs->Mt_S(beta);
00257   return true;
00258 }
00259 
00260 bool MatrixZero::syrk(
00261   BLAS_Cpp::Transp M_trans, value_type alpha
00262   , value_type beta, MatrixSymOp* sym_lhs ) const
00263 {
00264   assert_initialized();
00265   sym_lhs->Mt_S(beta);
00266   return true;
00267 }
00268 
00269 // private
00270 
00271 void MatrixZero::assert_initialized() const {
00272   TEUCHOS_TEST_FOR_EXCEPTION(
00273     space_cols_.get() == NULL, std::logic_error
00274     ,"Error, the MatrixZero object has not been initialized!" );
00275 }
00276 
00277 } // end namespace AbstractLinAlgPack
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines