o_f_stream.C
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 // C++ includes 00021 00022 00023 // Local Includes 00024 #include "libmesh/o_f_stream.h" 00025 00026 /* 00027 * This class is only alive when iostream is broken 00028 */ 00029 #ifdef LIBMESH_BROKEN_IOSTREAM 00030 00031 00032 namespace libMesh 00033 { 00034 00035 00036 // the template for reals 00037 template <typename T> 00038 OFStream& OFStream::scientific (const sizetype w, 00039 const T r) 00040 { 00041 libmesh_assert_less (w, 30); 00042 char buf[30]; 00043 char format[8]; 00044 // form the format for r 00045 sprintf (format, "%%%de", w); 00046 // form string as desired 00047 sprintf (buf, format, r); 00048 *this << buf; 00049 return *this; 00050 } 00051 00052 00053 00054 // full specialization in case of complex numbers 00055 #if defined(LIBMESH_USE_COMPLEX_NUMBERS) 00056 00057 template <> 00058 OFStream& OFStream::scientific (const sizetype w, 00059 const Complex r) 00060 { 00061 libmesh_assert_less (w, 30); 00062 char buf[60]; 00063 char format[16]; 00064 // form the format for r 00065 sprintf (format, "%%%de %%%de", w, w); 00066 // form string as desired 00067 sprintf (buf, format, r.real(), r.imag()); 00068 *this << buf; 00069 return *this; 00070 } 00071 00072 #endif // if defined(LIBMESH_USE_COMPLEX_NUMBERS) 00073 00074 00075 00076 //-------------------------------------------------------------- 00077 // Explicit instantiations for reals 00078 template OFStream& OFStream::scientific (const sizetype w, 00079 const double r); 00080 00081 template OFStream& OFStream::scientific (const sizetype w, 00082 const float r); 00083 00084 } // namespace libMesh 00085 00086 00087 00088 #endif // ifdef LIBMESH_BROKEN_IOSTREAM
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: