AbstractLinAlgPack_AbstractLinAlgOpPack.cpp

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_LinAlgOpPack.hpp"
00030 
00031 // Level 1 BLAS for Matrices
00032 
00033 // M_lhs = op(M_rhs).
00034 
00035 void LinAlgOpPack::assign(MatrixOp* M_lhs, const MatrixOp& M_rhs, BLAS_Cpp::Transp trans_rhs)
00036 {
00037   Mp_M_assert_compatibility( M_lhs, BLAS_Cpp::no_trans, M_rhs, trans_rhs );
00038   M_lhs->zero_out();
00039   Mp_StM(M_lhs,1.0,M_rhs,trans_rhs);
00040 }
00041 
00042 // M_lhs = alpha * op(M_rhs).
00043 
00044 void LinAlgOpPack::M_StM(MatrixOp* M_lhs, value_type alpha, const MatrixOp& M_rhs, BLAS_Cpp::Transp trans_rhs)
00045 {
00046   Mp_M_assert_compatibility( M_lhs, BLAS_Cpp::no_trans, M_rhs, trans_rhs );
00047   M_lhs->zero_out();
00048   Mp_StM(M_lhs,alpha,M_rhs,trans_rhs);
00049 }
00050 
00051 // M_lhs = op(M_rhs1) + op(M_rhs2).
00052 
00053 void LinAlgOpPack::M_MpM(MatrixOp* M_lhs, const MatrixOp& M_rhs1, BLAS_Cpp::Transp trans_rhs1
00054   , const MatrixOp& M_rhs2, BLAS_Cpp::Transp trans_rhs2)
00055 {
00056   Mp_M_assert_compatibility(M_lhs,BLAS_Cpp::no_trans,M_rhs1,trans_rhs1);
00057   MopM_assert_compatibility(M_rhs1,trans_rhs1,M_rhs2,trans_rhs2);
00058   M_lhs->zero_out();
00059   Mp_M(M_lhs,M_rhs1,trans_rhs1);
00060   Mp_M(M_lhs,M_rhs2,trans_rhs2);
00061 }
00062 
00063 // M_lhs = op(M_rhs1) - op(M_rhs2).
00064 
00065 void LinAlgOpPack::M_MmM(MatrixOp* M_lhs, const MatrixOp& M_rhs1, BLAS_Cpp::Transp trans_rhs1
00066   , const MatrixOp& M_rhs2, BLAS_Cpp::Transp trans_rhs2)
00067 {
00068   Mp_M_assert_compatibility(M_lhs,BLAS_Cpp::no_trans,M_rhs1,trans_rhs1);
00069   MopM_assert_compatibility(M_rhs1,trans_rhs1,M_rhs2,trans_rhs2);
00070   M_lhs->zero_out();
00071   Mp_M(M_lhs,M_rhs1,trans_rhs1);
00072   Mp_StM(M_lhs,-1.0,M_rhs2,trans_rhs2);
00073 }
00074 
00075 // M_lhs = alpha * op(M_rhs1) + op(m_rhs2).
00076 
00077 void LinAlgOpPack::M_StMpM(MatrixOp* M_lhs, value_type alpha, const MatrixOp& M_rhs1, BLAS_Cpp::Transp trans_rhs1
00078   , const MatrixOp& M_rhs2, BLAS_Cpp::Transp trans_rhs2)
00079 {
00080   Mp_M_assert_compatibility(M_lhs,BLAS_Cpp::no_trans,M_rhs1,trans_rhs1);
00081   MopM_assert_compatibility(M_rhs1,trans_rhs1,M_rhs2,trans_rhs2);
00082   assign(M_lhs,M_rhs2,trans_rhs2);
00083   Mp_StM(M_lhs,alpha,M_rhs1,trans_rhs1);
00084 }
00085 
00086 // Level 3 BLAS
00087 
00088 // M_lhs = alpha * op(M_rhs1) * op(M_rhs2).
00089 
00090 void LinAlgOpPack::M_StMtM(MatrixOp* M_lhs, value_type alpha, const MatrixOp& M_rhs1
00091   , BLAS_Cpp::Transp trans_rhs1, const MatrixOp& M_rhs2, BLAS_Cpp::Transp trans_rhs2)
00092 {
00093   Mp_MtM_assert_compatibility(M_lhs,BLAS_Cpp::no_trans,M_rhs1,trans_rhs1,M_rhs2,trans_rhs2);
00094   Mp_StMtM(M_lhs,alpha,M_rhs1,trans_rhs1,M_rhs2,trans_rhs2,0.0);
00095 }
00096 
00097 // M_lhs = op(M_rhs1) * op(M_rhs2).
00098 
00099 void LinAlgOpPack::M_MtM(MatrixOp* M_lhs, const MatrixOp& M_rhs1
00100   , BLAS_Cpp::Transp trans_rhs1, const MatrixOp& M_rhs2, BLAS_Cpp::Transp trans_rhs2)
00101 {
00102   Mp_MtM_assert_compatibility(M_lhs,BLAS_Cpp::no_trans,M_rhs1,trans_rhs1,M_rhs2,trans_rhs2);
00103   Mp_StMtM(M_lhs,1.0,M_rhs1,trans_rhs1,M_rhs2,trans_rhs2,0.0);
00104 }

Generated on Tue Jul 13 09:28:50 2010 for AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects by  doxygen 1.4.7