|
ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization
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 // 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 <assert.h> 00043 00044 #include "ConstrainedOptPack_MatrixIdentConcatStd.hpp" 00045 #include "Teuchos_Assert.hpp" 00046 00047 namespace ConstrainedOptPack { 00048 00049 // Setup and representation access 00050 00051 MatrixIdentConcatStd::MatrixIdentConcatStd() 00052 { 00053 this->set_uninitialized(); 00054 } 00055 00056 void MatrixIdentConcatStd::initialize( 00057 const VectorSpace::space_ptr_t& space_cols 00058 ,const VectorSpace::space_ptr_t& space_rows 00059 ,ETopBottom top_or_bottom 00060 ,value_type alpha 00061 ,const D_ptr_t &D_ptr 00062 ,BLAS_Cpp::Transp D_trans 00063 ) 00064 { 00065 #ifdef TEUCHOS_DEBUG 00066 TEUCHOS_TEST_FOR_EXCEPTION( 00067 space_cols.get() == NULL, std::invalid_argument 00068 ,"MatrixIdentConcatStd::initialize(...): Error, " 00069 "space_cols.get() can not be NULL!" ); 00070 TEUCHOS_TEST_FOR_EXCEPTION( 00071 space_rows.get() == NULL, std::invalid_argument 00072 ,"MatrixIdentConcatStd::initialize(...): Error, " 00073 "space_rows.get() can not be NULL!" ); 00074 TEUCHOS_TEST_FOR_EXCEPTION( 00075 D_ptr.get() == NULL, std::invalid_argument 00076 ,"MatrixIdentConcatStd::initialize(...): Error, " 00077 "D_ptr.get() can not be NULL!" ); 00078 #endif 00079 const size_type 00080 D_rows = D_ptr->rows(), 00081 D_cols = D_ptr->cols(), 00082 opD_rows = BLAS_Cpp::rows( D_rows, D_cols, D_trans ), 00083 opD_cols = BLAS_Cpp::cols( D_rows, D_cols, D_trans ), 00084 rows = opD_rows + opD_cols; 00085 space_cols_ = space_cols; 00086 space_rows_ = space_rows; 00087 alpha_ = alpha; 00088 D_ptr_ = D_ptr; 00089 D_trans_ = D_trans; 00090 D_rng_ = top_or_bottom == TOP ? Range1D(1,opD_rows) : Range1D(opD_cols+1,rows); 00091 I_rng_ = top_or_bottom == TOP ? Range1D(opD_rows+1,rows) : Range1D(1,opD_cols); 00092 } 00093 00094 void MatrixIdentConcatStd::set_uninitialized() 00095 { 00096 namespace rcp = MemMngPack; 00097 space_cols_ = Teuchos::null; 00098 space_rows_ = Teuchos::null; 00099 alpha_ = 0.0; 00100 D_ptr_ = Teuchos::null; 00101 D_trans_ = BLAS_Cpp::no_trans; 00102 D_rng_ = Range1D::Invalid; 00103 I_rng_ = Range1D::Invalid; 00104 } 00105 00106 const MatrixIdentConcatStd::D_ptr_t& MatrixIdentConcatStd::D_ptr() const 00107 { 00108 return D_ptr_; 00109 } 00110 00111 // Overridden form MatrixIdentConcat 00112 00113 Range1D MatrixIdentConcatStd::D_rng() const 00114 { 00115 return D_rng_; 00116 } 00117 00118 Range1D MatrixIdentConcatStd::I_rng() const 00119 { 00120 return I_rng_; 00121 } 00122 00123 value_type MatrixIdentConcatStd::alpha() const 00124 { 00125 return alpha_; 00126 } 00127 00128 const MatrixOp& MatrixIdentConcatStd::D() const 00129 { 00130 return *D_ptr_; 00131 } 00132 00133 BLAS_Cpp::Transp MatrixIdentConcatStd::D_trans() const 00134 { 00135 return D_trans_; 00136 } 00137 00138 // Overridden from MatrixOp 00139 00140 const VectorSpace& MatrixIdentConcatStd::space_cols() const 00141 { 00142 return *space_cols_; 00143 } 00144 00145 const VectorSpace& MatrixIdentConcatStd::space_rows() const 00146 { 00147 return *space_rows_; 00148 } 00149 00150 MatrixOp& MatrixIdentConcatStd::operator=(const MatrixOp& m) 00151 { 00152 TEUCHOS_TEST_FOR_EXCEPT(true); // Finish! 00153 return *this; 00154 } 00155 00156 // private 00157 00158 void MatrixIdentConcatStd::assert_initialized() const { 00159 TEUCHOS_TEST_FOR_EXCEPTION( 00160 space_cols_.get() == NULL, std::logic_error 00161 ,"Error, the MatrixIdentConcatStd object has not been initialized!" ); 00162 } 00163 00164 } // end namespace ConstrainedOptPack
1.7.6.1