AbstractLinAlgPack_COOMatrixPartitionViewSubclass.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 // 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 "AbstractLinAlgPack_LinAlgOpPackHack.hpp"
00030 #include "AbstractLinAlgPack_COOMatrixPartitionViewSubclass.hpp"
00031 #include "AbstractLinAlgPack_SparseVectorSliceOp.hpp"
00032 #include "AbstractLinAlgPack_SparseElement.hpp"
00033 #include "AbstractLinAlgPack_COOMPartitionOp.hpp"
00034 #include "DenseLinAlgPack_DMatrixOp.hpp"
00035 
00036 namespace LinAlgOpPack {
00037 
00038 using AbstractLinAlgPack::Vp_StV;
00039 using AbstractLinAlgPack::Vp_StMtV;
00040 using AbstractLinAlgPack::Mp_StM;
00041 using AbstractLinAlgPack::Mp_StMtM;
00042 
00043 } // end namespace LinAlgOpPack
00044 
00045 namespace AbstractLinAlgPack {
00046 
00047 size_type COOMatrixPartitionViewSubclass::rows() const {
00048   return trans_ == BLAS_Cpp::no_trans ? m().rows() : m().cols();
00049 }
00050 
00051 size_type COOMatrixPartitionViewSubclass::cols() const {
00052   return trans_ == BLAS_Cpp::no_trans ? m().cols() : m().rows();
00053 }
00054 
00055 MatrixOp& COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m) {
00056   if(&m == this) return *this;  // assignment to self
00057   const COOMatrixPartitionViewSubclass *p_m = dynamic_cast<const COOMatrixPartitionViewSubclass*>(&m);
00058   if(p_m) {
00059     throw std::invalid_argument("COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m)"
00060       " :  There is not an assignment operator defined for COOMatrixWithPartitionedView::partition_type"
00061       ".   Only assignment to self can be handeled" );
00062   }
00063   else {
00064     throw std::invalid_argument("COOMatrixPartitionViewSubclass::operator=(const MatrixOp& m)"
00065       " : The concrete type of m is not a subclass of COOMatrixPartitionViewSubclass as expected" );
00066   }
00067   return *this;
00068 }
00069 
00070 // Level-1 BLAS
00071 
00072 void COOMatrixPartitionViewSubclass::Mp_StM(DMatrixSlice* gms_lhs, value_type alpha
00073   , BLAS_Cpp::Transp trans_rhs) const
00074 {
00075   AbstractLinAlgPack::Mp_StM(gms_lhs,alpha,m(),op(trans_rhs));
00076 }
00077 
00078 // Level-2 BLAS
00079 
00080 void COOMatrixPartitionViewSubclass::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha
00081   , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta) const
00082 {
00083   AbstractLinAlgPack::Vp_StMtV(vs_lhs, alpha, m(), op(trans_rhs1), vs_rhs2, beta);
00084 }
00085 
00086 void COOMatrixPartitionViewSubclass::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha
00087   , BLAS_Cpp::Transp trans_rhs1, const SpVectorSlice& sv_rhs2, value_type beta) const
00088 {
00089   DVector v_rhs2;
00090   LinAlgOpPack::assign(&v_rhs2,sv_rhs2);
00091   AbstractLinAlgPack::Vp_StMtV(vs_lhs, alpha, m(), op(trans_rhs1), v_rhs2(), beta);
00092 }
00093 
00094 value_type COOMatrixPartitionViewSubclass::transVtMtV(const DVectorSlice& vs_rhs1
00095   , BLAS_Cpp::Transp trans_rhs2, const DVectorSlice& vs_rhs3) const
00096 {
00097   DVector tmp;
00098   LinAlgOpPack::V_MtV(&tmp,m(),op(trans_rhs2),vs_rhs3);
00099   return DenseLinAlgPack::dot(vs_rhs1,tmp());
00100 }
00101 
00102 value_type COOMatrixPartitionViewSubclass::transVtMtV(const SpVectorSlice& sv_rhs1
00103   , BLAS_Cpp::Transp trans_rhs2, const SpVectorSlice& sv_rhs3) const
00104 {
00105   DVector v_rhs3;
00106   LinAlgOpPack::assign(&v_rhs3,sv_rhs3);
00107   DVector tmp;
00108   LinAlgOpPack::V_MtV(&tmp,m(),op(trans_rhs2),v_rhs3());
00109   return dot(sv_rhs1,tmp());
00110 }
00111 
00112 // Level-3 BLAS
00113 
00114 void COOMatrixPartitionViewSubclass::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
00115   , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2
00116   , BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00117 {
00118   AbstractLinAlgPack::Mp_StMtM(gms_lhs, alpha, m(), op(trans_rhs1), gms_rhs2, trans_rhs2, beta);
00119 }
00120 
00121 void COOMatrixPartitionViewSubclass::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
00122   , BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
00123 {
00124   AbstractLinAlgPack::Mp_StMtM(gms_lhs, alpha, gms_rhs1, trans_rhs1, m(), op(trans_rhs2), beta);
00125 }
00126 
00127 } // end namespace AbstractLinAlgPack

Generated on Thu Sep 18 12:35:10 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1