MOOCHO (Single Doxygen Collection) Version of the Day
DenseLinAlgPack_AssertOp.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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #include <stdexcept>
00043 #include <string>
00044 
00045 #include "DenseLinAlgPack_AssertOp.hpp"
00046 #include "Teuchos_Assert.hpp"
00047 
00048 #ifdef LINALGPACK_CHECK_RHS_SIZES
00049 
00050 void DenseLinAlgPack::Vp_V_assert_sizes(size_type v_lhs_size, size_type v_rhs_size)
00051 {
00052   TEUCHOS_TEST_FOR_EXCEPTION(
00053     v_lhs_size != v_rhs_size, std::length_error
00054     ,"Vp_V_assert_sizes(...) : The sizes of v_lhs = " << v_lhs_size << " and v_rhs = " << v_rhs_size
00055     << " in the operation v_lhs += op v_rhs do not match");
00056 }
00057 
00058 void DenseLinAlgPack::VopV_assert_sizes(size_type v_rhs1_size, size_type v_rhs2_size)
00059 {
00060   TEUCHOS_TEST_FOR_EXCEPTION(
00061     v_rhs1_size != v_rhs2_size, std::length_error
00062     ,"VopV_assert_sizes(...) : The sizes of v_rhs1 and v_rhs2 "
00063     "in the operation v_rhs1 op v_rhs2 do not match");
00064 }
00065 
00066 void DenseLinAlgPack::Mp_M_assert_sizes(size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs
00067   , size_type m_rhs_rows, size_type m_rhs_cols, BLAS_Cpp::Transp trans_rhs)
00068 {
00069   if(   rows(m_lhs_rows,m_lhs_cols,trans_lhs) != rows(m_rhs_rows,m_rhs_cols,trans_rhs)
00070     ||  cols(m_lhs_rows,m_lhs_cols,trans_lhs) != cols(m_rhs_rows,m_rhs_cols,trans_rhs) )
00071   {
00072     TEUCHOS_TEST_FOR_EXCEPTION(
00073       true, std::length_error
00074       ,"Mp_M_assert_sizes(...) : The sizes of m_lhs and m_rhs "
00075       "in the operation op(m_lhs) += op op(m_rhs) do not match");
00076   }
00077 }
00078 
00079 void DenseLinAlgPack::MopM_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1
00080   , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
00081 {
00082   if(   rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2)
00083     ||  cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != cols(m_rhs2_rows,m_rhs2_cols,trans_rhs2) )
00084   {
00085     TEUCHOS_TEST_FOR_EXCEPTION(
00086       true, std::length_error
00087       ,"Mp_M_assert_sizes(...) : The sizes of m_rhs1 and m_rhs2 "
00088       "in the operation op(m_rhs1) op op(m_rhs2) do not match");
00089   }
00090 }
00091 
00092 void DenseLinAlgPack::MtV_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols
00093   , BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
00094 {
00095   if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_rhs2_size)
00096     TEUCHOS_TEST_FOR_EXCEPTION(
00097       true, std::length_error
00098       ,"MtV_assert_sizes(...) : The number of columns in "
00099       "m_rhs1 and the size of v_rhs2 in the operation v_lhs += op(m_rhs1) * v_rhs2 "
00100       "do not match");
00101 }
00102 
00103 void DenseLinAlgPack::Vp_MtV_assert_sizes(size_type v_lhs_size, size_type m_rhs1_rows
00104   , size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
00105 {
00106   if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_rhs2_size)
00107     TEUCHOS_TEST_FOR_EXCEPTION(
00108       true, std::length_error
00109       ,"Vp_MtV_assert_sizes(...) : The number of columns in"
00110       " m_rhs1 and the size of v_rhs2 in the operation v_lhs += op(m_rhs1) * v_rhs2"
00111       " do not match");
00112   if(rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_lhs_size)
00113     TEUCHOS_TEST_FOR_EXCEPTION(
00114       true, std::length_error
00115       ,"Vp_MtV_assert_sizes(...) : The number of rows in"
00116       " m_rhs1 and the size of v_lhs in the operation v_lhs += op(m_rhs1) * v_rhs2"
00117       " do not match");
00118 }
00119 
00120 void DenseLinAlgPack::MtM_assert_sizes(
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     TEUCHOS_TEST_FOR_EXCEPTION(
00126       true, std::length_error
00127       ,"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 }
00131 
00132 void DenseLinAlgPack::Mp_MtM_assert_sizes(
00133     size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs
00134   , size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1
00135   , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
00136 {
00137   if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2))
00138     TEUCHOS_TEST_FOR_EXCEPTION(
00139       true, std::length_error
00140       ,"Mp_MtM_assert_sizes(...) : The number of columns in"
00141       " m_rhs1 and the number of rows in m_rhs2 in the operation"
00142       " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
00143   if(rows(m_lhs_rows,m_lhs_cols,trans_lhs) != rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1))
00144     TEUCHOS_TEST_FOR_EXCEPTION(
00145       true, std::length_error
00146       ,"Mp_MtM_assert_sizes(...) : The number of rows in"
00147       " m_lhs and the number of rows in m_rhs1 in the operation"
00148       " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
00149   if(cols(m_lhs_rows,m_lhs_cols,trans_lhs) != cols(m_rhs2_rows,m_rhs2_cols,trans_rhs2))
00150     TEUCHOS_TEST_FOR_EXCEPTION(
00151       true, std::length_error
00152       ,"Mp_MtM_assert_sizes(...) : The number of columns in"
00153       " m_lhs and the number of columns in m_rhs1 in the operation"
00154       " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
00155 }
00156 
00157 #endif // LINALGPACK_CHECK_RHS_SIZES
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines