Skip to content

Commit

Permalink
using muli and mulmi
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Nov 17, 2023
1 parent da628a9 commit 62ab430
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
4 changes: 1 addition & 3 deletions include/kyosu/types/impl/detail/bessel_h.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace kyosu::_
{
if constexpr(concepts::complex<Z>)
{
auto muli = [](auto z){ auto [r, i] = z; return complex(-i, r); };
return cyl_bessel_jn(n, z)+muli(cyl_bessel_yn(n, z));
}
else
Expand All @@ -40,7 +39,6 @@ namespace kyosu::_
{
if constexpr(concepts::complex<Z>)
{
auto muli = [](auto z){ auto [r, i] = z; return complex(-i, r); };
return cyl_bessel_jn(n, z)-muli(cyl_bessel_yn(n, z));
}
else
Expand Down Expand Up @@ -111,7 +109,7 @@ namespace kyosu::_
using u_t = eve::underlying_type_t<Z>;
auto i = complex(u_t(0), u_t(1));
auto rz = rec(z);
auto miz = complex(ipart(z), -real(z));
auto miz = mulmi(z);
auto h0 = if_else(imzlt0, i*exp(miz), -i*exp(-miz))*rz;
if(n == 0) return h0;
auto h1 = if_else(imzlt0, (rz+i),(rz-i))*h0 ;
Expand Down
11 changes: 5 additions & 6 deletions include/kyosu/types/impl/detail/bessel_i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace kyosu::_
template<typename Z>
auto dispatch(eve::tag_of<kyosu::cyl_bessel_i0>, Z z) noexcept
{
return cyl_bessel_j0(complex(-ipart(z), real(z)));
return cyl_bessel_j0(muli(z));
}

//===-------------------------------------------------------------------------------------------
Expand All @@ -27,8 +27,7 @@ namespace kyosu::_
{
if constexpr(concepts::complex<Z> )
{
auto [r, i] = cyl_bessel_j1(complex(-ipart(z), real(z)));
return complex(i, -r);
return mulmi(cyl_bessel_j1(muli(z)));
}
else
{
Expand All @@ -52,7 +51,7 @@ namespace kyosu::_
else return complex(eve::zero(eve::as<e_t>()), eve::one(eve::as<e_t>()));
};
auto an = eve::abs(n);
return miton(an)*cyl_bessel_jn(an,complex(-ipart(z), real(z)));
return miton(an)*cyl_bessel_jn(an,muli(z));
}
else
{
Expand Down Expand Up @@ -115,7 +114,7 @@ namespace kyosu::_
else if (n%4 == 2) return complex(eve::mone(eve::as<e_t>()));
else return complex(eve::zero(eve::as<e_t>()), eve::mone(eve::as<e_t>()));
};
return iton(-n)*sph_bessel_jn(n,complex(-ipart(z), real(z)));
return iton(-n)*sph_bessel_jn(n,muli(z));
}
else
{
Expand Down Expand Up @@ -172,7 +171,7 @@ namespace kyosu::_
else if (n%4 == 2) return complex(eve::mone(eve::as<e_t>()));
else return complex(eve::zero(eve::as<e_t>()), eve::mone(eve::as<e_t>()));
};
return iton(-n-1)*sph_bessel_yn(n,complex(-ipart(z), real(z)));
return iton(-n-1)*sph_bessel_yn(n,muli(z));
}
else
{
Expand Down
4 changes: 1 addition & 3 deletions include/kyosu/types/impl/invtrig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,7 @@ namespace kyosu::_
{
if constexpr(concepts::complex<C> )
{
auto [r, i] = a0;
auto [r1, i1] = kyosu::asin(complex(-i, r));
return complex(i1, -r1); // -(eve::i*asin(eve::i*a0));
return mulmi( kyosu::asin(muli(a0)));
}
else
{
Expand Down
4 changes: 1 addition & 3 deletions include/kyosu/types/impl/special.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,7 @@ namespace kyosu::_
}
else
{
auto [rz, iz] = z;
auto tmp = erf(complex(-iz, rz));
return complex(imag(tmp), -real(tmp));
return mulmi(erf(muli(z)));
}
}
else
Expand Down

0 comments on commit 62ab430

Please sign in to comment.