MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseLinAlgPack_AssertOp.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #include <stdexcept>
43 #include <string>
44 
46 #include "Teuchos_Assert.hpp"
47 
48 #ifdef LINALGPACK_CHECK_RHS_SIZES
49 
51 {
53  v_lhs_size != v_rhs_size, std::length_error
54  ,"Vp_V_assert_sizes(...) : The sizes of v_lhs = " << v_lhs_size << " and v_rhs = " << v_rhs_size
55  << " in the operation v_lhs += op v_rhs do not match");
56 }
57 
59 {
61  v_rhs1_size != v_rhs2_size, std::length_error
62  ,"VopV_assert_sizes(...) : The sizes of v_rhs1 and v_rhs2 "
63  "in the operation v_rhs1 op v_rhs2 do not match");
64 }
65 
67  , size_type m_rhs_rows, size_type m_rhs_cols, BLAS_Cpp::Transp trans_rhs)
68 {
69  if( rows(m_lhs_rows,m_lhs_cols,trans_lhs) != rows(m_rhs_rows,m_rhs_cols,trans_rhs)
70  || cols(m_lhs_rows,m_lhs_cols,trans_lhs) != cols(m_rhs_rows,m_rhs_cols,trans_rhs) )
71  {
73  true, std::length_error
74  ,"Mp_M_assert_sizes(...) : The sizes of m_lhs and m_rhs "
75  "in the operation op(m_lhs) += op op(m_rhs) do not match");
76  }
77 }
78 
80  , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
81 {
82  if( rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2)
83  || cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != cols(m_rhs2_rows,m_rhs2_cols,trans_rhs2) )
84  {
86  true, std::length_error
87  ,"Mp_M_assert_sizes(...) : The sizes of m_rhs1 and m_rhs2 "
88  "in the operation op(m_rhs1) op op(m_rhs2) do not match");
89  }
90 }
91 
93  , BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
94 {
95  if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_rhs2_size)
97  true, std::length_error
98  ,"MtV_assert_sizes(...) : The number of columns in "
99  "m_rhs1 and the size of v_rhs2 in the operation v_lhs += op(m_rhs1) * v_rhs2 "
100  "do not match");
101 }
102 
104  , size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
105 {
106  if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_rhs2_size)
108  true, std::length_error
109  ,"Vp_MtV_assert_sizes(...) : The number of columns in"
110  " m_rhs1 and the size of v_rhs2 in the operation v_lhs += op(m_rhs1) * v_rhs2"
111  " do not match");
112  if(rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != v_lhs_size)
114  true, std::length_error
115  ,"Vp_MtV_assert_sizes(...) : The number of rows in"
116  " m_rhs1 and the size of v_lhs in the operation v_lhs += op(m_rhs1) * v_rhs2"
117  " do not match");
118 }
119 
121  size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1
122  , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
123 {
124  if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2))
126  true, std::length_error
127  ,"MtM_assert_sizes(...) : The number of columns in"
128  " m_rhs1 and the number of rows in m_rhs2 in the operation"
129  " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
130 }
131 
133  size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs
134  , size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1
135  , size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
136 {
137  if(cols(m_rhs1_rows,m_rhs1_cols,trans_rhs1) != rows(m_rhs2_rows,m_rhs2_cols,trans_rhs2))
139  true, std::length_error
140  ,"Mp_MtM_assert_sizes(...) : The number of columns in"
141  " m_rhs1 and the number of rows in m_rhs2 in the operation"
142  " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
143  if(rows(m_lhs_rows,m_lhs_cols,trans_lhs) != rows(m_rhs1_rows,m_rhs1_cols,trans_rhs1))
145  true, std::length_error
146  ,"Mp_MtM_assert_sizes(...) : The number of rows in"
147  " m_lhs and the number of rows in m_rhs1 in the operation"
148  " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
149  if(cols(m_lhs_rows,m_lhs_cols,trans_lhs) != cols(m_rhs2_rows,m_rhs2_cols,trans_rhs2))
151  true, std::length_error
152  ,"Mp_MtM_assert_sizes(...) : The number of columns in"
153  " m_lhs and the number of columns in m_rhs1 in the operation"
154  " op(m_lhs) += op(m_rhs1) * op(m_rhs2) do not match");
155 }
156 
157 #endif // LINALGPACK_CHECK_RHS_SIZES
Teuchos::Ordinal size_type
Typedef for the size type of elements that are used by the library.
void MtM_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
op(m_lhs) += op(m_rhs1)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
void Mp_MtM_assert_sizes(size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs, size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
op(m_lhs) += op(m_rhs1) * op(m_rhs2)
void Mp_M_assert_sizes(size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs, size_type m_rhs_rows, size_type m_rhs_cols, BLAS_Cpp::Transp trans_rhs)
op(m_lhs) += op op(m_rhs)
void MopM_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
v_rhs1 op v_rhs2
void Vp_V_assert_sizes(size_type v_lhs_size, size_type v_rhs_size)
v_lhs += op v_rhs
void VopV_assert_sizes(size_type v_rhs1_size, size_type v_rhs2_size)
v_rhs1 op v_rhs2
void Vp_MtV_assert_sizes(size_type v_lhs_size, size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
v_lhs += op(m_rhs1) * v_rhs2
void MtV_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
op(m_rhs1) * v_rhs2
Transp
TRANS.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.