added updated version of simdmathlibrary-1.0.1
This commit is contained in:
51
Extras/simdmathlibrary/ppu/simdmath/_vec_utils.h
Normal file
51
Extras/simdmathlibrary/ppu/simdmath/_vec_utils.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Common types for PPU SIMD Math Library
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_VEC_UTILS_H___
|
||||
#define ___SIMD_MATH_VEC_UTILS_H___
|
||||
|
||||
static inline vector float
|
||||
__vec_splatsf4(const float x)
|
||||
{
|
||||
return (vector float) {x, x, x, x};
|
||||
}
|
||||
|
||||
static inline vector signed int
|
||||
__vec_splatsi4(const signed int x)
|
||||
{
|
||||
return (vector signed int) {x, x, x, x};
|
||||
}
|
||||
|
||||
static inline vector unsigned int
|
||||
__vec_splatsu4(const unsigned int x)
|
||||
{
|
||||
return (vector unsigned int) {x, x, x, x};
|
||||
}
|
||||
|
||||
#endif
|
||||
42
Extras/simdmathlibrary/ppu/simdmath/absi4.h
Normal file
42
Extras/simdmathlibrary/ppu/simdmath/absi4.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* absi4 - for each of four integer slots, compute absolute value.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_ABSI4_H___
|
||||
#define ___SIMD_MATH_ABSI4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
static inline vector signed int
|
||||
_absi4 (vector signed int x)
|
||||
{
|
||||
return vec_abs( x );
|
||||
}
|
||||
|
||||
#endif
|
||||
82
Extras/simdmathlibrary/ppu/simdmath/acosf4.h
Normal file
82
Extras/simdmathlibrary/ppu/simdmath/acosf4.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* acosf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_ACOSF4_H___
|
||||
#define ___SIMD_MATH_ACOSF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/sqrtf4.h>
|
||||
|
||||
//
|
||||
// Computes the inverse cosine of all four slots of x.
|
||||
//
|
||||
static inline vector float
|
||||
_acosf4 (vector float x)
|
||||
{
|
||||
vector float result, xabs;
|
||||
vector float t1;
|
||||
vector float xabs2, xabs4;
|
||||
vector float hi, lo;
|
||||
vector float neg, pos;
|
||||
vector unsigned int select;
|
||||
|
||||
xabs = vec_abs(x);
|
||||
select = (vector unsigned int)(vec_sra((vector signed int)(x), __vec_splatsu4(31)));
|
||||
|
||||
t1 = _sqrtf4(vec_sub(__vec_splatsf4(1.0f), xabs));
|
||||
|
||||
/* Instruction counts can be reduced if the polynomial was
|
||||
* computed entirely from nested (dependent) fma's. However,
|
||||
* to reduce the number of pipeline stalls, the polygon is evaluated
|
||||
* in two halves (hi amd lo).
|
||||
*/
|
||||
xabs2 = vec_madd(xabs, xabs, __vec_splatsf4(0.0f) );
|
||||
xabs4 = vec_madd(xabs2, xabs2, __vec_splatsf4(0.0f) );
|
||||
hi = vec_madd(__vec_splatsf4(-0.0012624911) , xabs, __vec_splatsf4(0.0066700901));
|
||||
hi = vec_madd(hi, xabs, __vec_splatsf4(-0.0170881256));
|
||||
hi = vec_madd(hi, xabs, __vec_splatsf4( 0.0308918810));
|
||||
lo = vec_madd(__vec_splatsf4(-0.0501743046), xabs, __vec_splatsf4(0.0889789874));
|
||||
lo = vec_madd(lo, xabs, __vec_splatsf4(-0.2145988016));
|
||||
lo = vec_madd(lo, xabs, __vec_splatsf4( 1.5707963050));
|
||||
|
||||
result = vec_madd(hi, xabs4, lo);
|
||||
|
||||
/* Adjust the result if x is negactive.
|
||||
*/
|
||||
neg = vec_nmsub(t1, result, __vec_splatsf4(3.1415926535898f));
|
||||
pos = vec_madd(t1, result, __vec_splatsf4(0.0f));
|
||||
|
||||
result = vec_sel(pos, neg, select);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
95
Extras/simdmathlibrary/ppu/simdmath/asinf4.h
Normal file
95
Extras/simdmathlibrary/ppu/simdmath/asinf4.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/* asinf4 - Computes the inverse sine of all four slots of x
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_ASINF4_H___
|
||||
#define ___SIMD_MATH_ASINF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/divf4.h>
|
||||
#include <simdmath/sqrtf4.h>
|
||||
|
||||
static inline vector float
|
||||
_asinf4 (vector float x)
|
||||
{
|
||||
// positive = (x > 0)
|
||||
//
|
||||
vector unsigned int positive = (vector unsigned int)vec_cmpgt(x, __vec_splatsf4(0.0f));
|
||||
|
||||
// x = absf(x)
|
||||
//
|
||||
x = vec_abs(x);
|
||||
|
||||
// gtHalf = (|x| > 0.5)
|
||||
//
|
||||
vector unsigned int gtHalf = (vector unsigned int)vec_cmpgt(x, __vec_splatsf4(0.5f));
|
||||
|
||||
|
||||
// if (x > 0.5)
|
||||
// g = 0.5 - 0.5*x
|
||||
// x = -2 * sqrtf(g)
|
||||
// else
|
||||
// g = x * x
|
||||
//
|
||||
vector float g =
|
||||
vec_sel(vec_madd(x, x, __vec_splatsf4(0.0f)),
|
||||
vec_madd(__vec_splatsf4(-0.5f), x, __vec_splatsf4(0.5f)), gtHalf);
|
||||
|
||||
x = vec_sel(x, vec_madd(__vec_splatsf4(-2.0f), _sqrtf4(g), __vec_splatsf4(0.0f)), gtHalf);
|
||||
|
||||
// Compute the polynomials and take their ratio
|
||||
// denom = (1.0f*g + -0.554846723e+1f)*g + 5.603603363f
|
||||
// num = x * g * (-0.504400557f * g + 0.933933258f)
|
||||
//
|
||||
vector float denom = vec_add(g, __vec_splatsf4(-5.54846723f));
|
||||
vector float num = vec_madd(__vec_splatsf4(-0.504400557f), g, __vec_splatsf4(0.933933258f));
|
||||
denom = vec_madd(denom, g, __vec_splatsf4(5.603603363f));
|
||||
num = vec_madd(vec_madd(x, g, __vec_splatsf4(0.0f)), num, __vec_splatsf4(0.0f));
|
||||
|
||||
|
||||
// x = x + num / denom
|
||||
//
|
||||
x = vec_add(x,_divf4(num,denom));
|
||||
|
||||
// if (x > 0.5)
|
||||
// x = x + M_PI_2
|
||||
//
|
||||
x = vec_sel(x,vec_add(x, __vec_splatsf4(1.57079632679489661923f)), gtHalf);
|
||||
|
||||
|
||||
// if (!positive) x = -x
|
||||
//
|
||||
x = vec_sel((vector float)vec_xor(__vec_splatsi4(0x80000000), (vector signed int)x),
|
||||
x, positive);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
#endif
|
||||
67
Extras/simdmathlibrary/ppu/simdmath/atan2f4.h
Normal file
67
Extras/simdmathlibrary/ppu/simdmath/atan2f4.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* atan2f4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_ATAN2F4_H___
|
||||
#define ___SIMD_MATH_ATAN2F4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/atanf4.h>
|
||||
|
||||
//
|
||||
// Inverse tangent function of two variables
|
||||
//
|
||||
static inline vector float
|
||||
_atan2f4 (vector float y, vector float x)
|
||||
{
|
||||
vector float res = _atanf4(divf4(y,x));
|
||||
|
||||
// Use the arguments to determine the quadrant of the result:
|
||||
// if (x < 0)
|
||||
// if (y < 0)
|
||||
// res = -PI + res
|
||||
// else
|
||||
// res = PI + res
|
||||
//
|
||||
vector unsigned int yNeg = (vector unsigned int)vec_cmpgt(__vec_splatsf4(0.0f), y);
|
||||
vector unsigned int xNeg = (vector unsigned int)vec_cmpgt(__vec_splatsf4(0.0f) ,x);
|
||||
|
||||
vector float bias =
|
||||
vec_sel(__vec_splatsf4(3.14159265358979323846f),
|
||||
__vec_splatsf4(-3.14159265358979323846f), yNeg);
|
||||
|
||||
vector float newRes = vec_add(bias, res);
|
||||
|
||||
res = vec_sel(res,newRes,xNeg);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
87
Extras/simdmathlibrary/ppu/simdmath/atanf4.h
Normal file
87
Extras/simdmathlibrary/ppu/simdmath/atanf4.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* atanf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_ATANF4_H___
|
||||
#define ___SIMD_MATH_ATANF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/recipf4.h>
|
||||
|
||||
//
|
||||
// Computes the inverse tangent of all four slots of x.
|
||||
//
|
||||
static inline vector float
|
||||
_atanf4 (vector float x)
|
||||
{
|
||||
vector float bias;
|
||||
vector float x2, x3, x4, x8, x9;
|
||||
vector float hi, lo;
|
||||
vector float result;
|
||||
vector float inv_x;
|
||||
vector unsigned int sign;
|
||||
vector unsigned int select;
|
||||
vector float xabs;
|
||||
vector float vzero = __vec_splatsf4(0.0f);
|
||||
|
||||
sign = vec_and((vector unsigned int)x, __vec_splatsu4(0x80000000));
|
||||
xabs = (vector float)vec_andc((vector unsigned int)x, __vec_splatsu4(0x80000000));
|
||||
inv_x = _recipf4(x);
|
||||
inv_x = (vector float)vec_xor((vector unsigned int)inv_x, __vec_splatsu4(0x80000000));
|
||||
select = (vector unsigned int)vec_cmpgt(xabs, __vec_splatsf4(1.0f));
|
||||
bias = (vector float)vec_or(sign, (vector unsigned int)(__vec_splatsf4(1.57079632679489661923f)));
|
||||
bias = (vector float)vec_and((vector unsigned int)bias, select);
|
||||
|
||||
x = vec_sel(x, inv_x, select);
|
||||
|
||||
/* Instruction counts can be reduced if the polynomial was
|
||||
* computed entirely from nested (dependent) fma's. However,
|
||||
* to reduce the number of pipeline stalls, the polygon is evaluated
|
||||
* in two halves(hi and lo).
|
||||
*/
|
||||
bias = vec_add(bias, x);
|
||||
x2 = vec_madd(x, x, vzero);
|
||||
x3 = vec_madd(x2, x, vzero);
|
||||
x4 = vec_madd(x2, x2, vzero);
|
||||
x8 = vec_madd(x4, x4, vzero);
|
||||
x9 = vec_madd(x8, x, vzero);
|
||||
hi = vec_madd(__vec_splatsf4(0.0028662257), x2, __vec_splatsf4(-0.0161657367));
|
||||
hi = vec_madd(hi, x2, __vec_splatsf4(0.0429096138));
|
||||
hi = vec_madd(hi, x2, __vec_splatsf4(-0.0752896400));
|
||||
hi = vec_madd(hi, x2, __vec_splatsf4(0.1065626393));
|
||||
lo = vec_madd(__vec_splatsf4(-0.1420889944), x2, __vec_splatsf4(0.1999355085));
|
||||
lo = vec_madd(lo, x2, __vec_splatsf4(-0.3333314528));
|
||||
lo = vec_madd(lo, x3, bias);
|
||||
|
||||
result = vec_madd(hi, x9, lo);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
97
Extras/simdmathlibrary/ppu/simdmath/cbrtf4.h
Normal file
97
Extras/simdmathlibrary/ppu/simdmath/cbrtf4.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* cbrtf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_CBRTF4_H___
|
||||
#define ___SIMD_MATH_CBRTF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/frexpf4.h>
|
||||
#include <simdmath/ldexpf4.h>
|
||||
#include <simdmath/divf4.h>
|
||||
|
||||
static inline vector signed int
|
||||
__cbrtf4_calc_quot(vector signed int n)
|
||||
{
|
||||
vector signed int quot;
|
||||
vector unsigned int negxexpmask = (vector unsigned int)vec_cmpgt(__vec_splatsi4(0), n);
|
||||
n = vec_sel(n, vec_add(n, __vec_splatsi4(2)), negxexpmask);
|
||||
|
||||
quot = vec_add(vec_sra(n, __vec_splatsu4(2)), vec_sra(n, __vec_splatsu4(4)));
|
||||
quot = vec_add(quot, vec_sra(quot, __vec_splatsu4(4)));
|
||||
quot = vec_add(quot, vec_sra(quot, __vec_splatsu4(8)));
|
||||
quot = vec_add(quot, vec_sra(quot, __vec_splatsu4(16)));
|
||||
vector signed int r = vec_sub(vec_sub(n,quot), vec_sl(quot, __vec_splatsu4(1)));
|
||||
quot = vec_add(quot,
|
||||
vec_sra(vec_add(vec_add(r, __vec_splatsi4(5)),
|
||||
vec_sl (r, __vec_splatsu4(2))),
|
||||
__vec_splatsu4(4)));
|
||||
|
||||
return quot;
|
||||
}
|
||||
|
||||
#define __CBRTF_cbrt2 1.2599210498948731648 // 2^(1/3)
|
||||
#define __CBRTF_sqr_cbrt2 1.5874010519681994748 // 2^(2/3)
|
||||
|
||||
static inline vector float
|
||||
_cbrtf4 (vector float x)
|
||||
{
|
||||
vector float zeros = __vec_splatsf4(0.0f);
|
||||
vector signed int xexp;
|
||||
vector float sgnmask = (vector float)__vec_splatsi4(0x80000000);
|
||||
vector unsigned int negmask = (vector unsigned int)vec_cmpgt(zeros, x);
|
||||
x = vec_andc(x, sgnmask);
|
||||
|
||||
x = _frexpf4(x, &xexp);
|
||||
vector float p =
|
||||
vec_madd(vec_madd(x, __vec_splatsf4(-0.191502161678719066f), __vec_splatsf4(0.697570460207922770f)),
|
||||
x,
|
||||
__vec_splatsf4(0.492659620528969547f));
|
||||
vector float p3 = vec_madd(p, vec_madd(p, p, zeros), zeros);
|
||||
|
||||
vector signed int quot = __cbrtf4_calc_quot(xexp);
|
||||
// mod = xexp - 3*quotient
|
||||
vector signed int modval = vec_sub(vec_sub(xexp,quot), vec_sl(quot, __vec_splatsu4(1)));
|
||||
vector float factor = __vec_splatsf4(1.0/__CBRTF_sqr_cbrt2);
|
||||
factor = vec_sel(factor, __vec_splatsf4(1.0/__CBRTF_cbrt2), vec_cmpeq(modval, __vec_splatsi4(-1)));
|
||||
factor = vec_sel(factor, __vec_splatsf4( 1.0), vec_cmpeq(modval, __vec_splatsi4( 0)));
|
||||
factor = vec_sel(factor, __vec_splatsf4( __CBRTF_cbrt2), vec_cmpeq(modval, __vec_splatsi4( 1)));
|
||||
factor = vec_sel(factor, __vec_splatsf4(__CBRTF_sqr_cbrt2), vec_cmpeq(modval, __vec_splatsi4( 2)));
|
||||
|
||||
vector float pre = vec_madd(p, factor, zeros);
|
||||
vector float numr = vec_madd(x , __vec_splatsf4(2.0f), p3);
|
||||
vector float denr = vec_madd(p3, __vec_splatsf4(2.0f), x );
|
||||
vector float res = vec_madd(pre, _divf4(numr, denr), zeros);
|
||||
res = _ldexpf4(res, quot);
|
||||
|
||||
return vec_sel(res, vec_or(res,sgnmask), negmask);
|
||||
}
|
||||
|
||||
#endif
|
||||
42
Extras/simdmathlibrary/ppu/simdmath/ceilf4.h
Normal file
42
Extras/simdmathlibrary/ppu/simdmath/ceilf4.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* ceilf4 - for each of four float slots, round up to smallest integer not less than the value.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_CEILF4_H___
|
||||
#define ___SIMD_MATH_CEILF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
static inline vector float
|
||||
_ceilf4(vector float x)
|
||||
{
|
||||
return vec_ceil( x );
|
||||
}
|
||||
|
||||
#endif
|
||||
45
Extras/simdmathlibrary/ppu/simdmath/copysignf4.h
Normal file
45
Extras/simdmathlibrary/ppu/simdmath/copysignf4.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* copysignf4 - for each of four float slots, return value with magnitude from x and sign from y.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_COPYSIGNF4_H___
|
||||
#define ___SIMD_MATH_COPYSIGNF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
|
||||
static inline vector float
|
||||
_copysignf4(vector float x, vector float y)
|
||||
{
|
||||
return vec_sel(x, y, __vec_splatsu4(0x80000000));
|
||||
}
|
||||
|
||||
#endif
|
||||
107
Extras/simdmathlibrary/ppu/simdmath/cosf4.h
Normal file
107
Extras/simdmathlibrary/ppu/simdmath/cosf4.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/* cosf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_COSF4_H___
|
||||
#define ___SIMD_MATH_COSF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_sincos.h>
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
|
||||
//
|
||||
// Computes the cosine of each of the four slots
|
||||
// by using a polynomial approximation.
|
||||
//
|
||||
static inline vector float
|
||||
_cosf4 (vector float x)
|
||||
{
|
||||
vector float xl,xl2,xl3,res;
|
||||
vector signed int q;
|
||||
|
||||
// Range reduction using : xl = angle * TwoOverPi;
|
||||
//
|
||||
xl = vec_madd(x, __vec_splatsf4(0.63661977236f), __vec_splatsf4(0.0f));
|
||||
|
||||
// Find the quadrant the angle falls in
|
||||
// using: q = (int) (ceil(abs(xl))*sign(xl))
|
||||
//
|
||||
xl = vec_add(xl, vec_sel(__vec_splatsf4(0.5f), xl, __vec_splatsu4(0x80000000)));
|
||||
q = vec_cts(xl, 0);
|
||||
|
||||
|
||||
// Compute an offset based on the quadrant that the angle falls in
|
||||
//
|
||||
vector signed int offset = vec_add(__vec_splatsi4(1), vec_and(q, __vec_splatsi4(0x3)));
|
||||
|
||||
// Remainder in range [-pi/4..pi/4]
|
||||
//
|
||||
vector float qf = vec_ctf(q,0);
|
||||
vector float p1 = vec_nmsub(qf, __vec_splatsf4(__SINCOSF_KC1), x);
|
||||
xl = vec_nmsub(qf, __vec_splatsf4(__SINCOSF_KC2), p1);
|
||||
|
||||
// Compute x^2 and x^3
|
||||
//
|
||||
xl2 = vec_madd(xl, xl, __vec_splatsf4(0.0f));
|
||||
xl3 = vec_madd(xl2, xl, __vec_splatsf4(0.0f));
|
||||
|
||||
|
||||
// Compute both the sin and cos of the angles
|
||||
// using a polynomial expression:
|
||||
// cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and
|
||||
// sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2)
|
||||
//
|
||||
vector float ct1 = vec_madd(__vec_splatsf4(__SINCOSF_CC0), xl2, __vec_splatsf4(__SINCOSF_CC1));
|
||||
vector float st1 = vec_madd(__vec_splatsf4(__SINCOSF_SC0), xl2, __vec_splatsf4(__SINCOSF_SC1));
|
||||
|
||||
vector float ct2 = vec_madd(ct1, xl2, __vec_splatsf4(__SINCOSF_CC2));
|
||||
vector float st2 = vec_madd(st1, xl2, __vec_splatsf4(__SINCOSF_SC2));
|
||||
|
||||
vector float cx = vec_madd(ct2, xl2, __vec_splatsf4(1.0f));
|
||||
vector float sx = vec_madd(st2, xl3, xl);
|
||||
|
||||
// Use the cosine when the offset is odd and the sin
|
||||
// when the offset is even
|
||||
//
|
||||
vector unsigned int mask1 =
|
||||
(vector unsigned int)vec_cmpeq(vec_and(offset, __vec_splatsi4(0x1)), __vec_splatsi4(0));
|
||||
res = vec_sel(cx, sx, mask1);
|
||||
|
||||
// Flip the sign of the result when (offset mod 4) = 1 or 2
|
||||
//
|
||||
vector unsigned int mask2 =
|
||||
(vector unsigned int)vec_cmpeq(vec_and(offset, __vec_splatsi4(0x2)), __vec_splatsi4(0));
|
||||
res = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000U), (vector unsigned int)res), res, mask2);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
51
Extras/simdmathlibrary/ppu/simdmath/divf4.h
Normal file
51
Extras/simdmathlibrary/ppu/simdmath/divf4.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* divf4 - for each of four float slots, divide numer by denom.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_DIVF4_H___
|
||||
#define ___SIMD_MATH_DIVF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
|
||||
static inline vector float
|
||||
_divf4 (vector float numer, vector float denom)
|
||||
{
|
||||
// Reciprocal estimate and 1 Newton-Raphson iteration.
|
||||
|
||||
vector float y0, y0numer;
|
||||
|
||||
y0 = vec_re(denom);
|
||||
y0numer = vec_madd(numer, y0, __vec_splatsf4(0.0f));
|
||||
return vec_madd(vec_nmsub(denom, y0, __vec_splatsf4(1.0f)), y0numer, y0numer);
|
||||
}
|
||||
|
||||
#endif
|
||||
105
Extras/simdmathlibrary/ppu/simdmath/divi4.h
Normal file
105
Extras/simdmathlibrary/ppu/simdmath/divi4.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/* divi4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_DIVI4_H___
|
||||
#define ___SIMD_MATH_DIVI4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
// divi4 - for each of four integer slots, compute quotient and remainder of numer/denom
|
||||
// and store in divi4_t struct. Divide by zero produces quotient = 0, remainder = numerator.
|
||||
|
||||
static inline divi4_t
|
||||
_divi4 (vector signed int numer, vector signed int denom )
|
||||
{
|
||||
vector signed int minusone = __vec_splatsi4(-1);
|
||||
vector unsigned int zero = __vec_splatsu4(0);
|
||||
vector unsigned int one = __vec_splatsu4(1);
|
||||
vector unsigned int k158 = __vec_splatsu4(158);
|
||||
vector unsigned int k23 = __vec_splatsu4(23);
|
||||
|
||||
divi4_t res;
|
||||
vector unsigned int numerPos, denomPos, quotNeg;
|
||||
vector unsigned int numerAbs, denomAbs;
|
||||
vector unsigned int denomZeros, numerZeros, shift, denomShifted, oneShifted;
|
||||
vector unsigned int quot, newQuot, skip, newNum, cont;
|
||||
int anyCont;
|
||||
|
||||
// determine whether result needs sign change
|
||||
|
||||
numerPos = (vector unsigned int)vec_cmpgt( numer, minusone );
|
||||
denomPos = (vector unsigned int)vec_cmpgt( denom, minusone );
|
||||
quotNeg = vec_xor( numerPos, denomPos );
|
||||
|
||||
// use absolute values of numerator, denominator
|
||||
|
||||
numerAbs = (vector unsigned int)vec_sel( vec_sub( (vector signed int)zero, numer ), numer, numerPos );
|
||||
denomAbs = (vector unsigned int)vec_sel( vec_sub( (vector signed int)zero, denom ), denom, denomPos );
|
||||
|
||||
// get difference of leading zeros to align denom with numer
|
||||
|
||||
denomZeros = vec_sub( k158, vec_sr( (vector unsigned int)vec_ctf( denomAbs, 0 ), k23 ) );
|
||||
numerZeros = vec_sub( k158, vec_sr( (vector unsigned int)vec_ctf( numerAbs, 0 ), k23 ) );
|
||||
|
||||
shift = vec_sub( denomZeros, numerZeros );
|
||||
denomShifted = vec_sl( denomAbs, shift );
|
||||
oneShifted = vec_sl( one, shift );
|
||||
oneShifted = vec_sel( oneShifted, zero, vec_or( vec_cmpeq( denomAbs, zero ),
|
||||
vec_cmpgt( denomAbs, numerAbs ) ) );
|
||||
|
||||
// long division
|
||||
|
||||
quot = zero;
|
||||
|
||||
do
|
||||
{
|
||||
cont = (vector unsigned int)vec_cmpgt( oneShifted, zero );
|
||||
anyCont = vec_any_gt( oneShifted, zero );
|
||||
skip = (vector unsigned int)vec_cmpgt( denomShifted, numerAbs );
|
||||
|
||||
newQuot = vec_or( quot, oneShifted );
|
||||
newNum = vec_sub( numerAbs, denomShifted );
|
||||
|
||||
oneShifted = vec_sr( oneShifted, one );
|
||||
denomShifted = vec_sr( denomShifted, one );
|
||||
|
||||
quot = vec_sel( newQuot, quot, skip );
|
||||
numerAbs = vec_sel( numerAbs, newNum, vec_andc( cont, skip ) );
|
||||
}
|
||||
while ( anyCont );
|
||||
|
||||
res.quot = (vector signed int)vec_sel( quot, vec_sub( zero, quot ), quotNeg );
|
||||
res.rem = (vector signed int)vec_sel( (vector unsigned int)vec_sub( (vector signed int)zero, (vector signed int)numerAbs ), numerAbs, numerPos );
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
137
Extras/simdmathlibrary/ppu/simdmath/exp2f4.h
Normal file
137
Extras/simdmathlibrary/ppu/simdmath/exp2f4.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/* exp2f4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_EXP2F4_H___
|
||||
#define ___SIMD_MATH_EXP2F4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
* vector float _exp2_v(vector float x)
|
||||
*
|
||||
* DESCRIPTION
|
||||
* _exp2_v computes 2 raised to the input vector x. Computation is
|
||||
* performed by observing the 2^(a+b) = 2^a * 2^b.
|
||||
* We decompose x into a and b (above) by letting.
|
||||
* a = ceil(x), b = x - a;
|
||||
*
|
||||
* 2^a is easilty computed by placing a into the exponent
|
||||
* or a floating point number whose mantissa is all zeros.
|
||||
*
|
||||
* 2^b is computed using the following polynomial approximation.
|
||||
* (C. Hastings, Jr, 1955).
|
||||
*
|
||||
* __7__
|
||||
* \
|
||||
* \
|
||||
* 2^(-x) = / Ci*x^i
|
||||
* /____
|
||||
* i=1
|
||||
*
|
||||
* for x in the range 0.0 to 1.0
|
||||
*
|
||||
* C0 = 1.0
|
||||
* C1 = -0.9999999995
|
||||
* C2 = 0.4999999206
|
||||
* C3 = -0.1666653019
|
||||
* C4 = 0.0416573475
|
||||
* C5 = -0.0083013598
|
||||
* C6 = 0.0013298820
|
||||
* C7 = -0.0001413161
|
||||
*
|
||||
* This function does not handle out of range conditions. It
|
||||
* assumes that x is in the range (-128.0, 127.0]. Values outside
|
||||
* this range will produce undefined results.
|
||||
*/
|
||||
|
||||
|
||||
#define __EXP2F_LN2 0.69314718055995f /* ln(2) */
|
||||
|
||||
static inline vector float
|
||||
_exp2f4 (vector float x)
|
||||
{
|
||||
vector signed int ix;
|
||||
vector unsigned int overflow;
|
||||
vector unsigned int underflow;
|
||||
vector float frac, frac2, frac4;
|
||||
vector float exp_int, exp_frac;
|
||||
vector float result;
|
||||
vector float hi, lo;
|
||||
vector float zeros = __vec_splatsf4(0.0f);
|
||||
vector float bias;
|
||||
/* Break in the input x into two parts ceil(x), x - ceil(x).
|
||||
*/
|
||||
#if 1
|
||||
bias = (vector float)(vec_sra((vector signed int)x, __vec_splatsu4(31) ));
|
||||
bias = (vector float)(vec_andc(__vec_splatsu4(0x3F7FFFFF), (vector unsigned int)bias));
|
||||
ix = vec_cts(vec_add(x, bias), 0);
|
||||
#else
|
||||
bias = vec_sel(vec_floor(x), vec_ceil(x), vec_cmpgt(x, __vec_splatsf4(0.0f)));
|
||||
ix = vec_cts(bias, 0);
|
||||
#endif
|
||||
frac = vec_sub(vec_ctf(ix, 0), x);
|
||||
frac = vec_madd(frac, __vec_splatsf4(__EXP2F_LN2), zeros);
|
||||
|
||||
overflow = (vector unsigned int)vec_cmpgt(x, (vector float)(__vec_splatsi4(0x4300FFFF))); // !!! Biggest possible exponent to fit in range.
|
||||
underflow = (vector unsigned int)vec_cmpgt(__vec_splatsf4(-126.0f), x);
|
||||
|
||||
exp_int = (vector float)(vec_sl(vec_add(ix, __vec_splatsi4(126)), __vec_splatsu4(23))); // !!! HRD <- add with saturation
|
||||
|
||||
/* Instruction counts can be reduced if the polynomial was
|
||||
* computed entirely from nested (dependent) fma's. However,
|
||||
* to reduce the number of pipeline stalls, the polygon is evaluated
|
||||
* in two halves (hi amd lo).
|
||||
*/
|
||||
frac2 = vec_madd(frac, frac, zeros);
|
||||
frac4 = vec_madd(frac2, frac2, zeros);
|
||||
|
||||
hi = vec_madd(frac, __vec_splatsf4(-0.0001413161), __vec_splatsf4(0.0013298820));
|
||||
hi = vec_madd(frac, hi, __vec_splatsf4(-0.0083013598));
|
||||
hi = vec_madd(frac, hi, __vec_splatsf4(0.0416573475));
|
||||
lo = vec_madd(frac, __vec_splatsf4(-0.1666653019), __vec_splatsf4(0.4999999206));
|
||||
lo = vec_madd(frac, lo, __vec_splatsf4(-0.9999999995));
|
||||
lo = vec_madd(frac, lo, __vec_splatsf4(1.0));
|
||||
|
||||
exp_frac = vec_madd(frac4, hi, lo);
|
||||
result = vec_madd(exp_frac, exp_int, zeros);
|
||||
result = vec_madd(exp_frac, exp_int, result); // !!! HRD
|
||||
|
||||
/* Handle overflow */
|
||||
result = vec_sel(result, __vec_splatsf4(HUGE_VALF), overflow);
|
||||
result = vec_sel(result, zeros, underflow);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endif
|
||||
69
Extras/simdmathlibrary/ppu/simdmath/expf4.h
Normal file
69
Extras/simdmathlibrary/ppu/simdmath/expf4.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* expf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_EXPF4_H___
|
||||
#define ___SIMD_MATH_EXPF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/divf4.h>
|
||||
#include <simdmath/ldexpf4.h>
|
||||
|
||||
#define __EXPF_C1 -0.6931470632553101f
|
||||
#define __EXPF_C2 -1.1730463525082e-7f
|
||||
|
||||
#define __EXPF_INVLN2 1.4426950408889634f
|
||||
|
||||
static inline vector float
|
||||
_expf4 (vector float x)
|
||||
{
|
||||
vector float zeros = __vec_splatsf4(0.0f);
|
||||
vector unsigned int xnegmask = (vector unsigned int)vec_cmpgt(zeros, x);
|
||||
vector float goffset = vec_sel(__vec_splatsf4( 0.5f),__vec_splatsf4(-0.5f),xnegmask);
|
||||
vector float g = vec_madd(x, __vec_splatsf4(__EXPF_INVLN2), zeros);
|
||||
vector signed int xexp = vec_cts(vec_add(g, goffset),0);
|
||||
|
||||
g = vec_ctf(xexp, 0);
|
||||
g = vec_madd(g, __vec_splatsf4(__EXPF_C2), vec_madd(g, __vec_splatsf4(__EXPF_C1), x));
|
||||
vector float z = vec_madd(g, g, zeros);
|
||||
vector float a = vec_madd(z, __vec_splatsf4(0.0999748594f), zeros);
|
||||
vector float b = vec_madd(g,
|
||||
vec_madd(z,
|
||||
__vec_splatsf4(0.0083208258f),
|
||||
__vec_splatsf4(0.4999999992f)),
|
||||
zeros);
|
||||
|
||||
vector float foo = _divf4(vec_add(__vec_splatsf4(1.0f), vec_add(a, b)),
|
||||
vec_add(__vec_splatsf4(1.0f), vec_sub(a, b)));
|
||||
|
||||
return _ldexpf4(foo, xexp);
|
||||
}
|
||||
|
||||
#endif
|
||||
63
Extras/simdmathlibrary/ppu/simdmath/expm1f4.h
Normal file
63
Extras/simdmathlibrary/ppu/simdmath/expm1f4.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* expm1f4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_EXPM1F4_H___
|
||||
#define ___SIMD_MATH_EXPM1F4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
#define __EXPM1F_ln1by2 -0.6931471805599f
|
||||
#define __EXPM1F_ln3by2 0.4054651081082f
|
||||
|
||||
static inline vector float
|
||||
_expm1f4 (vector float x)
|
||||
{
|
||||
vector float zeros = __vec_splatsf4(0.0f);
|
||||
vector unsigned int nearzeromask =
|
||||
(vector unsigned int)vec_and(vec_cmpgt(x, __vec_splatsf4(__EXPM1F_ln1by2)),
|
||||
vec_cmpgt(__vec_splatsf4(__EXPM1F_ln3by2), x));
|
||||
vector float x2 = vec_madd(x,x,zeros);
|
||||
vector float d0, d1, n0, n1;
|
||||
|
||||
d0 = vec_madd(x , __vec_splatsf4(-0.3203561199f), __vec_splatsf4(0.9483177697f));
|
||||
d1 = vec_madd(x2, __vec_splatsf4( 0.0326527809f), d0);
|
||||
|
||||
n0 = vec_madd(x , __vec_splatsf4(0.1538026623f), __vec_splatsf4(0.9483177732f));
|
||||
n1 = vec_madd(x , __vec_splatsf4(0.0024490478f), __vec_splatsf4(0.0305274668f));
|
||||
n1 = vec_madd(x2, n1, n0);
|
||||
|
||||
return vec_sel(vec_sub(expf4(x), __vec_splatsf4(1.0f)),
|
||||
vec_madd(x, divf4(n1, d1), zeros),
|
||||
nearzeromask);
|
||||
}
|
||||
|
||||
#endif
|
||||
42
Extras/simdmathlibrary/ppu/simdmath/fabsf4.h
Normal file
42
Extras/simdmathlibrary/ppu/simdmath/fabsf4.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* fabsf4 - for each of four float slots, compute absolute value.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FABSF4_H___
|
||||
#define ___SIMD_MATH_FABSF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
static inline vector float
|
||||
_fabsf4(vector float x)
|
||||
{
|
||||
return vec_abs( x );
|
||||
}
|
||||
|
||||
#endif
|
||||
45
Extras/simdmathlibrary/ppu/simdmath/fdimf4.h
Normal file
45
Extras/simdmathlibrary/ppu/simdmath/fdimf4.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* fdimf -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FDIMF4_H___
|
||||
#define ___SIMD_MATH_FDIMF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector float
|
||||
_fdimf4 (vector float x, vector float y)
|
||||
{
|
||||
vector float diff = vec_sub(x,y);
|
||||
return vec_sel(__vec_splatsf4(0.0f), diff, vec_cmpgt(x,y));
|
||||
}
|
||||
|
||||
#endif
|
||||
43
Extras/simdmathlibrary/ppu/simdmath/floorf4.h
Normal file
43
Extras/simdmathlibrary/ppu/simdmath/floorf4.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* floorf4 - for each of four float slots, round down to largest integer not greater than the value.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FLOORF4_H___
|
||||
#define ___SIMD_MATH_FLOORF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
|
||||
static inline vector float
|
||||
_floorf4 (vector float x)
|
||||
{
|
||||
return vec_floor( x );
|
||||
}
|
||||
|
||||
#endif
|
||||
42
Extras/simdmathlibrary/ppu/simdmath/fmaf4.h
Normal file
42
Extras/simdmathlibrary/ppu/simdmath/fmaf4.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* fmaf4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FMAF4_H___
|
||||
#define ___SIMD_MATH_FMAF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
static inline vector float
|
||||
_fmaf4 (vector float x, vector float y, vector float z)
|
||||
{
|
||||
return vec_madd(x,y,z);
|
||||
}
|
||||
|
||||
#endif
|
||||
43
Extras/simdmathlibrary/ppu/simdmath/fmaxf4.h
Normal file
43
Extras/simdmathlibrary/ppu/simdmath/fmaxf4.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* fmaxf4 - for each of four float slots, compute maximum of x and y
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FMAXF4_H___
|
||||
#define ___SIMD_MATH_FMAXF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
|
||||
static inline vector float
|
||||
_fmaxf4 (vector float x, vector float y)
|
||||
{
|
||||
return vec_max( x, y );
|
||||
}
|
||||
|
||||
#endif
|
||||
43
Extras/simdmathlibrary/ppu/simdmath/fminf4.h
Normal file
43
Extras/simdmathlibrary/ppu/simdmath/fminf4.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* fminf4 - for each of four float slots, compute minimum of x and y
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FMINF4_H___
|
||||
#define ___SIMD_MATH_FMINF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
|
||||
static inline vector float
|
||||
_fminf4 (vector float x, vector float y)
|
||||
{
|
||||
return vec_min( x, y );
|
||||
}
|
||||
|
||||
#endif
|
||||
88
Extras/simdmathlibrary/ppu/simdmath/fmodf4.h
Normal file
88
Extras/simdmathlibrary/ppu/simdmath/fmodf4.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* fmodf4 - for each of four float slots, compute remainder of x/y defined as x - truncated_integer(x/y) * y.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FMODF4_H___
|
||||
#define ___SIMD_MATH_FMODF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/divf4.h>
|
||||
#include <simdmath/fabsf4.h>
|
||||
#include <simdmath/copysignf4.h>
|
||||
|
||||
//
|
||||
// This returns an accurate result when |divf4(x,y)| < 2^20 and |x| < 2^128, and otherwise returns zero.
|
||||
// If x == 0, the result is 0.
|
||||
// If x != 0 and y == 0, the result is undefined.
|
||||
|
||||
static inline vector float
|
||||
_fmodf4 (vector float x, vector float y)
|
||||
{
|
||||
vector float q, xabs, yabs, qabs, xabs2;
|
||||
vector signed int qi0, qi1, qi2;
|
||||
vector float i0, i1, i2, r1, r2, i;
|
||||
vector unsigned int inrange;
|
||||
|
||||
// Find i = truncated_integer(|x/y|)
|
||||
|
||||
// If |divf4(x,y)| < 2^20, the quotient is at most off by 1.0.
|
||||
// Thus i is either the truncated quotient, one less, or one greater.
|
||||
|
||||
q = _divf4( x, y );
|
||||
xabs = _fabsf4( x );
|
||||
yabs = _fabsf4( y );
|
||||
qabs = _fabsf4( q );
|
||||
xabs2 = vec_add( xabs, xabs );
|
||||
|
||||
inrange = (vector unsigned int)vec_cmpgt( (vector float)(__vec_splatsu4(0x49800000)), qabs );
|
||||
|
||||
qi1 = vec_cts( qabs, 0 );
|
||||
qi0 = vec_add( qi1, __vec_splatsi4(-1) );
|
||||
qi2 = vec_add( qi1, __vec_splatsi4(1) );
|
||||
|
||||
i0 = vec_ctf( qi0, 0 );
|
||||
i1 = vec_ctf( qi1, 0 );
|
||||
i2 = vec_ctf( qi2, 0 );
|
||||
|
||||
// Correct i will be the largest one such that |x| - i*|y| >= 0.
|
||||
|
||||
r1 = vec_nmsub( i1, yabs, xabs );
|
||||
r2 = vec_nmsub( i2, yabs, xabs );
|
||||
|
||||
i = i0;
|
||||
i = vec_sel( i1, i, vec_cmpgt( __vec_splatsi4(0), (vector signed int)r1 ) );
|
||||
i = vec_sel( i2, i, vec_cmpgt( __vec_splatsi4(0), (vector signed int)r2 ) );
|
||||
|
||||
i = _copysignf4( i, q );
|
||||
|
||||
return vec_sel( __vec_splatsf4(0.0f), vec_nmsub( i, y, x ), inrange );
|
||||
}
|
||||
|
||||
#endif
|
||||
54
Extras/simdmathlibrary/ppu/simdmath/frexpf4.h
Normal file
54
Extras/simdmathlibrary/ppu/simdmath/frexpf4.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* frexpf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_FREXPF4_H___
|
||||
#define ___SIMD_MATH_FREXPF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector float
|
||||
_frexpf4 (vector float x, vector signed int *exp)
|
||||
{
|
||||
vector signed int zeros = __vec_splatsi4(0);
|
||||
vector unsigned int zeromask = (vector unsigned int)vec_cmpeq(x, (vector float)zeros);
|
||||
|
||||
vector signed int expmask = __vec_splatsi4(0x7F800000);
|
||||
vector signed int e1 = vec_and ( (vector signed int)x, expmask);
|
||||
vector signed int e2 = vec_sub(vec_sr(e1, __vec_splatsu4(23) ), __vec_splatsi4(126) );
|
||||
*exp = vec_sel(e2, zeros, zeromask);
|
||||
|
||||
vector float m2 = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask);
|
||||
|
||||
return vec_sel(m2, (vector float)zeros, zeromask);
|
||||
}
|
||||
|
||||
#endif
|
||||
46
Extras/simdmathlibrary/ppu/simdmath/hypotf4.h
Normal file
46
Extras/simdmathlibrary/ppu/simdmath/hypotf4.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* hypotf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_HYPOTF4_H___
|
||||
#define ___SIMD_MATH_HYPOTF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/sqrtf4.h>
|
||||
|
||||
static inline vector float
|
||||
_hypotf4 (vector float x, vector float y)
|
||||
{
|
||||
vector float sum = vec_madd( x, x, __vec_splatsf4(0.0f) );
|
||||
sum = vec_madd(y, y, sum);
|
||||
return _sqrtf4(sum);
|
||||
}
|
||||
|
||||
#endif
|
||||
52
Extras/simdmathlibrary/ppu/simdmath/ilogbf4.h
Normal file
52
Extras/simdmathlibrary/ppu/simdmath/ilogbf4.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* ilogbf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_ILOGBF4_H___
|
||||
#define ___SIMD_MATH_ILOGBF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector signed int
|
||||
_ilogbf4 (vector float x)
|
||||
{
|
||||
vector signed int minus127 = __vec_splatsi4(-127);
|
||||
|
||||
vector signed int e1 = vec_and((vector signed int)x, __vec_splatsi4(0x7F800000));
|
||||
vector unsigned int zeromask = (vector unsigned int)vec_cmpeq(e1, __vec_splatsi4(0));
|
||||
vector signed int e2 = vec_add(vec_sr(e1,__vec_splatsu4(23)), minus127);
|
||||
|
||||
return vec_sel(e2, __vec_splatsi4(FP_ILOGB0), zeromask);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
63
Extras/simdmathlibrary/ppu/simdmath/ldexpf4.h
Normal file
63
Extras/simdmathlibrary/ppu/simdmath/ldexpf4.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* ldexpf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_LDEXPF4_H___
|
||||
#define ___SIMD_MATH_LDEXPF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector float
|
||||
_ldexpf4 (vector float x, vector signed int exp)
|
||||
{
|
||||
vector signed int zeros = __vec_splatsi4(0);
|
||||
|
||||
vector signed int expmask = __vec_splatsi4(0x7F800000);
|
||||
vector signed int e1 = vec_and((vector signed int)x, expmask);
|
||||
vector signed int e2 = vec_sr(e1,__vec_splatsu4(23));
|
||||
|
||||
vector unsigned int maxmask = (vector unsigned int)vec_cmpgt(exp, __vec_splatsi4(255));
|
||||
vector unsigned int minmask = (vector unsigned int)vec_cmpgt(__vec_splatsi4(-255), exp);
|
||||
minmask = vec_or (minmask, (vector unsigned int)vec_cmpeq(x, (vector float)zeros));
|
||||
|
||||
vector signed int esum = vec_add(e2, exp);
|
||||
|
||||
maxmask = vec_or (maxmask, (vector unsigned int)vec_cmpgt(esum, __vec_splatsi4(255)));
|
||||
maxmask = vec_and(maxmask, __vec_splatsu4(0x7FFFFFFF));
|
||||
minmask = vec_or (minmask, (vector unsigned int)vec_cmpgt(zeros, esum));
|
||||
|
||||
x = vec_sel(x, (vector float)vec_sl(esum,__vec_splatsu4(23)), (vector unsigned int)expmask);
|
||||
x = vec_sel(x, (vector float)zeros, minmask);
|
||||
x = vec_sel(x, (vector float)maxmask, maxmask);
|
||||
return x;
|
||||
}
|
||||
|
||||
#endif
|
||||
83
Extras/simdmathlibrary/ppu/simdmath/log10f4.h
Normal file
83
Extras/simdmathlibrary/ppu/simdmath/log10f4.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* log10f4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_LOG10F4_H___
|
||||
#define ___SIMD_MATH_LOG10F4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/divf4.h>
|
||||
|
||||
#define __LOG10F_loga2msb 0.3010299205780f
|
||||
#define __LOG10F_loga2lsb 7.5085978266e-8f
|
||||
#define __LOG10F_logaemsb 0.4342944622040f
|
||||
#define __LOG10F_logaelsb 1.9699272335e-8f
|
||||
#define __LOG10F_neglogae -0.4342944819033f
|
||||
|
||||
#define __LOG10F_c0 -0.2988439998f
|
||||
#define __LOG10F_c1 -0.3997655209f
|
||||
#define __LOG10F_c2 -0.6666679125f
|
||||
|
||||
static inline vector float
|
||||
_log10f4 (vector float x)
|
||||
{
|
||||
vector signed int zeros = __vec_splatsi4(0);
|
||||
vector float ones = __vec_splatsf4(1.0f);
|
||||
|
||||
vector signed int expmask = __vec_splatsi4(0x7F800000);
|
||||
vector signed int xexp =
|
||||
vec_add( vec_sr(vec_and((vector signed int)x, expmask), __vec_splatsu4(23)), __vec_splatsi4(-126) );
|
||||
x = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask);
|
||||
|
||||
vector unsigned int mask = (vector unsigned int)vec_cmpgt( __vec_splatsf4(0.7071067811865f), x);
|
||||
x = vec_sel(x , vec_add(x, x) , mask);
|
||||
xexp = vec_sel(xexp, vec_sub(xexp, __vec_splatsi4(1)), mask);
|
||||
|
||||
vector float x1 = vec_sub(x , ones);
|
||||
vector float z = _divf4 (x1, vec_add(x, ones));
|
||||
vector float w = vec_madd(z , z, (vector float)zeros);
|
||||
vector float polywneg;
|
||||
polywneg = vec_madd(__vec_splatsf4(__LOG10F_c0), w, __vec_splatsf4(__LOG10F_c1));
|
||||
polywneg = vec_madd(polywneg , w, __vec_splatsf4(__LOG10F_c2));
|
||||
|
||||
vector float y = vec_madd(z, vec_madd(polywneg, w, x1), (vector float)zeros);
|
||||
vector float wnew = vec_ctf(xexp,0);
|
||||
|
||||
vector float zz1 = vec_madd(__vec_splatsf4(__LOG10F_logaemsb), x1,
|
||||
vec_madd(__vec_splatsf4(__LOG10F_loga2msb),wnew,(vector float)zeros));
|
||||
vector float zz2 = vec_madd(__vec_splatsf4(__LOG10F_logaelsb), x1,
|
||||
vec_madd(__vec_splatsf4(__LOG10F_loga2lsb), wnew,
|
||||
vec_madd(__vec_splatsf4(__LOG10F_neglogae),y,(vector float)zeros))
|
||||
);
|
||||
|
||||
return vec_add(zz1, zz2);
|
||||
}
|
||||
|
||||
#endif
|
||||
61
Extras/simdmathlibrary/ppu/simdmath/log1pf4.h
Normal file
61
Extras/simdmathlibrary/ppu/simdmath/log1pf4.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* log1pf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_LOG1PF4_H___
|
||||
#define ___SIMD_MATH_LOG1PF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/logf4.h>
|
||||
#include <simdmath/divf4.h>
|
||||
|
||||
static inline vector float
|
||||
_log1pf4 (vector float x)
|
||||
{
|
||||
vector unsigned int nearzeromask =
|
||||
(vector unsigned int)vec_and(vec_cmpgt(x, __vec_splatsf4(-0.5f)),
|
||||
vec_cmpgt(__vec_splatsf4(0.5f), x));
|
||||
vector float x2 = vec_madd(x,x,__vec_splatsf4(0.0f));
|
||||
vector float d0, d1, n0, n1;
|
||||
|
||||
d0 = vec_madd(x , __vec_splatsf4(1.5934420741f), __vec_splatsf4(0.8952856868f));
|
||||
d1 = vec_madd(x , __vec_splatsf4(0.1198195734f), __vec_splatsf4(0.8377145063f));
|
||||
d1 = vec_madd(x2, d1, d0);
|
||||
|
||||
n0 = vec_madd(x , __vec_splatsf4(1.1457993413f), __vec_splatsf4(0.8952856678f));
|
||||
n1 = vec_madd(x , __vec_splatsf4(0.0082862580f), __vec_splatsf4(0.3394238808f));
|
||||
n1 = vec_madd(x2, n1, n0);
|
||||
|
||||
return vec_sel(_logf4(vec_add(x, __vec_splatsf4(1.0f))),
|
||||
vec_madd(x, _divf4(n1, d1), __vec_splatsf4(0.0f)),
|
||||
nearzeromask);
|
||||
}
|
||||
|
||||
#endif
|
||||
77
Extras/simdmathlibrary/ppu/simdmath/log2f4.h
Normal file
77
Extras/simdmathlibrary/ppu/simdmath/log2f4.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* log2f4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_LOG2F4_H___
|
||||
#define ___SIMD_MATH_LOG2F4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/divf4.h>
|
||||
|
||||
|
||||
#define __LOG2F_l2emsb 1.4426950216293f
|
||||
#define __LOG2F_l2elsb 1.9259629911e-8f
|
||||
#define __LOG2F_negl2e -1.4426950408890f
|
||||
|
||||
#define __LOG2F_c0 -0.2988439998f
|
||||
#define __LOG2F_c1 -0.3997655209f
|
||||
#define __LOG2F_c2 -0.6666679125f
|
||||
|
||||
static inline vector float
|
||||
_log2f4 (vector float x)
|
||||
{
|
||||
vector signed int zeros = __vec_splatsi4(0);
|
||||
vector float ones = __vec_splatsf4(1.0f);
|
||||
|
||||
vector signed int expmask = __vec_splatsi4(0x7F800000);
|
||||
vector signed int xexp =
|
||||
vec_add( vec_sr(vec_and((vector signed int)x, expmask), __vec_splatsu4(23)), __vec_splatsi4(-126) );
|
||||
x = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask);
|
||||
|
||||
vector unsigned int mask = (vector unsigned int)vec_cmpgt( __vec_splatsf4(0.7071067811865f), x);
|
||||
x = vec_sel(x , vec_add(x, x) , mask);
|
||||
xexp = vec_sel(xexp, vec_sub(xexp, __vec_splatsi4(1) ), mask);
|
||||
|
||||
vector float x1 = vec_sub(x , ones);
|
||||
vector float z = _divf4(x1, vec_add(x, ones));
|
||||
vector float w = vec_madd(z , z, (vector float)zeros);
|
||||
vector float polywneg;
|
||||
polywneg = vec_madd(__vec_splatsf4(__LOG2F_c0), w, __vec_splatsf4(__LOG2F_c1));
|
||||
polywneg = vec_madd(polywneg , w, __vec_splatsf4(__LOG2F_c2));
|
||||
|
||||
vector float y = vec_madd(z, vec_madd(polywneg, w, x1), (vector float)zeros);
|
||||
vector float zz1 = vec_madd(__vec_splatsf4(__LOG2F_l2emsb), x1, vec_ctf(xexp,0));
|
||||
vector float zz2 = vec_madd(__vec_splatsf4(__LOG2F_l2elsb), x1,
|
||||
vec_madd(__vec_splatsf4(__LOG2F_negl2e), y, (vector float)zeros));
|
||||
|
||||
return vec_add(zz1,zz2);
|
||||
}
|
||||
|
||||
#endif
|
||||
48
Extras/simdmathlibrary/ppu/simdmath/logbf4.h
Normal file
48
Extras/simdmathlibrary/ppu/simdmath/logbf4.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* logbf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_LOGBF4_H___
|
||||
#define ___SIMD_MATH_LOGBF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector float
|
||||
_logbf4 (vector float x)
|
||||
{
|
||||
vector signed int e1 = vec_and((vector signed int)x, __vec_splatsi4(0x7F800000));
|
||||
vector unsigned int zeromask = (vector unsigned int)vec_cmpeq(e1, __vec_splatsi4(0));
|
||||
e1 = vec_sub(e1, __vec_splatsi4(0x3F800000));
|
||||
return vec_sel(vec_ctf(e1,23), __vec_splatsf4(-HUGE_VALF), zeromask);
|
||||
}
|
||||
|
||||
#endif
|
||||
77
Extras/simdmathlibrary/ppu/simdmath/logf4.h
Normal file
77
Extras/simdmathlibrary/ppu/simdmath/logf4.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* logf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_LOGF4_H___
|
||||
#define ___SIMD_MATH_LOGF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/divf4.h>
|
||||
|
||||
|
||||
#define __LOGF_ln2msb 0.6931470632553f
|
||||
#define __LOGF_negln2lsb -1.1730463525e-7f
|
||||
|
||||
#define __LOGF_c0 -0.2988439998f
|
||||
#define __LOGF_c1 -0.3997655209f
|
||||
#define __LOGF_c2 -0.6666679125f
|
||||
|
||||
static inline vector float
|
||||
_logf4 (vector float x)
|
||||
{
|
||||
vector signed int zeros = __vec_splatsi4(0);
|
||||
vector float ones = __vec_splatsf4(1.0f);
|
||||
|
||||
vector signed int expmask = __vec_splatsi4(0x7F800000);
|
||||
vector signed int xexp =
|
||||
vec_add( vec_sr(vec_and((vector signed int)x, expmask), __vec_splatsu4(23)), __vec_splatsi4(-126) );
|
||||
x = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask);
|
||||
|
||||
|
||||
vector unsigned int mask = (vector unsigned int)vec_cmpgt(__vec_splatsf4(0.7071067811865f), x);
|
||||
x = vec_sel(x , vec_add(x, x) , mask);
|
||||
xexp = vec_sel(xexp, vec_sub(xexp,__vec_splatsi4(1)), mask);
|
||||
|
||||
vector float x1 = vec_sub(x , ones);
|
||||
vector float z = _divf4 (x1, vec_add(x, ones));
|
||||
vector float w = vec_madd(z , z, (vector float)zeros);
|
||||
vector float polywneg;
|
||||
polywneg = vec_madd(__vec_splatsf4(__LOGF_c0), w, __vec_splatsf4(__LOGF_c1));
|
||||
polywneg = vec_madd(polywneg , w, __vec_splatsf4(__LOGF_c2));
|
||||
|
||||
vector float y = vec_madd(z, vec_madd(polywneg, w, x1), (vector float)zeros);
|
||||
vector float wnew = vec_ctf(xexp,0);
|
||||
vector float zz1 = vec_madd(__vec_splatsf4(__LOGF_ln2msb) , wnew, x1);
|
||||
vector float zz2neg = vec_madd(__vec_splatsf4(__LOGF_negln2lsb), wnew, y );
|
||||
|
||||
return vec_sub(zz1,zz2neg);
|
||||
}
|
||||
|
||||
#endif
|
||||
53
Extras/simdmathlibrary/ppu/simdmath/modff4.h
Normal file
53
Extras/simdmathlibrary/ppu/simdmath/modff4.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* modff4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_MODFF4_H___
|
||||
#define ___SIMD_MATH_MODFF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/truncf4.h>
|
||||
|
||||
// modff4 - for each of four float slots, compute fractional and integral parts.
|
||||
// Returns fractional part and stores integral part in *iptr.
|
||||
|
||||
static inline vector float
|
||||
_modff4 (vector float x, vector float *iptr)
|
||||
{
|
||||
vector float integral, fraction;
|
||||
|
||||
integral = _truncf4( x );
|
||||
fraction = vec_sub( x, integral );
|
||||
|
||||
*iptr = integral;
|
||||
return fraction;
|
||||
}
|
||||
|
||||
#endif
|
||||
44
Extras/simdmathlibrary/ppu/simdmath/negatef4.h
Normal file
44
Extras/simdmathlibrary/ppu/simdmath/negatef4.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* negatef4 - for each of four float slots, negate the sign bit.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_NEGATEF4_H___
|
||||
#define ___SIMD_MATH_NEGATEF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector float
|
||||
_negatef4 (vector float x)
|
||||
{
|
||||
return (vector float)vec_xor( (vector unsigned int)x, __vec_splatsu4(0x80000000) );
|
||||
}
|
||||
|
||||
#endif
|
||||
45
Extras/simdmathlibrary/ppu/simdmath/negatei4.h
Normal file
45
Extras/simdmathlibrary/ppu/simdmath/negatei4.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* negatei4 - for each of four int slots, negate the sign bit.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_NEGATEI4_H___
|
||||
#define ___SIMD_MATH_NEGATEI4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector signed int
|
||||
_negatei4 (vector signed int x)
|
||||
{
|
||||
vector signed int zero = __vec_splatsi4(0);
|
||||
return vec_sub (zero, x);
|
||||
}
|
||||
|
||||
#endif
|
||||
61
Extras/simdmathlibrary/ppu/simdmath/powf4.h
Normal file
61
Extras/simdmathlibrary/ppu/simdmath/powf4.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* exp2f4
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_POWF4_H___
|
||||
#define ___SIMD_MATH_POWF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <simdmath/exp2f4.h>
|
||||
#include <simdmath/log2f4.h>
|
||||
|
||||
static inline vector float
|
||||
_powf4 (vector float x, vector float y)
|
||||
{
|
||||
vector signed int zeros = __vec_splatsi4(0);
|
||||
vector unsigned int zeromask = (vector unsigned int)vec_cmpeq((vector float)zeros, x);
|
||||
|
||||
vector unsigned int negmask = (vector unsigned int)vec_cmpgt((vector float)zeros, x);
|
||||
|
||||
vector float sbit = (vector float)(__vec_splatsi4(0x80000000));
|
||||
vector float absx = vec_andc(x, sbit);
|
||||
vector float absy = vec_andc(y, sbit);
|
||||
vector unsigned int oddy = vec_and(vec_ctu(absy, 0), __vec_splatsu4(0x00000001));
|
||||
negmask = vec_and(negmask, (vector unsigned int)vec_cmpgt(oddy, (vector unsigned int)zeros));
|
||||
|
||||
vector float res = _exp2f4(vec_madd(y, _log2f4(absx), (vector float)zeros));
|
||||
res = vec_sel(res, vec_or(sbit, res), negmask);
|
||||
|
||||
|
||||
return vec_sel(res, (vector float)zeros, zeromask);
|
||||
}
|
||||
|
||||
#endif
|
||||
50
Extras/simdmathlibrary/ppu/simdmath/recipf4.h
Normal file
50
Extras/simdmathlibrary/ppu/simdmath/recipf4.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* recipf4 - for each of four float slots, compute reciprocal.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_RECIPF4_H___
|
||||
#define ___SIMD_MATH_RECIPF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
static inline vector float
|
||||
_recipf4 (vector float x)
|
||||
{
|
||||
// Reciprocal estimate and 1 Newton-Raphson iteration.
|
||||
|
||||
vector float y0;
|
||||
vector float ones = __vec_splatsf4(1.0f);
|
||||
|
||||
y0 = vec_re( x );
|
||||
return vec_madd( vec_nmsub( x, y0, ones), y0, y0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
57
Extras/simdmathlibrary/ppu/simdmath/rsqrtf4.h
Normal file
57
Extras/simdmathlibrary/ppu/simdmath/rsqrtf4.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* sqrtf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_RSQRTF4_H___
|
||||
#define ___SIMD_MATH_RSQRTF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
// rsqrtf4 - for each of four float slots, compute reciprocal square root.
|
||||
// Undefined if input < 0.
|
||||
|
||||
static inline vector float
|
||||
_rsqrtf4 (vector float x)
|
||||
{
|
||||
// Reciprocal square root estimate and 1 Newton-Raphson iteration.
|
||||
|
||||
vector float zero = __vec_splatsf4(0.0f);
|
||||
vector float half = __vec_splatsf4(0.5f);
|
||||
vector float one = __vec_splatsf4(1.0f);
|
||||
vector float y0, y0x, y0half;
|
||||
|
||||
y0 = vec_rsqrte( x );
|
||||
y0x = vec_madd( y0, x, zero );
|
||||
y0half = vec_madd( y0, half, zero );
|
||||
return vec_madd( vec_nmsub( y0, y0x, one ), y0half, y0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
113
Extras/simdmathlibrary/ppu/simdmath/sincosf4.h
Normal file
113
Extras/simdmathlibrary/ppu/simdmath/sincosf4.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/* sincosf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_SINCOSF4_H___
|
||||
#define ___SIMD_MATH_SINCOSF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_sincos.h>
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
//
|
||||
// Computes both the sine and cosine of the all four slots of x
|
||||
// by using a polynomial approximation.
|
||||
//
|
||||
static inline void
|
||||
_sincosf4 (vector float x, vector float *s, vector float *c)
|
||||
{
|
||||
vector float xl,xl2,xl3;
|
||||
vector signed int q;
|
||||
vector signed int offsetSin, offsetCos;
|
||||
|
||||
// Range reduction using : xl = angle * TwoOverPi;
|
||||
//
|
||||
xl = vec_madd(x, __vec_splatsf4(0.63661977236f),__vec_splatsf4(0.0f));
|
||||
|
||||
// Find the quadrant the angle falls in
|
||||
// using: q = (int) (ceil(abs(xl))*sign(xl))
|
||||
//
|
||||
xl = vec_add(xl,vec_sel(__vec_splatsf4(0.5f),xl,__vec_splatsu4(0x80000000)));
|
||||
q = vec_cts(xl,0);
|
||||
|
||||
|
||||
// Compute the offset based on the quadrant that the angle falls in.
|
||||
// Add 1 to the offset for the cosine.
|
||||
//
|
||||
offsetSin = vec_and(q,__vec_splatsi4((int)0x3));
|
||||
offsetCos = vec_add(__vec_splatsi4(1),offsetSin);
|
||||
|
||||
// Remainder in range [-pi/4..pi/4]
|
||||
//
|
||||
vector float qf = vec_ctf(q,0);
|
||||
vector float p1 = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC1),x);
|
||||
xl = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC2),p1);
|
||||
|
||||
// Compute x^2 and x^3
|
||||
//
|
||||
xl2 = vec_madd(xl,xl,__vec_splatsf4(0.0f));
|
||||
xl3 = vec_madd(xl2,xl,__vec_splatsf4(0.0f));
|
||||
|
||||
|
||||
// Compute both the sin and cos of the angles
|
||||
// using a polynomial expression:
|
||||
// cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and
|
||||
// sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2)
|
||||
//
|
||||
vector float ct1 = vec_madd(__vec_splatsf4(__SINCOSF_CC0),xl2,__vec_splatsf4(__SINCOSF_CC1));
|
||||
vector float st1 = vec_madd(__vec_splatsf4(__SINCOSF_SC0),xl2,__vec_splatsf4(__SINCOSF_SC1));
|
||||
|
||||
vector float ct2 = vec_madd(ct1,xl2,__vec_splatsf4(__SINCOSF_CC2));
|
||||
vector float st2 = vec_madd(st1,xl2,__vec_splatsf4(__SINCOSF_SC2));
|
||||
|
||||
vector float cx = vec_madd(ct2,xl2,__vec_splatsf4(1.0f));
|
||||
vector float sx = vec_madd(st2,xl3,xl);
|
||||
|
||||
// Use the cosine when the offset is odd and the sin
|
||||
// when the offset is even
|
||||
//
|
||||
vector unsigned int sinMask =
|
||||
(vector unsigned int)vec_cmpeq(vec_and(offsetSin,__vec_splatsi4(0x1)),__vec_splatsi4(0));
|
||||
vector unsigned int cosMask =
|
||||
(vector unsigned int)vec_cmpeq(vec_and(offsetCos,__vec_splatsi4(0x1)),__vec_splatsi4(0));
|
||||
*s = vec_sel(cx,sx,sinMask);
|
||||
*c = vec_sel(cx,sx,cosMask);
|
||||
|
||||
// Flip the sign of the result when (offset mod 4) = 1 or 2
|
||||
//
|
||||
sinMask = (vector unsigned int)vec_cmpeq(vec_and(offsetSin,__vec_splatsi4(0x2)),__vec_splatsi4(0));
|
||||
cosMask = (vector unsigned int)vec_cmpeq(vec_and(offsetCos,__vec_splatsi4(0x2)),__vec_splatsi4(0));
|
||||
|
||||
*s = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000),(vector unsigned int)*s),*s,sinMask);
|
||||
*c = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000),(vector unsigned int)*c),*c,cosMask);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
107
Extras/simdmathlibrary/ppu/simdmath/sinf4.h
Normal file
107
Extras/simdmathlibrary/ppu/simdmath/sinf4.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/* sinf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_SINF4_H___
|
||||
#define ___SIMD_MATH_SINF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_sincos.h>
|
||||
#include <simdmath/_vec_utils.h>
|
||||
//
|
||||
// Computes the sine of each of the four slots
|
||||
// by using a polynomial approximation.
|
||||
//
|
||||
|
||||
static inline vector float
|
||||
_sinf4 (vector float x)
|
||||
{
|
||||
vector float xl,xl2,xl3,res;
|
||||
vector signed int q;
|
||||
|
||||
// Range reduction using : xl = angle * TwoOverPi;
|
||||
//
|
||||
xl = vec_madd(x, __vec_splatsf4(0.63661977236f),__vec_splatsf4(0.0f));
|
||||
|
||||
// Find the quadrant the angle falls in
|
||||
// using: q = (int) (ceil(abs(xl))*sign(xl))
|
||||
//
|
||||
xl = vec_add(xl,vec_sel(__vec_splatsf4(0.5f),xl,__vec_splatsu4(0x80000000)));
|
||||
q = vec_cts(xl,0);
|
||||
|
||||
|
||||
// Compute an offset based on the quadrant that the angle falls in
|
||||
//
|
||||
vector signed int offset = vec_and(q,__vec_splatsi4((int)0x3));
|
||||
|
||||
// Remainder in range [-pi/4..pi/4]
|
||||
//
|
||||
vector float qf = vec_ctf(q,0);
|
||||
vector float p1 = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC1),x);
|
||||
xl = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC2),p1);
|
||||
|
||||
// Compute x^2 and x^3
|
||||
//
|
||||
xl2 = vec_madd(xl,xl,__vec_splatsf4(0.0f));
|
||||
xl3 = vec_madd(xl2,xl,__vec_splatsf4(0.0f));
|
||||
|
||||
|
||||
// Compute both the sin and cos of the angles
|
||||
// using a polynomial expression:
|
||||
// cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and
|
||||
// sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2)
|
||||
//
|
||||
vector float ct1 = vec_madd(__vec_splatsf4(__SINCOSF_CC0),xl2,__vec_splatsf4(__SINCOSF_CC1));
|
||||
vector float st1 = vec_madd(__vec_splatsf4(__SINCOSF_SC0),xl2,__vec_splatsf4(__SINCOSF_SC1));
|
||||
|
||||
vector float ct2 = vec_madd(ct1,xl2,__vec_splatsf4(__SINCOSF_CC2));
|
||||
vector float st2 = vec_madd(st1,xl2,__vec_splatsf4(__SINCOSF_SC2));
|
||||
|
||||
vector float cx = vec_madd(ct2,xl2,__vec_splatsf4(1.0f));
|
||||
vector float sx = vec_madd(st2,xl3,xl);
|
||||
|
||||
// Use the cosine when the offset is odd and the sin
|
||||
// when the offset is even
|
||||
//
|
||||
vector unsigned int mask1 = (vector unsigned int)vec_cmpeq(vec_and(offset,
|
||||
__vec_splatsi4(0x1)),
|
||||
__vec_splatsi4((int)(0)));
|
||||
res = vec_sel(cx,sx,mask1);
|
||||
|
||||
// Flip the sign of the result when (offset mod 4) = 1 or 2
|
||||
//
|
||||
vector unsigned int mask2 =
|
||||
(vector unsigned int)vec_cmpeq(vec_and(offset,__vec_splatsi4(0x2)),__vec_splatsi4((int)0));
|
||||
res = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000U),(vector unsigned int)res),res,mask2);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
59
Extras/simdmathlibrary/ppu/simdmath/sqrtf4.h
Normal file
59
Extras/simdmathlibrary/ppu/simdmath/sqrtf4.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* sqrtf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_SQRTF4_H___
|
||||
#define ___SIMD_MATH_SQRTF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_vec_utils.h>
|
||||
|
||||
// sqrtf4 - for each of four float slots, compute square root.
|
||||
// Undefined if input < 0.
|
||||
|
||||
static inline vector float
|
||||
_sqrtf4 (vector float x)
|
||||
{
|
||||
// Reciprocal square root estimate and 1 Newton-Raphson iteration.
|
||||
|
||||
vector float zero = __vec_splatsf4(0.0f);
|
||||
vector float half = __vec_splatsf4(0.5f);
|
||||
vector float one = __vec_splatsf4(1.0f);
|
||||
vector float y0, y0x, y0xhalf;
|
||||
vector unsigned int cmp_zero;
|
||||
|
||||
y0 = vec_rsqrte( x );
|
||||
cmp_zero = (vector unsigned int)vec_cmpeq( x, zero );
|
||||
y0x = vec_madd( y0, x, zero );
|
||||
y0xhalf = vec_madd( y0x, half, zero );
|
||||
return vec_sel( vec_madd( vec_nmsub( y0, y0x, one ), y0xhalf, y0x ), zero, cmp_zero );
|
||||
}
|
||||
|
||||
#endif
|
||||
98
Extras/simdmathlibrary/ppu/simdmath/tanf4.h
Normal file
98
Extras/simdmathlibrary/ppu/simdmath/tanf4.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* tanf4 -
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_TANF4_H___
|
||||
#define ___SIMD_MATH_TANF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
#include <simdmath/_sincos.h>
|
||||
#include <simdmath/divf4.h>
|
||||
|
||||
//
|
||||
// Computes the tangent of all four slots of x by using a polynomia approximation.
|
||||
//
|
||||
static inline vector float
|
||||
_tanf4 (vector float x)
|
||||
{
|
||||
vector float xl,xl2,xl3,res;
|
||||
vector signed int q;
|
||||
|
||||
// Range reduction using : xl = angle * TwoOverPi;
|
||||
//
|
||||
xl = vec_madd(x, __vec_splatsf4(0.63661977236f),__vec_splatsf4(0.0f));
|
||||
|
||||
// Find the quadrant the angle falls in
|
||||
// using: q = (int) (ceil(abs(x))*sign(x))
|
||||
//
|
||||
xl = vec_add(xl,vec_sel(__vec_splatsf4(0.5f),xl,__vec_splatsu4(0x80000000)));
|
||||
q = vec_cts(xl,0);
|
||||
|
||||
|
||||
// Remainder in range [-pi/4..pi/4]
|
||||
//
|
||||
vector float qf = vec_ctf(q,0);
|
||||
vector float p1 = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC1),x);
|
||||
xl = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC2),p1);
|
||||
|
||||
// Compute x^2 and x^3
|
||||
//
|
||||
xl2 = vec_madd(xl,xl,__vec_splatsf4(0.0f));
|
||||
xl3 = vec_madd(xl2,xl,__vec_splatsf4(0.0f));
|
||||
|
||||
// Compute both the sin and cos of the angles
|
||||
// using a polynomial expression:
|
||||
// cx = 1.0f + x2 * (C0 * x2 + C1), and
|
||||
// sx = xl + x3 * S0
|
||||
//
|
||||
vector float ct2 = vec_madd(__vec_splatsf4( 0.0097099364f),xl2,__vec_splatsf4(-0.4291161787f));
|
||||
|
||||
vector float cx = vec_madd(ct2,xl2,__vec_splatsf4(1.0f));
|
||||
vector float sx = vec_madd(__vec_splatsf4(-0.0957822992f),xl3,xl);
|
||||
|
||||
|
||||
// Compute both cx/sx and sx/cx
|
||||
//
|
||||
vector float cxosx = _divf4(cx,sx);
|
||||
vector float sxocx = _divf4(sx,cx);
|
||||
|
||||
vector float ncxosx = (vector float)vec_xor(__vec_splatsu4(0x80000000),(vector unsigned int)cxosx);
|
||||
|
||||
// For odd numbered quadrants return -cx/sx , otherwise return
|
||||
// sx/cx
|
||||
//
|
||||
vector unsigned int mask =
|
||||
(vector unsigned int)vec_cmpeq(vec_and(q,__vec_splatsi4(0x1)),__vec_splatsi4(0));
|
||||
res = vec_sel(ncxosx,sxocx,mask);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
43
Extras/simdmathlibrary/ppu/simdmath/truncf4.h
Normal file
43
Extras/simdmathlibrary/ppu/simdmath/truncf4.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* truncf4 - for each of four float slots, round towards zero to integer value.
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ___SIMD_MATH_TRUNCF4_H___
|
||||
#define ___SIMD_MATH_TRUNCF4_H___
|
||||
|
||||
#include <simdmath.h>
|
||||
#include <altivec.h>
|
||||
|
||||
|
||||
static inline vector float
|
||||
_truncf4 (vector float x)
|
||||
{
|
||||
return vec_trunc( x );
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user