|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects
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 "AbstractLinAlgPack_VectorAuxiliaryOps.hpp" 00045 #include "AbstractLinAlgPack_VectorMutable.hpp" 00046 #include "RTOp_ROp_max.h" 00047 #include "RTOp_ROp_max_near_feas_step.h" 00048 #include "RTOp_ROp_max_rel_step.h" 00049 #include "RTOp_ROp_num_bounded.h" 00050 #include "RTOp_ROp_combined_nu_comp_err.h" 00051 #include "RTOp_ROp_comp_err_with_mu.h" 00052 #include "RTOp_ROp_fraction_to_boundary.h" 00053 #include "RTOp_ROp_fraction_to_zero_boundary.h" 00054 #include "RTOp_ROp_log_bound_barrier.h" 00055 #include "RTOp_TOp_correct_multipliers.h" 00056 #include "RTOp_ROp_max_inequ_viol.h" 00057 #include "RTOp_TOp_multiplier_step.h" 00058 #include "RTOp_TOp_force_in_bounds.h" 00059 #include "RTOp_TOp_ele_wise_sqrt.h" 00060 #include "RTOp_TOp_inv_of_difference.h" 00061 #include "RTOp_TOp_max_vec_scalar.h" 00062 #include "RTOp_TOp_max_abs_vec_scalar.h" 00063 #include "RTOpPack_RTOpC.hpp" 00064 #include "Teuchos_Assert.hpp" 00065 00066 namespace { 00067 00068 // log_bound_barrier 00069 static RTOpPack::RTOpC log_bound_barrier_op; 00070 static Teuchos::RCP<RTOpPack::ReductTarget> log_bound_barrier_targ; 00071 // combined_nu_comp_err 00072 static RTOpPack::RTOpC combined_nu_comp_err_op; 00073 static Teuchos::RCP<RTOpPack::ReductTarget> combined_nu_comp_err_targ; 00074 // combined_nu_comp_err_lower 00075 static RTOpPack::RTOpC combined_nu_comp_err_lower_op; 00076 static Teuchos::RCP<RTOpPack::ReductTarget> combined_nu_comp_err_lower_targ; 00077 // combined_nu_comp_err_upper 00078 static RTOpPack::RTOpC combined_nu_comp_err_upper_op; 00079 static Teuchos::RCP<RTOpPack::ReductTarget> combined_nu_comp_err_upper_targ; 00080 // comp_err_with_mu 00081 static RTOpPack::RTOpC comp_err_with_mu_op; 00082 static Teuchos::RCP<RTOpPack::ReductTarget> comp_err_with_mu_targ; 00083 // maximum near feasible step 00084 static RTOpPack::RTOpC max_near_feas_step_op; 00085 static Teuchos::RCP<RTOpPack::ReductTarget> max_near_feas_step_targ; 00086 // fraction to boundary rule 00087 static RTOpPack::RTOpC fraction_to_boundary_op; 00088 static Teuchos::RCP<RTOpPack::ReductTarget> fraction_to_boundary_targ; 00089 // fraction to zero boundary rule 00090 static RTOpPack::RTOpC fraction_to_zero_boundary_op; 00091 static Teuchos::RCP<RTOpPack::ReductTarget> fraction_to_zero_boundary_targ; 00092 // maximum relative step 00093 static RTOpPack::RTOpC max_rel_step_op; 00094 static Teuchos::RCP<RTOpPack::ReductTarget> max_rel_step_targ; 00095 // number of bounded elements 00096 static RTOpPack::RTOpC num_bounded_op; 00097 static Teuchos::RCP<RTOpPack::ReductTarget> num_bounded_targ; 00098 // force in bounds 00099 static RTOpPack::RTOpC force_in_bounds_op; 00100 // force in bounds with buffer 00101 static RTOpPack::RTOpC force_in_bounds_buffer_op; 00102 // inv_of_difference 00103 static RTOpPack::RTOpC inv_of_difference_op; 00104 // correct_multipliers 00105 static RTOpPack::RTOpC correct_lower_bound_multipliers_op; 00106 static RTOpPack::RTOpC correct_upper_bound_multipliers_op; 00107 // multipliers step 00108 static RTOpPack::RTOpC lowerbound_multipliers_step_op; 00109 static RTOpPack::RTOpC upperbound_multipliers_step_op; 00110 // element wise square root 00111 static RTOpPack::RTOpC ele_wise_sqrt_op; 00112 00113 // Simple class for an object that will initialize the RTOp_Server. 00114 class init_rtop_server_t { 00115 public: 00116 init_rtop_server_t() { 00117 // Operator and target obj for log_bound_barrier 00118 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_log_bound_barrier_construct(&log_bound_barrier_op.op())); 00119 log_bound_barrier_targ = log_bound_barrier_op.reduct_obj_create(); 00120 // Operator and target obj for combined_nu_comp_err 00121 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_combined_nu_comp_err_construct(&combined_nu_comp_err_op.op())); 00122 combined_nu_comp_err_targ = combined_nu_comp_err_op.reduct_obj_create(); 00123 // Operator and target obj for combined_nu_comp_err_lower 00124 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_combined_nu_comp_err_one_only_construct(&combined_nu_comp_err_lower_op.op())); 00125 combined_nu_comp_err_lower_targ = combined_nu_comp_err_lower_op.reduct_obj_create(); 00126 // Operator and target obj for combined_nu_comp_err_upper 00127 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_combined_nu_comp_err_one_only_construct(&combined_nu_comp_err_upper_op.op())); 00128 combined_nu_comp_err_upper_targ = combined_nu_comp_err_upper_op.reduct_obj_create(); 00129 // Operator and target obj for comp_err_with_mu 00130 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_comp_err_with_mu_construct(0.0,0.0,&comp_err_with_mu_op.op())); 00131 comp_err_with_mu_targ = comp_err_with_mu_op.reduct_obj_create(); 00132 // Operator and target obj for max_near_feas_step 00133 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_max_near_feas_step_construct(0.0,&max_near_feas_step_op.op())); 00134 max_near_feas_step_targ = max_near_feas_step_op.reduct_obj_create(); 00135 // Operator and target obj for max_rel_step 00136 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_max_rel_step_construct(&max_rel_step_op.op())); 00137 max_rel_step_targ = max_rel_step_op.reduct_obj_create(); 00138 // Operator and target obj for fraction to boundary 00139 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_fraction_to_boundary_construct(0.99,&fraction_to_boundary_op.op())); 00140 fraction_to_boundary_targ = fraction_to_boundary_op.reduct_obj_create(); 00141 // Operator and target obj for fraction to zero boundary 00142 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_fraction_to_zero_boundary_construct(0.99,&fraction_to_zero_boundary_op.op())); 00143 fraction_to_zero_boundary_targ = fraction_to_zero_boundary_op.reduct_obj_create(); 00144 // Operator and target obj for num_bounded 00145 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_num_bounded_construct(0.0,&num_bounded_op.op())); 00146 num_bounded_targ = num_bounded_op.reduct_obj_create(); 00147 // Operator force_in_bounds 00148 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_force_in_bounds_construct( &force_in_bounds_op.op() )); 00149 // Operator force_in_bounds_buffer 00150 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_force_in_bounds_buffer_construct( 0.01, 0.001, &force_in_bounds_buffer_op.op() )); 00151 // Operator inv_of_difference 00152 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_inv_of_difference_construct( 1.0, &inv_of_difference_op.op())); 00153 // correct_lower_bounds_multipliers 00154 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_Correct_Multipliers_construct( -1e50, 0, &correct_lower_bound_multipliers_op.op())); 00155 // correct_upper_bounds_multipliers 00156 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_Correct_Multipliers_construct( 1e50, 1, &correct_upper_bound_multipliers_op.op())); 00157 // lower_bounds_multipliers step 00158 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_multiplier_step_construct( 1.0, -1.0, &lowerbound_multipliers_step_op.op())); 00159 // upper_bounds_multipliers step 00160 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_multiplier_step_construct( 1.0, 1.0, &upperbound_multipliers_step_op.op())); 00161 // ele_wise_sqrt 00162 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_ele_wise_sqrt_construct( &ele_wise_sqrt_op.op())); 00163 } 00164 }; 00165 00166 // When the program starts, this object will be created and the RTOp_Server object will 00167 // be initialized before main() gets underway! 00168 init_rtop_server_t init_rtop_server; 00169 00170 } // end namespace 00171 00172 AbstractLinAlgPack::value_type 00173 AbstractLinAlgPack::max_element( const Vector& v ) 00174 { 00175 RTOpPack::RTOpC op; 00176 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_max_construct(&op.op())); 00177 Teuchos::RCP<RTOpPack::ReductTarget> reduct_obj = op.reduct_obj_create(); 00178 const Vector* vecs[1] = { &v }; 00179 apply_op(op,1,vecs,0,NULL,&*reduct_obj); 00180 return RTOp_ROp_max_val(op(*reduct_obj)); 00181 } 00182 00183 std::pair<AbstractLinAlgPack::value_type,AbstractLinAlgPack::value_type> 00184 AbstractLinAlgPack::max_near_feas_step( 00185 const Vector& x, const Vector& d 00186 ,const Vector& xl, const Vector& xu 00187 ,value_type max_bnd_viol 00188 ) 00189 { 00190 const int num_vecs = 4; 00191 const Vector* 00192 vecs[num_vecs] = { &xl, &x, &d, &xu }; 00193 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_max_near_feas_step_set_beta( max_bnd_viol, &max_near_feas_step_op.op() )); 00194 max_near_feas_step_op.reduct_obj_reinit(max_near_feas_step_targ.ptr()); 00195 apply_op( 00196 max_near_feas_step_op, num_vecs, vecs, 0, NULL 00197 ,&*max_near_feas_step_targ ); 00198 RTOp_ROp_max_near_feas_step_reduct_obj_t 00199 u = RTOp_ROp_max_near_feas_step_val(max_near_feas_step_op(*max_near_feas_step_targ));; 00200 return std::pair<value_type,value_type>(u.alpha_pos,u.alpha_neg); 00201 } 00202 00203 AbstractLinAlgPack::value_type 00204 AbstractLinAlgPack::max_rel_step( 00205 const Vector& x, const Vector& d 00206 ) 00207 { 00208 const int num_vecs = 2; 00209 const Vector* 00210 vecs[num_vecs] = { &x, &d }; 00211 max_rel_step_op.reduct_obj_reinit(max_rel_step_targ.ptr()); 00212 apply_op( 00213 max_rel_step_op, num_vecs, vecs, 0, NULL 00214 ,&*max_rel_step_targ ); 00215 return RTOp_ROp_max_rel_step_val(max_rel_step_op(*max_rel_step_targ)); 00216 } 00217 00218 00219 AbstractLinAlgPack::value_type 00220 AbstractLinAlgPack::fraction_to_boundary( 00221 const value_type tau, 00222 const Vector& x, 00223 const Vector& d, 00224 const Vector& xl, 00225 const Vector& xu 00226 ) 00227 { 00228 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_fraction_to_boundary_init( tau, &fraction_to_boundary_op.op() )); 00229 fraction_to_boundary_op.reduct_obj_reinit(fraction_to_boundary_targ.ptr()); 00230 const int num_vecs = 4; 00231 const Vector* 00232 vecs[num_vecs] = { &x, &d, &xl, &xu }; 00233 apply_op( 00234 fraction_to_boundary_op, num_vecs, vecs, 0, NULL 00235 ,&*fraction_to_boundary_targ ); 00236 return RTOp_ROp_fraction_to_boundary_val(fraction_to_boundary_op(*fraction_to_boundary_targ)); 00237 } 00238 00239 AbstractLinAlgPack::value_type 00240 AbstractLinAlgPack::fraction_to_zero_boundary( 00241 const value_type tau, 00242 const Vector& x, 00243 const Vector& d 00244 ) 00245 { 00246 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_fraction_to_zero_boundary_init( tau, &fraction_to_zero_boundary_op.op() )); 00247 fraction_to_zero_boundary_op.reduct_obj_reinit(fraction_to_zero_boundary_targ.ptr()); 00248 const int num_vecs = 2; 00249 const Vector* 00250 vecs[num_vecs] = { &x, &d }; 00251 apply_op( 00252 fraction_to_zero_boundary_op, num_vecs, vecs, 0, NULL 00253 ,&*fraction_to_zero_boundary_targ ); 00254 return RTOp_ROp_fraction_to_zero_boundary_val(fraction_to_zero_boundary_op(*fraction_to_zero_boundary_targ)); 00255 } 00256 00257 AbstractLinAlgPack::size_type 00258 AbstractLinAlgPack:: num_bounded( 00259 const Vector& xl, const Vector& xu 00260 ,value_type inf_bound 00261 ) 00262 { 00263 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_num_bounded_set_inf_bnd( inf_bound, &num_bounded_op.op() )); 00264 num_bounded_op.reduct_obj_reinit(num_bounded_targ.ptr()); 00265 const int num_vecs = 2; 00266 const Vector* 00267 vecs[num_vecs] = { &xl, &xu }; 00268 apply_op( 00269 num_bounded_op, num_vecs, vecs, 0, NULL 00270 ,&*num_bounded_targ ); 00271 return RTOp_ROp_num_bounded_val(num_bounded_op(*num_bounded_targ)); 00272 } 00273 00274 AbstractLinAlgPack::value_type 00275 AbstractLinAlgPack::log_bound_barrier( 00276 const Vector &x 00277 ,const Vector &xl 00278 ,const Vector &xu 00279 ) 00280 { 00281 log_bound_barrier_op.reduct_obj_reinit(log_bound_barrier_targ.ptr()); 00282 const int num_vecs = 3; 00283 const Vector* 00284 vecs[num_vecs] = { &x, &xl, &xu }; 00285 apply_op( 00286 log_bound_barrier_op, num_vecs, vecs, 0, NULL 00287 ,&*log_bound_barrier_targ 00288 ); 00289 00290 return RTOp_ROp_log_bound_barrier_val(log_bound_barrier_op(*log_bound_barrier_targ)); 00291 } 00292 00293 AbstractLinAlgPack::value_type 00294 AbstractLinAlgPack::combined_nu_comp_err( 00295 const Vector &v 00296 ,const Vector &x 00297 ,const Vector &xl 00298 ,const Vector &xu 00299 ) 00300 { 00301 combined_nu_comp_err_op.reduct_obj_reinit(combined_nu_comp_err_targ.ptr()); 00302 const int num_vecs = 4; 00303 const Vector* 00304 vecs[num_vecs] = {&v, &x, &xl, &xu }; 00305 apply_op( 00306 combined_nu_comp_err_op, num_vecs, vecs, 0, NULL 00307 ,&*combined_nu_comp_err_targ 00308 ); 00309 return RTOp_ROp_combined_nu_comp_err_val(combined_nu_comp_err_op(*combined_nu_comp_err_targ)); 00310 } 00311 00312 AbstractLinAlgPack::value_type 00313 AbstractLinAlgPack::combined_nu_comp_err_lower( 00314 const Vector &v 00315 ,const Vector &x 00316 ,const Vector &xl 00317 ) 00318 { 00319 combined_nu_comp_err_lower_op.reduct_obj_reinit(combined_nu_comp_err_lower_targ.ptr()); 00320 const int num_vecs = 3; 00321 const Vector* 00322 vecs[num_vecs] = {&v, &xl, &x}; 00323 apply_op( 00324 combined_nu_comp_err_lower_op, num_vecs, vecs, 0, NULL 00325 ,&*combined_nu_comp_err_lower_targ 00326 ); 00327 return RTOp_ROp_combined_nu_comp_err_one_only_val(combined_nu_comp_err_lower_op(*combined_nu_comp_err_lower_targ)); 00328 } 00329 00330 00331 AbstractLinAlgPack::value_type 00332 AbstractLinAlgPack::combined_nu_comp_err_upper( 00333 const Vector &v 00334 ,const Vector &x 00335 ,const Vector &xu 00336 ) 00337 { 00338 combined_nu_comp_err_upper_op.reduct_obj_reinit(combined_nu_comp_err_upper_targ.ptr()); 00339 const int num_vecs = 3; 00340 const Vector* 00341 vecs[num_vecs] = {&v, &xu, &x}; 00342 apply_op( 00343 combined_nu_comp_err_upper_op, num_vecs, vecs, 0, NULL 00344 ,&*combined_nu_comp_err_upper_targ 00345 ); 00346 return RTOp_ROp_combined_nu_comp_err_one_only_val(combined_nu_comp_err_upper_op(*combined_nu_comp_err_upper_targ)); 00347 } 00348 00349 AbstractLinAlgPack::value_type 00350 AbstractLinAlgPack::IP_comp_err_with_mu( 00351 const value_type mu 00352 ,const value_type inf_bound 00353 ,const Vector &x 00354 ,const Vector &xl 00355 ,const Vector &xu 00356 ,const Vector &vl 00357 ,const Vector &vu 00358 ) 00359 { 00360 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_comp_err_with_mu_init(mu, inf_bound, &comp_err_with_mu_op.op())); 00361 comp_err_with_mu_op.reduct_obj_reinit(comp_err_with_mu_targ.ptr()); 00362 const int num_vecs = 5; 00363 const Vector* 00364 vecs[num_vecs] = {&x, &xl, &xu, &vl, &vu}; 00365 apply_op( 00366 comp_err_with_mu_op, num_vecs, vecs, 0, NULL 00367 ,&*comp_err_with_mu_targ 00368 ); 00369 return RTOp_ROp_comp_err_with_mu_val(comp_err_with_mu_op(*comp_err_with_mu_targ)); 00370 } 00371 00372 bool AbstractLinAlgPack::max_inequ_viol( 00373 const AbstractLinAlgPack::Vector &v 00374 ,const AbstractLinAlgPack::Vector &vL 00375 ,const AbstractLinAlgPack::Vector &vU 00376 ,AbstractLinAlgPack::size_type *max_viol_i 00377 ,AbstractLinAlgPack::value_type *max_viol 00378 ,AbstractLinAlgPack::value_type *v_i 00379 ,int *bnd_type 00380 ,AbstractLinAlgPack::value_type *vLU_i 00381 ) 00382 { 00383 RTOpPack::RTOpC op; 00384 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_ROp_max_inequ_viol_construct(&op.op())); 00385 Teuchos::RCP<RTOpPack::ReductTarget> reduct_obj = op.reduct_obj_create(); 00386 const int num_vecs = 3; 00387 const Vector* 00388 vecs[num_vecs] = { &v, &vL, &vU }; 00389 apply_op( 00390 op, num_vecs, vecs, 0, NULL 00391 ,&*reduct_obj 00392 ); 00393 const RTOp_ROp_max_inequ_viol_reduct_obj_t 00394 ro = RTOp_ROp_max_inequ_viol_val(op(*reduct_obj)); 00395 *max_viol_i = ro.max_viol_i; 00396 *max_viol = ro.max_viol; 00397 *v_i = ro.v_i; 00398 *bnd_type = ro.bnd_type; 00399 *vLU_i = ro.vLU_i; 00400 return *max_viol_i > 0.0; 00401 } 00402 00403 void AbstractLinAlgPack::force_in_bounds( 00404 const Vector& xl, const Vector& xu 00405 ,VectorMutable* x 00406 ) 00407 { 00408 #ifdef TEUCHOS_DEBUG 00409 TEUCHOS_TEST_FOR_EXCEPTION(x==NULL,std::logic_error,"force_in_bounds(...), Error"); 00410 #endif 00411 const Vector* vecs[2] = { &xl, &xu }; 00412 VectorMutable* targ_vecs[1] = { x }; 00413 apply_op(force_in_bounds_op,2,vecs,1,targ_vecs,NULL); 00414 } 00415 00416 00417 void AbstractLinAlgPack::force_in_bounds_buffer( 00418 const value_type rel_push, 00419 const value_type abs_push, 00420 const Vector& xl, 00421 const Vector& xu, 00422 VectorMutable* x 00423 ) 00424 { 00425 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_force_in_bounds_buffer_init( rel_push, abs_push, &force_in_bounds_buffer_op.op())); 00426 const Vector* vecs[2] = { &xl, &xu }; 00427 VectorMutable* targ_vecs[1] = { x }; 00428 apply_op(force_in_bounds_buffer_op,2,vecs,1,targ_vecs,NULL); 00429 } 00430 00431 00432 void AbstractLinAlgPack::inv_of_difference( 00433 const value_type alpha 00434 ,const Vector &v0 00435 ,const Vector &v1 00436 ,VectorMutable *z 00437 ) 00438 { 00439 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_inv_of_difference_init( alpha, &inv_of_difference_op.op())); 00440 const Vector* vecs[2] = { &v0, &v1 }; 00441 VectorMutable* targ_vecs[1] = { z }; 00442 apply_op(inv_of_difference_op,2,vecs,1,targ_vecs,NULL); 00443 } 00444 00445 void AbstractLinAlgPack::correct_lower_bound_multipliers( 00446 const Vector &xl 00447 ,const value_type inf_bound_limit 00448 ,VectorMutable *vl 00449 ) 00450 { 00451 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_Correct_Multipliers_init( inf_bound_limit, 0, &correct_lower_bound_multipliers_op.op())) 00452 const Vector* vecs[1] = { &xl }; 00453 VectorMutable* targ_vecs[1] = { vl }; 00454 apply_op(correct_lower_bound_multipliers_op,1,vecs,1,targ_vecs,NULL); 00455 } 00456 00457 void AbstractLinAlgPack::correct_upper_bound_multipliers( 00458 const Vector &xu 00459 ,const value_type inf_bound_limit 00460 ,VectorMutable *vu 00461 ) 00462 { 00463 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_Correct_Multipliers_init( inf_bound_limit, 1, &correct_upper_bound_multipliers_op.op())); 00464 const Vector* vecs[1] = { &xu }; 00465 VectorMutable* targ_vecs[1] = { vu }; 00466 apply_op(correct_upper_bound_multipliers_op,1,vecs,1,targ_vecs,NULL); 00467 } 00468 00469 void AbstractLinAlgPack::lowerbound_multipliers_step( 00470 const value_type mu, 00471 const Vector& invXl, 00472 const Vector& vl, 00473 const Vector& d_k, 00474 VectorMutable* dvl_k 00475 ) 00476 { 00477 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_multiplier_step_init(mu, -1.0, &lowerbound_multipliers_step_op.op())); 00478 const Vector* vecs[] = { &invXl, &vl, &d_k }; 00479 VectorMutable* targ_vecs[] = { dvl_k }; 00480 apply_op(lowerbound_multipliers_step_op,3,vecs,1,targ_vecs,NULL); 00481 } 00482 00483 void AbstractLinAlgPack::upperbound_multipliers_step( 00484 const value_type mu, 00485 const Vector& invXu, 00486 const Vector& vu, 00487 const Vector& d_k, 00488 VectorMutable* dvu_k 00489 ) 00490 { 00491 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_multiplier_step_init(mu, 1.0, &upperbound_multipliers_step_op.op())); 00492 const Vector* vecs[] = { &invXu, &vu, &d_k }; 00493 VectorMutable* targ_vecs[] = { dvu_k }; 00494 apply_op(upperbound_multipliers_step_op,3,vecs,1,targ_vecs,NULL); 00495 } 00496 00497 void AbstractLinAlgPack::ele_wise_sqrt( 00498 VectorMutable* z 00499 ) 00500 { 00501 VectorMutable* targ_vecs[] = { z }; 00502 apply_op(ele_wise_sqrt_op,0,NULL,1,targ_vecs,NULL); 00503 } 00504 00505 void AbstractLinAlgPack::max_vec_scalar( 00506 value_type min_ele 00507 ,VectorMutable *y 00508 ) 00509 { 00510 RTOpPack::RTOpC op; 00511 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_max_vec_scalar_construct(min_ele,&op.op())); 00512 VectorMutable* targ_vecs[] = { y }; 00513 apply_op(op,0,NULL,1,targ_vecs,NULL); 00514 } 00515 00516 void AbstractLinAlgPack::max_abs_vec_scalar( 00517 value_type min_ele 00518 ,VectorMutable *y 00519 ) 00520 { 00521 RTOpPack::RTOpC op; 00522 TEUCHOS_TEST_FOR_EXCEPT(0!=RTOp_TOp_max_abs_vec_scalar_construct(min_ele,&op.op())); 00523 VectorMutable* targ_vecs[] = { y }; 00524 apply_op(op,0,NULL,1,targ_vecs,NULL); 00525 }
1.7.6.1