Skip to content

Commit

Permalink
some zero optim
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Nov 12, 2023
1 parent 3d375df commit e1e064d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
14 changes: 6 additions & 8 deletions include/kyosu/types/impl/detail/bessel_j.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ namespace kyosu::_
auto Q = Qm;
auto bds = bound_compute();

Z zero{};
size_t im = 1;
auto bound_not_reached = u_t(im) <= bds;
while (eve::any(bound_not_reached))
Expand All @@ -91,8 +90,8 @@ namespace kyosu::_
}
else
{
P += if_else( bound_not_reached, Pm, zero);
Q += if_else( bound_not_reached, Qm, zero);
P += if_else( bound_not_reached, Pm, eve::zero);
Q += if_else( bound_not_reached, Qm, eve::zero);
}
bound_not_reached = u_t(++im) <= bds;
}
Expand Down Expand Up @@ -192,7 +191,6 @@ namespace kyosu::_
auto P = Pm;
auto Q = Qm;
auto bds = bound_compute();
auto zero = Z{};
size_t im = 1;
auto bound_not_reached = u_t(im) <= bds;

Expand All @@ -208,8 +206,8 @@ namespace kyosu::_
}
else
{
P += kyosu::if_else(bound_not_reached, Pm, zero);
Q += kyosu::if_else(bound_not_reached, Qm, zero);
P += kyosu::if_else(bound_not_reached, Pm, eve::zero);
Q += kyosu::if_else(bound_not_reached, Qm, eve::zero);
}
bound_not_reached = u_t(++im) <= bds;
}
Expand Down Expand Up @@ -408,7 +406,7 @@ namespace kyosu::_
{
auto rz = rec(z);
return if_else(kyosu::abs(z) < eve::eps(eve::as(real(z)))
, eve::zero(eve::as(real(z)))
, eve::zero
, (sinc(z)-cos(z))*rz
);
}
Expand Down Expand Up @@ -456,7 +454,7 @@ namespace kyosu::_
auto scalej0 = (j0/jcur);
auto scalej1 = (j1/jnext);
res *= if_else(j0ltj1, scalej0, scalej1);
return if_else(is_eqz(z), Z{}, res);
return if_else(is_eqz(z), eve::zero, res);
}
else
{
Expand Down
5 changes: 2 additions & 3 deletions include/kyosu/types/impl/detail/besselj0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ namespace kyosu::_
auto Q = Qm;
auto bds = bound_compute();

Z zero{};
size_t im = 1;
auto bound_not_reached = u_t(im) <= bds;
while (eve::any(bound_not_reached))
Expand All @@ -90,8 +89,8 @@ namespace kyosu::_
}
else
{
P += if_else( bound_not_reached, Pm, zero);
Q += if_else( bound_not_reached, Qm, zero);
P += if_else( bound_not_reached, Pm, eve::zero);
Q += if_else( bound_not_reached, Qm, eve::zero);
}
bound_not_reached = u_t(++im) <= bds;
}
Expand Down
5 changes: 2 additions & 3 deletions include/kyosu/types/impl/detail/besselj1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ namespace kyosu::_
auto P = Pm;
auto Q = Qm;
auto bds = bound_compute();
auto zero = Z{};
size_t im = 1;
auto bound_not_reached = u_t(im) <= bds;

Expand All @@ -90,8 +89,8 @@ namespace kyosu::_
}
else
{
P += kyosu::if_else(bound_not_reached, Pm, zero);
Q += kyosu::if_else(bound_not_reached, Qm, zero);
P += kyosu::if_else(bound_not_reached, Pm, eve::zero);
Q += kyosu::if_else(bound_not_reached, Qm, eve::zero);
}
bound_not_reached = u_t(++im) <= bds;
}
Expand Down

0 comments on commit e1e064d

Please sign in to comment.