MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_MatrixZero.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 <assert.h>
43 
47 #include "Teuchos_Assert.hpp"
48 
49 namespace AbstractLinAlgPack {
50 
51 // Constructors/initializers
52 
54  const VectorSpace::space_ptr_t& space_cols
55  ,const VectorSpace::space_ptr_t& space_rows
56  )
57 {
58  this->initialize(space_cols,space_rows);
59 }
60 
62  const VectorSpace::space_ptr_t& space_cols
63  ,const VectorSpace::space_ptr_t& space_rows
64  )
65 {
67  (space_cols.get() == NULL && space_rows.get() != NULL)
68  || (space_cols.get() != NULL && space_rows.get() == NULL)
69  , std::invalid_argument
70  ,"MatrixZero::initialize(...) : Error, the space_cols.get() and "
71  "space_rows.get() must both be != NULL or == NULL" );
74 }
75 
76 // Overridden from MatrixBase
77 
79 {
80  return space_cols_.get() ? space_cols_->dim() : 0;
81 }
82 
84 {
85  return space_rows_.get() ? space_rows_->dim() : 0;
86 }
87 
89 {
90  return 0;
91 }
92 
93 // Overridden form MatrixOp
94 
96 {
98  return *space_cols_;
99 }
100 
102 {
104  return *space_rows_;
105 }
106 
108 {
110  // Automatically satisfied!
111 }
112 
114 {
116  // Automatically satisfied!
117 }
118 
120 {
122  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement!
123  return *this;
124 }
125 
126 std::ostream& MatrixZero::output(std::ostream& out) const
127 {
129  return out << "Zero matrix of dimension " << rows() << " x " << cols() << std::endl;
130 }
131 
132 // Level-1 BLAS
133 
135  MatrixOp* m_lhs, value_type alpha
136  , BLAS_Cpp::Transp trans_rhs) const
137 {
139  return true; // Nothing to do!
140 }
141 
143  MatrixOp* m_lhs, value_type alpha
144  , BLAS_Cpp::Transp M_trans
145  , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
146  ) const
147 {
149  return true; // Nothing to do!
150 }
151 
153  MatrixOp* m_lhs, value_type alpha
154  , const GenPermMatrixSlice& P_rhs, BLAS_Cpp::Transp P_rhs_trans
155  , BLAS_Cpp::Transp M_trans
156  ) const
157 {
159  return true; // Nothing to do!
160 }
161 
163  MatrixOp* m_lhs, value_type alpha
164  , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
165  , BLAS_Cpp::Transp M_trans
166  , const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans
167  ) const
168 {
170  return true; // Nothing to do!
171 }
172 
173 // Level-2 BLAS
174 
177  , const Vector& x, value_type b
178  ) const
179 {
181  Vt_S(y,b);
182 }
183 
185  VectorMutable* y, value_type alpha, BLAS_Cpp::Transp trans_rhs1
186  , const SpVectorSlice& x, value_type b) const
187 {
189  Vt_S(y,b);
190 }
191 
193  VectorMutable* y, value_type alpha
194  , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
195  , BLAS_Cpp::Transp M_rhs2_trans
196  , const Vector& x, value_type b) const
197 {
199  Vt_S(y,b);
200 }
201 
203  VectorMutable* y, value_type alpha
204  , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
205  , BLAS_Cpp::Transp M_rhs2_trans
206  , const SpVectorSlice& x, value_type b) const
207 {
209  Vt_S(y,b);
210 }
211 
213  const Vector& v_rhs1, BLAS_Cpp::Transp trans_rhs2
214  , const Vector& v_rhs3) const
215 {
217  return 0.0; // Nothing to do!
218 }
219 
221  const SpVectorSlice& sv_rhs1, BLAS_Cpp::Transp trans_rhs2
222  , const SpVectorSlice& sv_rhs3) const
223 {
225  return 0.0; // Nothing to do!
226 }
227 
229  BLAS_Cpp::Transp M_trans, value_type alpha
230  , const GenPermMatrixSlice& P1, BLAS_Cpp::Transp P1_trans
231  , const GenPermMatrixSlice& P2, BLAS_Cpp::Transp P2_trans
232  , value_type beta, MatrixSymOp* sym_lhs ) const
233 {
235  sym_lhs->Mt_S(beta);
236 }
237 
238 // Level-3 BLAS
239 
241  MatrixOp* m_lhs, value_type alpha
242  , BLAS_Cpp::Transp trans_rhs1, const MatrixOp& mwo_rhs2
243  , BLAS_Cpp::Transp trans_rhs2, value_type beta) const
244 {
246  m_lhs->Mt_S(beta);
247  return true;
248 }
249 
251  MatrixOp* m_lhs, value_type alpha
252  , const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1
253  , BLAS_Cpp::Transp trans_rhs2, value_type beta ) const
254 {
256  m_lhs->Mt_S(beta);
257  return true;
258 }
259 
261  BLAS_Cpp::Transp M_trans, value_type alpha
262  , value_type beta, MatrixSymOp* sym_lhs ) const
263 {
265  sym_lhs->Mt_S(beta);
266  return true;
267 }
268 
269 // private
270 
273  space_cols_.get() == NULL, std::logic_error
274  ,"Error, the MatrixZero object has not been initialized!" );
275 }
276 
277 } // end namespace AbstractLinAlgPack
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
void syr2k(BLAS_Cpp::Transp M_trans, value_type alpha, const GenPermMatrixSlice &P1, BLAS_Cpp::Transp P1_trans, const GenPermMatrixSlice &P2, BLAS_Cpp::Transp P2_trans, value_type beta, MatrixSymOp *symwo_lhs) const
virtual void Mt_S(value_type alpha)
M_lhs *= alpha : Multiply a matrix by a scalar.
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void initialize(const VectorSpace::space_ptr_t &space_cols, const VectorSpace::space_ptr_t &space_rows)
Initialize (or initialize) given the columns and rows vector spaces.
friend void Mt_S(MatrixOp *mwo_lhs, value_type alpha)
T * get() const
value_type transVtMtV(const Vector &v_rhs1, BLAS_Cpp::Transp trans_rhs2, const Vector &v_rhs3) const
Interface adding operations specific for a symmetric matrix {abstract}.
std::ostream & output(std::ostream &out) const
Abstract interface for objects that represent a space for mutable coordinate vectors.
void Vp_StPtMtV(VectorMutable *vs_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, BLAS_Cpp::Transp M_rhs2_trans, const Vector &v_rhs3, value_type beta) const
std::ostream * out
const LAPACK_C_Decl::f_int & M
void Vp_StMtV(VectorMutable *vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta) const
Base class for all matrices that support basic matrix operations.
bool Mp_StM(MatrixOp *mwo_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs) const
bool Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans) const
Abstract interface for mutable coordinate vectors {abstract}.
MatrixZero(const VectorSpace::space_ptr_t &space_cols=Teuchos::null, const VectorSpace::space_ptr_t &space_rows=Teuchos::null)
Calls this->initalize()
bool syrk(BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs) const
bool Mp_StMtP(MatrixOp *mwo_lhs, value_type alpha, BLAS_Cpp::Transp M_trans, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans) const
bool Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
Transp
TRANS.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Concrete matrix type to represent general permutation (mapping) matrices.
bool Mp_StPtM(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs, BLAS_Cpp::Transp P_rhs_trans, BLAS_Cpp::Transp M_trans) const