RTOpPack_print_sub_vector.cpp

Go to the documentation of this file.
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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-13079
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include "RTOpPack_print_sub_vector.hpp"
00030 #include "Teuchos_FancyOStream.hpp"
00031 
00032 std::ostream& RTOpPack::output(
00033   std::ostream& o_arg, const SubVector& v
00034   ,bool print_dim , bool newline
00035   )
00036 {
00037   Teuchos::RCP<Teuchos::FancyOStream> o = Teuchos::getFancyOStream(Teuchos::rcp(&o_arg,false));
00038   //Teuchos::OSTab tab(o);
00039   int w = o->width(0) - 1; // get the set width (minus 1 since a space is inserted)
00040   if( print_dim )
00041     *o << std::setw(0) << std::left << v.subDim() << std::endl << std::right;
00042   //*o << std::setiosflags(std::ios::left) << std::setw(0) << v.subDim() 
00043   //    << std::endl << std::setiosflags(std::ios::right);
00044   // RAB: 20030916: ToDo: Fix the above by hacking std::left and std::right in config header!
00045   const RTOp_value_type  *v_val        = v.values();
00046   const ptrdiff_t        v_val_s       = v.stride();
00047   for( RTOp_index_type i = 1; i <= v.subDim(); ++i, v_val+=v_val_s ) {
00048     // insert a space to be sure there is white space
00049     // inbetween adjacent elements.
00050     *o << " " << std::setw(w) << (*v_val) << ":" << i + v.globalOffset();
00051   }
00052   if(newline) *o << std::endl;
00053   return o_arg;
00054 }

Generated on Wed May 12 21:52:32 2010 for MOOCHO (Single Doxygen Collection) by  doxygen 1.4.7