![]() |
|
|||
File indexing completed on 2025-04-19 09:13:36
0001 /*=====================================================================* 0002 * Copyright (C) 2011 Paul Mineiro * 0003 * All rights reserved. * 0004 * * 0005 * Redistribution and use in source and binary forms, with * 0006 * or without modification, are permitted provided that the * 0007 * following conditions are met: * 0008 * * 0009 * * Redistributions of source code must retain the * 0010 * above copyright notice, this list of conditions and * 0011 * the following disclaimer. * 0012 * * 0013 * * Redistributions in binary form must reproduce the * 0014 * above copyright notice, this list of conditions and * 0015 * the following disclaimer in the documentation and/or * 0016 * other materials provided with the distribution. * 0017 * * 0018 * * Neither the name of Paul Mineiro nor the names * 0019 * of other contributors may be used to endorse or promote * 0020 * products derived from this software without specific * 0021 * prior written permission. * 0022 * * 0023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 0024 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * 0025 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * 0026 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * 0027 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * 0028 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 0029 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * 0030 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * 0031 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 0032 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 0033 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 0034 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 0035 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * 0036 * POSSIBILITY OF SUCH DAMAGE. * 0037 * * 0038 * Contact: Paul Mineiro <paul@mineiro.com> * 0039 *=====================================================================*/ 0040 0041 #ifndef __FAST_LOG_H_ 0042 #define __FAST_LOG_H_ 0043 0044 #include <stdint.h> 0045 0046 namespace YODA { 0047 namespace Utils { 0048 static inline float 0049 fastlog2 (float x) 0050 { 0051 union { float f; uint32_t i; } vx = { x }; 0052 union { uint32_t i; float f; } mx = { (vx.i & 0x007FFFFF) | 0x3f000000 }; 0053 float y = vx.i; 0054 y *= 1.1920928955078125e-7f; 0055 0056 return y - 124.22551499f 0057 - 1.498030302f * mx.f 0058 - 1.72587999f / (0.3520887068f + mx.f); 0059 } 0060 0061 static inline float 0062 fasterlog2 (float x) 0063 { 0064 union { float f; uint32_t i; } vx = { x }; 0065 float y = vx.i; 0066 y *= 1.1920928955078125e-7f; 0067 return y - 126.94269504f; 0068 } 0069 } 0070 } 0071 #endif // __FAST_LOG_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |