Skip to content

Commit

Permalink
Fix CosSingle to be correct
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Jul 13, 2024
1 parent 19183c5 commit ba147a8
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,25 @@ public static TVectorSingle CosSingle<TVectorSingle, TVectorInt32, TVectorDouble

TVectorSingle result;

if (TVectorSingle.LessThanOrEqualAll(ax, TVectorSingle.Create(ARG_LARGE)))
if (TVectorInt32.LessThanOrEqualAll(ux, TVectorInt32.Create(ARG_LARGE)))
{
// We must be a finite value: (pi / 4) >= |x|

if (TVectorInt32.GreaterThanAny(ux, TVectorInt32.Create(ARG_SMALL - 1)))
{
// at least one element is: |x| >= 2^-13
TVectorSingle x2 = x * x;

if (TVectorSingle.Count == TVectorDouble.Count)
{
result = Narrow<TVectorDouble, TVectorSingle>(
CosSingleSmall(Widen<TVectorSingle, TVectorDouble>(x2))
CosSingleSmall(Widen<TVectorSingle, TVectorDouble>(x))
);
}
else
{
result = Narrow<TVectorDouble, TVectorSingle>(
CosSingleSmall(WidenLower<TVectorSingle, TVectorDouble>(x2)),
CosSingleSmall(WidenUpper<TVectorSingle, TVectorDouble>(x2))
CosSingleSmall(WidenLower<TVectorSingle, TVectorDouble>(x)),
CosSingleSmall(WidenUpper<TVectorSingle, TVectorDouble>(x))
);
}
}
Expand Down

0 comments on commit ba147a8

Please sign in to comment.