@@ -211,30 +211,29 @@ public static TVectorSingle CosSingle<TVectorSingle, TVectorInt32, TVectorDouble
211
211
const int ARG_SMALLER = 0x39000000 ; // 2^-27
212
212
213
213
TVectorSingle ax = TVectorSingle . Abs ( x ) ;
214
- TVectorInt32 ux = Unsafe . BitCast < TVectorSingle , TVectorInt32 > ( x ) ;
214
+ TVectorInt32 ux = Unsafe . BitCast < TVectorSingle , TVectorInt32 > ( ax ) ;
215
215
216
216
TVectorSingle result ;
217
217
218
- if ( TVectorSingle . LessThanOrEqualAll ( ax , TVectorSingle . Create ( ARG_LARGE ) ) )
218
+ if ( TVectorInt32 . LessThanOrEqualAll ( ux , TVectorInt32 . Create ( ARG_LARGE ) ) )
219
219
{
220
220
// We must be a finite value: (pi / 4) >= |x|
221
221
222
222
if ( TVectorInt32 . GreaterThanAny ( ux , TVectorInt32 . Create ( ARG_SMALL - 1 ) ) )
223
223
{
224
224
// at least one element is: |x| >= 2^-13
225
- TVectorSingle x2 = x * x ;
226
225
227
226
if ( TVectorSingle . Count == TVectorDouble . Count )
228
227
{
229
228
result = Narrow < TVectorDouble , TVectorSingle > (
230
- CosSingleSmall ( Widen < TVectorSingle , TVectorDouble > ( x2 ) )
229
+ CosSingleSmall ( Widen < TVectorSingle , TVectorDouble > ( x ) )
231
230
) ;
232
231
}
233
232
else
234
233
{
235
234
result = Narrow < TVectorDouble , TVectorSingle > (
236
- CosSingleSmall ( WidenLower < TVectorSingle , TVectorDouble > ( x2 ) ) ,
237
- CosSingleSmall ( WidenUpper < TVectorSingle , TVectorDouble > ( x2 ) )
235
+ CosSingleSmall ( WidenLower < TVectorSingle , TVectorDouble > ( x ) ) ,
236
+ CosSingleSmall ( WidenUpper < TVectorSingle , TVectorDouble > ( x ) )
238
237
) ;
239
238
}
240
239
}
@@ -1760,8 +1759,8 @@ public static (TVectorDouble Sin, TVectorDouble Cos) SinCosDouble<TVectorDouble,
1760
1759
1761
1760
sinResult = TVectorDouble . ConditionalSelect (
1762
1761
Unsafe . BitCast < TVectorInt64 , TVectorDouble > ( TVectorInt64 . Equals ( ( ( sign & region ) | ( ~ sign & ~ region ) ) & TVectorInt64 . One , TVectorInt64 . Zero ) ) ,
1763
- - sinResult , // negative in region 1 or 3, positive in region 0 or 2
1764
- + sinResult // negative in region 0 or 2, positive in region 1 or 3
1762
+ + sinResult , // negative in region 1 or 3, positive in region 0 or 2
1763
+ - sinResult // negative in region 0 or 2, positive in region 1 or 3
1765
1764
) ;
1766
1765
1767
1766
cosResult = TVectorDouble . ConditionalSelect (
@@ -1838,11 +1837,11 @@ public static (TVectorSingle Sin, TVectorSingle Cos) SinCosSingle<TVectorSingle,
1838
1837
const int ARG_SMALLER = 0x39000000 ; // 2^-27
1839
1838
1840
1839
TVectorSingle ax = TVectorSingle . Abs ( x ) ;
1841
- TVectorInt32 ux = Unsafe . BitCast < TVectorSingle , TVectorInt32 > ( x ) ;
1840
+ TVectorInt32 ux = Unsafe . BitCast < TVectorSingle , TVectorInt32 > ( ax ) ;
1842
1841
1843
1842
TVectorSingle sinResult , cosResult ;
1844
1843
1845
- if ( TVectorSingle . LessThanOrEqualAll ( ax , TVectorSingle . Create ( ARG_LARGE ) ) )
1844
+ if ( TVectorInt32 . LessThanOrEqualAll ( ux , TVectorInt32 . Create ( ARG_LARGE ) ) )
1846
1845
{
1847
1846
// We must be a finite value: (pi / 4) >= |x|
1848
1847
@@ -1982,8 +1981,8 @@ public static (TVectorSingle Sin, TVectorSingle Cos) SinCosSingle<TVectorSingle,
1982
1981
1983
1982
sinResult = TVectorDouble . ConditionalSelect (
1984
1983
Unsafe . BitCast < TVectorInt64 , TVectorDouble > ( TVectorInt64 . Equals ( ( ( sign & region ) | ( ~ sign & ~ region ) ) & TVectorInt64 . One , TVectorInt64 . Zero ) ) ,
1985
- - sinResult , // negative in region 1 or 3, positive in region 0 or 2
1986
- + sinResult // negative in region 0 or 2, positive in region 1 or 3
1984
+ + sinResult , // negative in region 1 or 3, positive in region 0 or 2
1985
+ - sinResult // negative in region 0 or 2, positive in region 1 or 3
1987
1986
) ;
1988
1987
1989
1988
cosResult = TVectorDouble . ConditionalSelect (
@@ -2095,8 +2094,8 @@ public static TVectorDouble SinDouble<TVectorDouble, TVectorInt64>(TVectorDouble
2095
2094
2096
2095
result = TVectorDouble . ConditionalSelect (
2097
2096
Unsafe . BitCast < TVectorInt64 , TVectorDouble > ( TVectorInt64 . Equals ( ( ( sign & region ) | ( ~ sign & ~ region ) ) & TVectorInt64 . One , TVectorInt64 . Zero ) ) ,
2098
- - result , // negative in region 1 or 3, positive in region 0 or 2
2099
- + result // negative in region 0 or 2, positive in region 1 or 3
2097
+ + result , // negative in region 1 or 3, positive in region 0 or 2
2098
+ - result // negative in region 0 or 2, positive in region 1 or 3
2100
2099
) ;
2101
2100
2102
2101
// Propagate the NaN that was passed in
@@ -2183,11 +2182,11 @@ public static TVectorSingle SinSingle<TVectorSingle, TVectorInt32, TVectorDouble
2183
2182
const int ARG_SMALLER = 0x39000000 ; // 2^-27
2184
2183
2185
2184
TVectorSingle ax = TVectorSingle . Abs ( x ) ;
2186
- TVectorInt32 ux = Unsafe . BitCast < TVectorSingle , TVectorInt32 > ( x ) ;
2185
+ TVectorInt32 ux = Unsafe . BitCast < TVectorSingle , TVectorInt32 > ( ax ) ;
2187
2186
2188
2187
TVectorSingle result ;
2189
2188
2190
- if ( TVectorSingle . LessThanOrEqualAll ( ax , TVectorSingle . Create ( ARG_LARGE ) ) )
2189
+ if ( TVectorInt32 . LessThanOrEqualAll ( ux , TVectorInt32 . Create ( ARG_LARGE ) ) )
2191
2190
{
2192
2191
// We must be a finite value: (pi / 4) >= |x|
2193
2192
@@ -2274,8 +2273,8 @@ static TVectorDouble CoreImpl(TVectorDouble x)
2274
2273
2275
2274
return TVectorDouble . ConditionalSelect (
2276
2275
Unsafe . BitCast < TVectorInt64 , TVectorDouble > ( TVectorInt64 . Equals ( ( ( sign & region ) | ( ~ sign & ~ region ) ) & TVectorInt64 . One , TVectorInt64 . Zero ) ) ,
2277
- - result , // negative in region 1 or 3, positive in region 0 or 2
2278
- + result // negative in region 0 or 2, positive in region 1 or 3
2276
+ + result , // negative in region 1 or 3, positive in region 0 or 2
2277
+ - result // negative in region 0 or 2, positive in region 1 or 3
2279
2278
) ;
2280
2279
}
2281
2280
}
0 commit comments