cmath.tcc

Go to the documentation of this file.
00001 // -*- C++ -*- C math library.
00002 
00003 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 3, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // Under Section 7 of GPL version 3, you are granted additional
00018 // permissions described in the GCC Runtime Library Exception, version
00019 // 3.1, as published by the Free Software Foundation.
00020 
00021 // You should have received a copy of the GNU General Public License and
00022 // a copy of the GCC Runtime Library Exception along with this program;
00023 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00024 // <http://www.gnu.org/licenses/>.
00025 
00026 // This file was written by Gabriel Dos Reis <gdr@codesourcery.com>
00027 
00028 /** @file cmath.tcc
00029  *  This is a Standard C++ Library file.
00030  */
00031 
00032 #ifndef _GLIBCXX_CMATH_TCC
00033 #define _GLIBCXX_CMATH_TCC 1
00034 
00035 _GLIBCXX_BEGIN_NAMESPACE(std)
00036 
00037   template<typename _Tp>
00038     inline _Tp
00039     __cmath_power(_Tp __x, unsigned int __n)
00040     {
00041       _Tp __y = __n % 2 ? __x : _Tp(1);
00042 
00043       while (__n >>= 1)
00044         {
00045           __x = __x * __x;
00046           if (__n % 2)
00047             __y = __y * __x;
00048         }
00049 
00050       return __y;
00051     }
00052 
00053 _GLIBCXX_END_NAMESPACE
00054 
00055 #endif

Generated on Thu Jul 23 21:16:02 2009 for libstdc++ by  doxygen 1.5.8