MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstrainedOptPack_MatrixIdentConcatStd.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 
45 #include "Teuchos_Assert.hpp"
46 
47 namespace ConstrainedOptPack {
48 
49 // Setup and representation access
50 
52 {
53  this->set_uninitialized();
54 }
55 
57  const VectorSpace::space_ptr_t& space_cols
58  ,const VectorSpace::space_ptr_t& space_rows
59  ,ETopBottom top_or_bottom
60  ,value_type alpha
61  ,const D_ptr_t &D_ptr
62  ,BLAS_Cpp::Transp D_trans
63  )
64 {
65 #ifdef TEUCHOS_DEBUG
67  space_cols.get() == NULL, std::invalid_argument
68  ,"MatrixIdentConcatStd::initialize(...): Error, "
69  "space_cols.get() can not be NULL!" );
71  space_rows.get() == NULL, std::invalid_argument
72  ,"MatrixIdentConcatStd::initialize(...): Error, "
73  "space_rows.get() can not be NULL!" );
75  D_ptr.get() == NULL, std::invalid_argument
76  ,"MatrixIdentConcatStd::initialize(...): Error, "
77  "D_ptr.get() can not be NULL!" );
78 #endif
79  const size_type
80  D_rows = D_ptr->rows(),
81  D_cols = D_ptr->cols(),
82  opD_rows = BLAS_Cpp::rows( D_rows, D_cols, D_trans ),
83  opD_cols = BLAS_Cpp::cols( D_rows, D_cols, D_trans ),
84  rows = opD_rows + opD_cols;
85  space_cols_ = space_cols;
86  space_rows_ = space_rows;
87  alpha_ = alpha;
88  D_ptr_ = D_ptr;
89  D_trans_ = D_trans;
90  D_rng_ = top_or_bottom == TOP ? Range1D(1,opD_rows) : Range1D(opD_cols+1,rows);
91  I_rng_ = top_or_bottom == TOP ? Range1D(opD_rows+1,rows) : Range1D(1,opD_cols);
92 }
93 
95 {
96  namespace rcp = MemMngPack;
97  space_cols_ = Teuchos::null;
98  space_rows_ = Teuchos::null;
99  alpha_ = 0.0;
100  D_ptr_ = Teuchos::null;
102  D_rng_ = Range1D::Invalid;
103  I_rng_ = Range1D::Invalid;
104 }
105 
107 {
108  return D_ptr_;
109 }
110 
111 // Overridden form MatrixIdentConcat
112 
114 {
115  return D_rng_;
116 }
117 
119 {
120  return I_rng_;
121 }
122 
124 {
125  return alpha_;
126 }
127 
128 const MatrixOp& MatrixIdentConcatStd::D() const
129 {
130  return *D_ptr_;
131 }
132 
134 {
135  return D_trans_;
136 }
137 
138 // Overridden from MatrixOp
139 
140 const VectorSpace& MatrixIdentConcatStd::space_cols() const
141 {
142  return *space_cols_;
143 }
144 
145 const VectorSpace& MatrixIdentConcatStd::space_rows() const
146 {
147  return *space_rows_;
148 }
149 
150 MatrixOp& MatrixIdentConcatStd::operator=(const MatrixOp& m)
151 {
152  TEUCHOS_TEST_FOR_EXCEPT(true); // Finish!
153  return *this;
154 }
155 
156 // private
157 
160  space_cols_.get() == NULL, std::logic_error
161  ,"Error, the MatrixIdentConcatStd object has not been initialized!" );
162 }
163 
164 } // end namespace ConstrainedOptPack
const VectorSpace & space_cols() const
AbstractLinAlgPack::size_type size_type
#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.
T * get() const
Not transposed.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MatrixOp & operator=(const MatrixOp &m)
The default just performs a shallow copy and just copies the underlying smart reference counted point...
const VectorSpace & space_rows() const
AbstractLinAlgPack::value_type value_type
virtual void initialize(const VectorSpace::space_ptr_t &space_cols, const VectorSpace::space_ptr_t &space_rows, ETopBottom top_or_bottom, value_type alpha, const D_ptr_t &D_ptr, BLAS_Cpp::Transp D_trans)
Setup with a matrix object.
virtual const D_ptr_t & D_ptr() const
Return the smart reference counted point to the D matrix.
Transp
TRANS.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
virtual void set_uninitialized()
Set the matrix to uninitialized.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)