AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
AbstractLinAlgPack_COOMatrixPartitionViewSubclass.cpp
00001 #if 0
00002 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00007 //                  Copyright (2003) Sandia Corporation
00008 // 
00009 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 // license for use of this work by or on behalf of the U.S. Government.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00027 // 
00028 // ***********************************************************************
00029 // @HEADER
00030 
00031 #include "AbstractLinAlgPack_LinAlgOpPackHack.hpp"
00032 #include "AbstractLinAlgPack_COOMatrixPartitionViewSubclass.hpp"
00033 #include "AbstractLinAlgPack_SparseVectorSliceOp.hpp"
00034 #include "AbstractLinAlgPack_SparseElement.hpp"
00035 #include "AbstractLinAlgPack_COOMPartitionOp.hpp"
00036 #include "DenseLinAlgPack_DMatrixOp.hpp"
00037 
00038 namespace LinAlgOpPack {
00039 
00040 using AbstractLinAlgPack::Vp_StV;
00041 using AbstractLinAlgPack::Vp_StMtV;
00042 using AbstractLinAlgPack::Mp_StM;
00043 using AbstractLinAlgPack::Mp_StMtM;
00044 
00045 } // end namespace LinAlgOpPack
00046 
00047 namespace AbstractLinAlgPack {
00048 
00049 size_type COOMatrixPartitionViewSubclass::rows() const {
00050   return trans_ == BLAS_Cpp::no_trans ? m().rows() : m().cols();
00051 }
00052 
00053 size_type COOMatrixPartitionViewSubclass::cols() const {
00054   return trans_ == BLAS_Cpp::no_trans ? m().cols() : m().rows();
00055 }
00056 
00057 MatrixOp& COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m) {
00058   if(&m == this) return *this;  // assignment to self
00059   const COOMatrixPartitionViewSubclass *p_m = dynamic_cast<const COOMatrixPartitionViewSubclass*>(&m);
00060   if(p_m) {
00061     throw std::invalid_argument("COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m)"
00062       " :  There is not an assignment operator defined for COOMatrixWithPartitionedView::partition_type"
00063       ".   Only assignment to self can be handeled" );
00064   }
00065   else {
00066     throw std::invalid_argument("COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m)"
00067       " : The concrete type of m is not a subclass of COOMatrixPartitionViewSubclass as expected" );
00068   }
00069   return *this;
00070 }
00071 
00072 // Level-1 BLAS
00073 
00074 void COOMatrixPartitionViewSubclass::Mp_StM(DMatrixSlice* gms_lhs, value_type alpha
00075   , BLAS_Cpp::Transp trans_rhs) const
00076 {
00077   AbstractLinAlgPack::Mp_StM(gms_lhs,alpha,m(),op(trans_rhs));
00078 }
00079 
00080 // Level-2 BLAS
00081 
00082 void COOMatrixPartitionViewSubclass::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha
00083   , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta) const
00084 {
00085   AbstractLinAlgPack::Vp_StMtV(vs_lhs, alpha, m(), op(trans_rhs1), vs_rhs2, beta);
00086 }
00087 
00088 void COOMatrixPartitionViewSubclass::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha
00089   , BLAS_Cpp::Transp trans_rhs1, const SpVectorSlice& sv_rhs2, value_type beta) const
00090 {
00091   DVector v_rhs2;
00092   LinAlgOpPack::assign(&v_rhs2,sv_rhs2);
00093   AbstractLinAlgPack::Vp_StMtV(vs_lhs, alpha, m(), op(trans_rhs1), v_rhs2(), beta);
00094 }
00095 
00096 value_type COOMatrixPartitionViewSubclass::transVtMtV(const DVectorSlice& vs_rhs1
00097   , BLAS_Cpp::Transp trans_rhs2, const DVectorSlice& vs_rhs3) const
00098 {
00099   DVector tmp;
00100   LinAlgOpPack::V_MtV(&tmp,m(),op(trans_rhs2),vs_rhs3);
00101   return DenseLinAlgPack::dot(vs_rhs1,tmp());
00102 }
00103 
00104 value_type COOMatrixPartitionViewSubclass::transVtMtV(const SpVectorSlice& sv_rhs1
00105   , BLAS_Cpp::Transp trans_rhs2, const SpVectorSlice& sv_rhs3) const
00106 {
00107   DVector v_rhs3;
00108   LinAlgOpPack::assign(&v_rhs3,sv_rhs3);
00109   DVector tmp;
00110   LinAlgOpPack::V_MtV(&tmp,m(),op(trans_rhs2),v_rhs3());
00111   return dot(sv_rhs1,tmp());
00112 }
00113 
00114 // Level-3 BLAS
00115 
00116 void COOMatrixPartitionViewSubclass::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00117   , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2
00118   , BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00119 {
00120   AbstractLinAlgPack::Mp_StMtM(gms_lhs, alpha, m(), op(trans_rhs1), gms_rhs2, trans_rhs2, beta);
00121 }
00122 
00123 void COOMatrixPartitionViewSubclass::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
00124   , BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00125 {
00126   AbstractLinAlgPack::Mp_StMtM(gms_lhs, alpha, gms_rhs1, trans_rhs1, m(), op(trans_rhs2), beta);
00127 }
00128 
00129 } // end namespace AbstractLinAlgPack
00130 
00131 #endif // 0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends