AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
AbstractLinAlgPack_MatrixOpSerial.hpp
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 #ifndef SPARSE_LINALG_PACK_MATRIX_WITH_OP_SERIAL_H
00043 #define SPARSE_LINALG_PACK_MATRIX_WITH_OP_SERIAL_H
00044 
00045 #include <iosfwd>
00046 
00047 #include "AbstractLinAlgPack_Types.hpp"
00048 #include "AbstractLinAlgPack_MatrixOp.hpp"
00049 #include "AbstractLinAlgPack_VectorSpaceSerial.hpp"
00050 
00051 namespace AbstractLinAlgPack {
00052 
00077 class MatrixOpSerial
00078   : virtual public AbstractLinAlgPack::MatrixOp // doxygen needs full name
00079 {
00080 public:
00081 
00083   using MatrixOp::Mp_StM;
00085   using MatrixOp::Mp_StMtP;
00087   using MatrixOp::Mp_StPtM;
00089   using MatrixOp::Mp_StPtMtP;
00091   using MatrixOp::Vp_StMtV;
00093   using MatrixOp::Mp_StMtM;
00094 
00097 
00099   virtual void Mp_StM(DMatrixSlice* gms_lhs, value_type alpha
00100     , BLAS_Cpp::Transp trans_rhs) const;
00101 
00103   virtual void Mp_StMtP(DMatrixSlice* gms_lhs, value_type alpha
00104     , BLAS_Cpp::Transp M_trans
00105     , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00106     ) const;
00107 
00109   virtual void Mp_StPtM(DMatrixSlice* gms_lhs, value_type alpha
00110     , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00111     , BLAS_Cpp::Transp M_trans
00112     ) const;
00113 
00115   virtual void Mp_StPtMtP(DMatrixSlice* gms_lhs, value_type alpha
00116     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00117     , BLAS_Cpp::Transp M_trans
00118     , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
00119     ) const;
00120 
00122 
00125 
00127   virtual void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00128     , const DVectorSlice& vs_rhs2, value_type beta) const = 0;
00129 
00131   virtual void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00132     , const SpVectorSlice& sv_rhs2, value_type beta) const;
00133 
00135   virtual void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
00136     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00137     , BLAS_Cpp::Transp M_rhs2_trans
00138     , const DVectorSlice& vs_rhs3, value_type beta) const;
00139 
00141   virtual void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
00142     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00143     , BLAS_Cpp::Transp M_rhs2_trans
00144     , const SpVectorSlice& sv_rhs3, value_type beta) const;
00145 
00147   virtual value_type transVtMtV(const DVectorSlice& vs_rhs1, BLAS_Cpp::Transp trans_rhs2
00148     , const DVectorSlice& vs_rhs3) const;
00149 
00161   virtual void syr2k(
00162      BLAS_Cpp::Transp M_trans, value_type alpha
00163     , const GenPermMatrixSlice& P1, BLAS_Cpp::Transp P1_trans
00164     , const GenPermMatrixSlice& P2, BLAS_Cpp::Transp P2_trans
00165     , value_type beta, DMatrixSliceSym* sym_lhs ) const;
00166 
00168 
00171 
00173   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00174     , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2
00175     , BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00176 
00178   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
00179     , BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00180 
00182   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00183     , BLAS_Cpp::Transp trans_rhs1, const MatrixOpSerial& mwo_rhs2
00184     , BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00185 
00187   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00188     , BLAS_Cpp::Transp trans_rhs1, const DMatrixSliceSym& sym_rhs2
00189     , BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00190 
00192   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSliceSym& sym_rhs1
00193     , BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00194 
00196   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00197     , BLAS_Cpp::Transp trans_rhs1, const DMatrixSliceTri& tri_rhs2
00198     , BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00199 
00201   virtual void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSliceTri& tri_rhs1
00202     , BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const;
00203 
00204 
00213   virtual void syrk(
00214      BLAS_Cpp::Transp M_trans, value_type alpha
00215     , value_type beta, DMatrixSliceSym* sym_lhs ) const;
00216 
00218 
00221 
00223   const VectorSpace& space_cols() const;
00225   const VectorSpace& space_rows() const;
00227   std::ostream& output(std::ostream& out) const;
00229   bool Mp_StM(
00230     MatrixOp* mwo_lhs, value_type alpha
00231     ,BLAS_Cpp::Transp trans_rhs
00232     ) const;
00234   bool Mp_StMtP(
00235     MatrixOp* mwo_lhs, value_type alpha
00236     , BLAS_Cpp::Transp M_trans
00237     , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00238     ) const;
00240   bool Mp_StPtM(
00241     MatrixOp* mwo_lhs, value_type alpha
00242     , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00243     , BLAS_Cpp::Transp M_trans
00244     ) const;
00246   bool Mp_StPtMtP(
00247     MatrixOp* mwo_lhs, value_type alpha
00248     ,const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00249     ,BLAS_Cpp::Transp M_trans
00250     ,const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
00251     ) const;
00253   void Vp_StMtV(
00254     VectorMutable* v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00255     , const Vector& v_rhs2, value_type beta) const;
00257   void Vp_StMtV(
00258     VectorMutable* v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00259     , const SpVectorSlice& sv_rhs2, value_type beta) const;
00261   void Vp_StPtMtV(
00262     VectorMutable* v_lhs, value_type alpha
00263     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00264     , BLAS_Cpp::Transp M_rhs2_trans
00265     , const Vector& v_rhs3, value_type beta) const;
00267   void Vp_StPtMtV(
00268     VectorMutable* v_lhs, value_type alpha
00269     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00270     , BLAS_Cpp::Transp M_rhs2_trans
00271     , const SpVectorSlice& sv_rhs3, value_type beta) const;
00273   value_type transVtMtV(
00274     const Vector& v_rhs1, BLAS_Cpp::Transp trans_rhs2
00275     , const Vector& v_rhs3) const;
00277   value_type transVtMtV(
00278     const SpVectorSlice& sv_rhs1, BLAS_Cpp::Transp trans_rhs2
00279     , const SpVectorSlice& sv_rhs3) const;
00281   void syr2k(
00282      BLAS_Cpp::Transp M_trans, value_type alpha
00283     , const GenPermMatrixSlice& P1, BLAS_Cpp::Transp P1_trans
00284     , const GenPermMatrixSlice& P2, BLAS_Cpp::Transp P2_trans
00285     , value_type beta, MatrixSymOp* symwo_lhs ) const;
00287   bool Mp_StMtM(
00288     MatrixOp* mwo_lhs, value_type alpha
00289     ,BLAS_Cpp::Transp trans_rhs1
00290     ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2
00291     ,value_type beta ) const;
00293   bool syrk(
00294     BLAS_Cpp::Transp M_trans, value_type alpha
00295     ,value_type beta, MatrixSymOp* sym_lhs ) const;
00296 
00298 
00299 private:
00300 
00301   // ////////////////////////////////////
00302   // Private data members
00303 
00304   mutable VectorSpaceSerial       space_cols_;
00305   mutable VectorSpaceSerial       space_rows_;
00306 
00307   // ////////////////////////////////////
00308   // Private member functions
00309 
00310 };  // end class MatrixOpSerial
00311 
00318 
00321 
00323 inline void Mp_StM(DMatrixSlice* gms_lhs, value_type alpha, const MatrixOpSerial& M_rhs
00324   , BLAS_Cpp::Transp trans_rhs)
00325 {
00326   M_rhs.Mp_StM(gms_lhs,alpha,trans_rhs);
00327 }
00328 
00330 inline void Mp_StMtP(DMatrixSlice* gms_lhs, value_type alpha
00331   , const MatrixOpSerial& M_rhs, BLAS_Cpp::Transp M_trans
00332   , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00333   )
00334 {
00335   M_rhs.Mp_StMtP(gms_lhs,alpha,M_trans,P_rhs,P_rhs_trans);
00336 }
00337 
00339 inline void Mp_StPtM(DMatrixSlice* gms_lhs, value_type alpha
00340   , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
00341   , const MatrixOpSerial& M_rhs, BLAS_Cpp::Transp M_trans
00342   )
00343 {
00344   M_rhs.Mp_StPtM(gms_lhs,alpha,P_rhs,P_rhs_trans,M_trans);
00345 }
00346 
00348 inline void Mp_StPtMtP(DMatrixSlice* gms_lhs, value_type alpha
00349   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00350   , const MatrixOpSerial& M_rhs, BLAS_Cpp::Transp trans_rhs
00351   , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
00352   )
00353 {
00354   M_rhs.Mp_StPtMtP(gms_lhs,alpha,P_rhs1,P_rhs1_trans,trans_rhs,P_rhs2,P_rhs2_trans);
00355 }
00356 
00358 
00361 
00363 inline void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const MatrixOpSerial& M_rhs1
00364   , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta = 1.0)
00365 {
00366   M_rhs1.Vp_StMtV(vs_lhs,alpha,trans_rhs1,vs_rhs2,beta);
00367 }
00368 
00370 inline void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const MatrixOpSerial& M_rhs1
00371   , BLAS_Cpp::Transp trans_rhs1, const SpVectorSlice& sv_rhs2, value_type beta = 1.0)
00372 {
00373   M_rhs1.Vp_StMtV(vs_lhs,alpha,trans_rhs1,sv_rhs2,beta);
00374 }
00375 
00377 inline void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
00378   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00379   , const MatrixOpSerial& M_rhs2, BLAS_Cpp::Transp M_rhs2_trans
00380   , const DVectorSlice& vs_rhs3, value_type beta = 1.0) 
00381 {
00382   M_rhs2.Vp_StPtMtV(vs_lhs,alpha,P_rhs1,P_rhs1_trans,M_rhs2_trans,vs_rhs3,beta);
00383 }
00384 
00386 inline void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
00387   , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00388   , const MatrixOpSerial& M_rhs2, BLAS_Cpp::Transp M_rhs2_trans
00389   , const SpVectorSlice& sv_rhs3, value_type beta = 1.0)
00390 {
00391   M_rhs2.Vp_StPtMtV(vs_lhs,alpha,P_rhs1,P_rhs1_trans,M_rhs2_trans,sv_rhs3,beta);
00392 }
00393 
00395 inline value_type transVtMtV(const DVectorSlice& vs_rhs1, const MatrixOpSerial& M_rhs2
00396   , BLAS_Cpp::Transp trans_rhs2, const DVectorSlice& vs_rhs3)
00397 {
00398   return M_rhs2.transVtMtV(vs_rhs1,trans_rhs2,vs_rhs3);
00399 }
00400 
00402 inline value_type transVtMtV(const SpVectorSlice& sv_rhs1, const MatrixOpSerial& M_rhs2
00403   , BLAS_Cpp::Transp trans_rhs2, const SpVectorSlice& sv_rhs3)
00404 {
00405   return M_rhs2.transVtMtV(sv_rhs1,trans_rhs2,sv_rhs3);
00406 }
00407 
00409 
00412 
00414 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const MatrixOpSerial& M_rhs1
00415   , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2
00416   , BLAS_Cpp::Transp trans_rhs2, value_type beta = 1.0)
00417 {
00418   M_rhs1.Mp_StMtM(gms_lhs,alpha,trans_rhs1,gms_rhs2,trans_rhs2,beta);
00419 }
00420 
00422 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
00423   , BLAS_Cpp::Transp trans_rhs1, const MatrixOpSerial& M_rhs2, BLAS_Cpp::Transp trans_rhs2
00424   , value_type beta = 1.0)
00425 {
00426   M_rhs2.Mp_StMtM(gms_lhs,alpha,gms_rhs1,trans_rhs1,trans_rhs2,beta);
00427 }
00428 
00430 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const MatrixOpSerial& mwo_rhs1
00431   , BLAS_Cpp::Transp trans_rhs1, const MatrixOpSerial& gms_rhs2
00432   , BLAS_Cpp::Transp trans_rhs2, value_type beta = 1.0)
00433 {
00434   mwo_rhs1.Mp_StMtM(gms_lhs,alpha,trans_rhs1,gms_rhs2,trans_rhs2,beta);
00435 }
00436 
00438 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const MatrixOpSerial& M_rhs1
00439   , BLAS_Cpp::Transp trans_rhs1, const DMatrixSliceSym& sym_rhs2
00440   , BLAS_Cpp::Transp trans_rhs2, value_type beta = 1.0)
00441 {
00442   M_rhs1.Mp_StMtM(gms_lhs,alpha,trans_rhs1,sym_rhs2,trans_rhs2,beta);
00443 }
00444 
00446 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSliceSym& sym_rhs1
00447   , BLAS_Cpp::Transp trans_rhs1, const MatrixOpSerial& M_rhs2, BLAS_Cpp::Transp trans_rhs2
00448   , value_type beta = 1.0)
00449 {
00450   M_rhs2.Mp_StMtM(gms_lhs,alpha,sym_rhs1,trans_rhs1,trans_rhs2,beta);
00451 }
00452 
00454 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const MatrixOpSerial& M_rhs1
00455   , BLAS_Cpp::Transp trans_rhs1, const DMatrixSliceTri& tri_rhs2, BLAS_Cpp::Transp trans_rhs2
00456   , value_type beta = 1.0)
00457 {
00458   M_rhs1.Mp_StMtM(gms_lhs,alpha,trans_rhs1,tri_rhs2,trans_rhs2,beta);
00459 }
00460 
00462 inline void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSliceTri& tri_rhs1
00463   , BLAS_Cpp::Transp trans_rhs1, const MatrixOpSerial& M_rhs2, BLAS_Cpp::Transp trans_rhs2
00464   , value_type beta = 1.0)
00465 {
00466   M_rhs2.Mp_StMtM(gms_lhs,alpha,tri_rhs1,trans_rhs1,trans_rhs2,beta);
00467 }
00468 
00470 
00472 
00473 } // end namespace AbstractLinAlgPack 
00474 
00475 #endif  // SPARSE_LINALG_PACK_MATRIX_WITH_OP_SERIAL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends