|
DenseLinAlgPack: Concreate C++ Classes for Dense Blas-Compatible Linear Algebra Version of the Day
|
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 <stdexcept> 00030 #include <string> 00031 00032 #include "DenseLinAlgPack_AssertOp.hpp" 00033 #include "Teuchos_TestForException.hpp" 00034 00035 #ifdef LINALGPACK_CHECK_RHS_SIZES 00036 00037 void DenseLinAlgPack::Vp_V_assert_sizes(size_type v_lhs_size, size_type v_rhs_size) 00038 { 00039 TEST_FOR_EXCEPTION( 00040 v_lhs_size != v_rhs_size, std::length_error 00041 ,"Vp_V_assert_sizes(...) : The sizes of v_lhs = " << v_lhs_size << " and v_rhs = " << v_rhs_size 00042 << " in the operation v_lhs += op v_rhs do not match"); 00043 } 00044 00045 void DenseLinAlgPack::VopV_assert_sizes(size_type v_rhs1_size, size_type v_rhs2_size) 00046 { 00047 TEST_FOR_EXCEPTION( 00048 v_rhs1_size != v_rhs2_size, std::length_error 00049 ,"VopV_assert_sizes(...) : The sizes of v_rhs1 and v_rhs2 " 00050 "in the operation v_rhs1 op v_rhs2 do not match"); 00051 } 00052 00053 void DenseLinAlgPack::Mp_M_assert_sizes(size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs 00054 , size_type m_rhs_rows, size_type m_rhs_cols, BLAS_Cpp::Transp trans_rhs) 00055 { 00056 if( rows(m_lhs_rows,m_lhs_cols,trans_lhs) != rows(m_rhs_rows,m_rhs_cols,trans_rhs) 00057 || cols(m_lhs_rows,m_lhs_cols,trans_lhs) != cols(m_rhs_rows,m_rhs_cols,trans_rhs) ) 00058 { 00059 TEST_FOR_EXCEPTION( 00060 true, std::length_error 00061 ,"Mp_M_assert_sizes(...) : The sizes of m_lhs and m_rhs " 00062 "in the operation op(m_lhs) += op op(m_rhs) do not match"); 00063 } 00064 } 00065 00066 void DenseLinAlgPack::MopM_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1 00067 , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2) 00068 { 00069 if( rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2) 00070 || cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != cols(m_rhs2_rows,m_rhs2_cols,trans_rhs2) ) 00071 { 00072 TEST_FOR_EXCEPTION( 00073 true, std::length_error 00074 ,"Mp_M_assert_sizes(...) : The sizes of m_rhs1 and m_rhs2 " 00075 "in the operation op(m_rhs1) op op(m_rhs2) do not match"); 00076 } 00077 } 00078 00079 void DenseLinAlgPack::MtV_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols 00080 , BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size) 00081 { 00082 if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_rhs2_size) 00083 TEST_FOR_EXCEPTION( 00084 true, std::length_error 00085 ,"MtV_assert_sizes(...) : The number of columns in " 00086 "m_rhs1 and the size of v_rhs2 in the operation v_lhs += op(m_rhs1) * v_rhs2 " 00087 "do not match"); 00088 } 00089 00090 void DenseLinAlgPack::Vp_MtV_assert_sizes(size_type v_lhs_size, size_type m_rhs1_rows 00091 , size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size) 00092 { 00093 if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_rhs2_size) 00094 TEST_FOR_EXCEPTION( 00095 true, std::length_error 00096 ,"Vp_MtV_assert_sizes(...) : The number of columns in" 00097 " m_rhs1 and the size of v_rhs2 in the operation v_lhs += op(m_rhs1) * v_rhs2" 00098 " do not match"); 00099 if(rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_lhs_size) 00100 TEST_FOR_EXCEPTION( 00101 true, std::length_error 00102 ,"Vp_MtV_assert_sizes(...) : The number of rows in" 00103 " m_rhs1 and the size of v_lhs in the operation v_lhs += op(m_rhs1) * v_rhs2" 00104 " do not match"); 00105 } 00106 00107 void DenseLinAlgPack::MtM_assert_sizes( 00108 size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1 00109 , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2) 00110 { 00111 if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2)) 00112 TEST_FOR_EXCEPTION( 00113 true, std::length_error 00114 ,"MtM_assert_sizes(...) : The number of columns in" 00115 " m_rhs1 and the number of rows in m_rhs2 in the operation" 00116 " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match"); 00117 } 00118 00119 void DenseLinAlgPack::Mp_MtM_assert_sizes( 00120 size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs 00121 , size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1 00122 , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2) 00123 { 00124 if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2)) 00125 TEST_FOR_EXCEPTION( 00126 true, std::length_error 00127 ,"Mp_MtM_assert_sizes(...) : The number of columns in" 00128 " m_rhs1 and the number of rows in m_rhs2 in the operation" 00129 " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match"); 00130 if(rows(m_lhs_rows,m_lhs_cols,trans_lhs) != rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1)) 00131 TEST_FOR_EXCEPTION( 00132 true, std::length_error 00133 ,"Mp_MtM_assert_sizes(...) : The number of rows in" 00134 " m_lhs and the number of rows in m_rhs1 in the operation" 00135 " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match"); 00136 if(cols(m_lhs_rows,m_lhs_cols,trans_lhs) != cols(m_rhs2_rows,m_rhs2_cols,trans_rhs2)) 00137 TEST_FOR_EXCEPTION( 00138 true, std::length_error 00139 ,"Mp_MtM_assert_sizes(...) : The number of columns in" 00140 " m_lhs and the number of columns in m_rhs1 in the operation" 00141 " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match"); 00142 } 00143 00144 #endif // LINALGPACK_CHECK_RHS_SIZES
1.7.4