MOOCHO (Single Doxygen Collection) Version of the Day
AbstractLinAlgPack_COOMatrixPartitionViewSubclass.cpp
Go to the documentation of this file.
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 // Redistribution and use in source and binary forms, with or without
00013 // modification, are permitted provided that the following conditions are
00014 // met:
00015 //
00016 // 1. Redistributions of source code must retain the above copyright
00017 // notice, this list of conditions and the following disclaimer.
00018 //
00019 // 2. Redistributions in binary form must reproduce the above copyright
00020 // notice, this list of conditions and the following disclaimer in the
00021 // documentation and/or other materials provided with the distribution.
00022 //
00023 // 3. Neither the name of the Corporation nor the names of the
00024 // contributors may be used to endorse or promote products derived from
00025 // this software without specific prior written permission.
00026 //
00027 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00028 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00031 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 //
00039 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00040 // 
00041 // ***********************************************************************
00042 // @HEADER
00043 
00044 #include "AbstractLinAlgPack_LinAlgOpPackHack.hpp"
00045 #include "AbstractLinAlgPack_COOMatrixPartitionViewSubclass.hpp"
00046 #include "AbstractLinAlgPack_SparseVectorSliceOp.hpp"
00047 #include "AbstractLinAlgPack_SparseElement.hpp"
00048 #include "AbstractLinAlgPack_COOMPartitionOp.hpp"
00049 #include "DenseLinAlgPack_DMatrixOp.hpp"
00050 
00051 namespace LinAlgOpPack {
00052 
00053 using AbstractLinAlgPack::Vp_StV;
00054 using AbstractLinAlgPack::Vp_StMtV;
00055 using AbstractLinAlgPack::Mp_StM;
00056 using AbstractLinAlgPack::Mp_StMtM;
00057 
00058 } // end namespace LinAlgOpPack
00059 
00060 namespace AbstractLinAlgPack {
00061 
00062 size_type COOMatrixPartitionViewSubclass::rows() const {
00063   return trans_ == BLAS_Cpp::no_trans ? m().rows() : m().cols();
00064 }
00065 
00066 size_type COOMatrixPartitionViewSubclass::cols() const {
00067   return trans_ == BLAS_Cpp::no_trans ? m().cols() : m().rows();
00068 }
00069 
00070 MatrixOp& COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m) {
00071   if(&m == this) return *this;  // assignment to self
00072   const COOMatrixPartitionViewSubclass *p_m = dynamic_cast<const COOMatrixPartitionViewSubclass*>(&m);
00073   if(p_m) {
00074     throw std::invalid_argument("COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m)"
00075       " :  There is not an assignment operator defined for COOMatrixWithPartitionedView::partition_type"
00076       ".   Only assignment to self can be handeled" );
00077   }
00078   else {
00079     throw std::invalid_argument("COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m)"
00080       " : The concrete type of m is not a subclass of COOMatrixPartitionViewSubclass as expected" );
00081   }
00082   return *this;
00083 }
00084 
00085 // Level-1 BLAS
00086 
00087 void COOMatrixPartitionViewSubclass::Mp_StM(DMatrixSlice* gms_lhs, value_type alpha
00088   , BLAS_Cpp::Transp trans_rhs) const
00089 {
00090   AbstractLinAlgPack::Mp_StM(gms_lhs,alpha,m(),op(trans_rhs));
00091 }
00092 
00093 // Level-2 BLAS
00094 
00095 void COOMatrixPartitionViewSubclass::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha
00096   , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta) const
00097 {
00098   AbstractLinAlgPack::Vp_StMtV(vs_lhs, alpha, m(), op(trans_rhs1), vs_rhs2, beta);
00099 }
00100 
00101 void COOMatrixPartitionViewSubclass::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha
00102   , BLAS_Cpp::Transp trans_rhs1, const SpVectorSlice& sv_rhs2, value_type beta) const
00103 {
00104   DVector v_rhs2;
00105   LinAlgOpPack::assign(&v_rhs2,sv_rhs2);
00106   AbstractLinAlgPack::Vp_StMtV(vs_lhs, alpha, m(), op(trans_rhs1), v_rhs2(), beta);
00107 }
00108 
00109 value_type COOMatrixPartitionViewSubclass::transVtMtV(const DVectorSlice& vs_rhs1
00110   , BLAS_Cpp::Transp trans_rhs2, const DVectorSlice& vs_rhs3) const
00111 {
00112   DVector tmp;
00113   LinAlgOpPack::V_MtV(&tmp,m(),op(trans_rhs2),vs_rhs3);
00114   return DenseLinAlgPack::dot(vs_rhs1,tmp());
00115 }
00116 
00117 value_type COOMatrixPartitionViewSubclass::transVtMtV(const SpVectorSlice& sv_rhs1
00118   , BLAS_Cpp::Transp trans_rhs2, const SpVectorSlice& sv_rhs3) const
00119 {
00120   DVector v_rhs3;
00121   LinAlgOpPack::assign(&v_rhs3,sv_rhs3);
00122   DVector tmp;
00123   LinAlgOpPack::V_MtV(&tmp,m(),op(trans_rhs2),v_rhs3());
00124   return dot(sv_rhs1,tmp());
00125 }
00126 
00127 // Level-3 BLAS
00128 
00129 void COOMatrixPartitionViewSubclass::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00130   , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2
00131   , BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00132 {
00133   AbstractLinAlgPack::Mp_StMtM(gms_lhs, alpha, m(), op(trans_rhs1), gms_rhs2, trans_rhs2, beta);
00134 }
00135 
00136 void COOMatrixPartitionViewSubclass::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
00137   , BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00138 {
00139   AbstractLinAlgPack::Mp_StMtM(gms_lhs, alpha, gms_rhs1, trans_rhs1, m(), op(trans_rhs2), beta);
00140 }
00141 
00142 } // end namespace AbstractLinAlgPack
00143 
00144 #endif // 0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines