-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1eab828
commit 418bd3e
Showing
150 changed files
with
16,706 additions
and
35,554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
third_party/xsimd/arch/generic/xsimd_generic_arithmetic.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/*************************************************************************** | ||
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and * | ||
* Martin Renou * | ||
* Copyright (c) QuantStack * | ||
* Copyright (c) Serge Guelton * | ||
* * | ||
* Distributed under the terms of the BSD 3-Clause License. * | ||
* * | ||
* The full license is in the file LICENSE, distributed with this software. * | ||
****************************************************************************/ | ||
|
||
#ifndef XSIMD_GENERIC_ARITHMETIC_HPP | ||
#define XSIMD_GENERIC_ARITHMETIC_HPP | ||
|
||
#include <complex> | ||
#include <type_traits> | ||
|
||
#include "./xsimd_generic_details.hpp" | ||
|
||
namespace xsimd { | ||
|
||
namespace kernel { | ||
|
||
using namespace types; | ||
|
||
// bitwise_lshift | ||
template<class A, class T, class/*=typename std::enable_if<std::is_integral<T>::value, void>::type*/> | ||
batch<T, A> bitwise_lshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<generic>) { | ||
return detail::apply([](T x, T y) { return x << y;}, self, other); | ||
} | ||
|
||
// bitwise_rshift | ||
template<class A, class T, class/*=typename std::enable_if<std::is_integral<T>::value, void>::type*/> | ||
batch<T, A> bitwise_rshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<generic>) { | ||
return detail::apply([](T x, T y) { return x >> y;}, self, other); | ||
} | ||
|
||
// div | ||
template<class A, class T, class=typename std::enable_if<std::is_integral<T>::value, void>::type> | ||
batch<T, A> div(batch<T, A> const& self, batch<T, A> const& other, requires_arch<generic>) { | ||
return detail::apply([](T x, T y) -> T { return x / y;}, self, other); | ||
} | ||
|
||
// fma | ||
template<class A, class T> batch<T, A> fma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<generic>) { | ||
return x * y + z; | ||
} | ||
|
||
template<class A, class T> batch<std::complex<T>, A> fma(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<generic>) { | ||
auto res_r = fms(x.real(), y.real(), fms(x.imag(), y.imag(), z.real())); | ||
auto res_i = fma(x.real(), y.imag(), fma(x.imag(), y.real(), z.imag())); | ||
return {res_r, res_i}; | ||
} | ||
|
||
// fms | ||
template<class A, class T> batch<T, A> fms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<generic>) { | ||
return x * y - z; | ||
} | ||
|
||
template<class A, class T> batch<std::complex<T>, A> fms(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<generic>) { | ||
auto res_r = fms(x.real(), y.real(), fma(x.imag(), y.imag(), z.real())); | ||
auto res_i = fma(x.real(), y.imag(), fms(x.imag(), y.real(), z.imag())); | ||
return {res_r, res_i}; | ||
} | ||
|
||
// fnma | ||
template<class A, class T> batch<T, A> fnma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<generic>) { | ||
return -x * y + z; | ||
} | ||
|
||
template<class A, class T> batch<std::complex<T>, A> fnma(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<generic>) { | ||
auto res_r = - fms(x.real(), y.real(), fma(x.imag(), y.imag(), z.real())); | ||
auto res_i = - fma(x.real(), y.imag(), fms(x.imag(), y.real(), z.imag())); | ||
return {res_r, res_i}; | ||
} | ||
|
||
// fnms | ||
template<class A, class T> batch<T, A> fnms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<generic>) { | ||
return -x * y - z; | ||
} | ||
|
||
template<class A, class T> batch<std::complex<T>, A> fnms(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<generic>) { | ||
auto res_r = - fms(x.real(), y.real(), fms(x.imag(), y.imag(), z.real())); | ||
auto res_i = - fma(x.real(), y.imag(), fma(x.imag(), y.real(), z.imag())); | ||
return {res_r, res_i}; | ||
} | ||
|
||
|
||
|
||
// mul | ||
template<class A, class T, class/*=typename std::enable_if<std::is_integral<T>::value, void>::type*/> | ||
batch<T, A> mul(batch<T, A> const& self, batch<T, A> const& other, requires_arch<generic>) { | ||
return detail::apply([](T x, T y) -> T { return x * y;}, self, other); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/*************************************************************************** | ||
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and * | ||
* Martin Renou * | ||
* Copyright (c) QuantStack * | ||
* Copyright (c) Serge Guelton * | ||
* * | ||
* Distributed under the terms of the BSD 3-Clause License. * | ||
* * | ||
* The full license is in the file LICENSE, distributed with this software. * | ||
****************************************************************************/ | ||
|
||
#ifndef XSIMD_GENERIC_COMPLEX_HPP | ||
#define XSIMD_GENERIC_COMPLEX_HPP | ||
|
||
#include <complex> | ||
|
||
#include "./xsimd_generic_details.hpp" | ||
|
||
namespace xsimd { | ||
|
||
namespace kernel { | ||
|
||
using namespace types; | ||
|
||
// real | ||
template <class A, class T> | ||
batch<T, A> real(batch<T, A> const& self, requires_arch<generic>) { | ||
return self; | ||
} | ||
|
||
template <class A, class T> | ||
batch<T, A> real(batch<std::complex<T>, A> const& self, requires_arch<generic>) { | ||
return self.real(); | ||
} | ||
|
||
// imag | ||
template <class A, class T> | ||
batch<T, A> imag(batch<T, A> const& /*self*/, requires_arch<generic>) { | ||
return batch<T, A>(T(0)); | ||
} | ||
|
||
template <class A, class T> | ||
batch<T, A> imag(batch<std::complex<T>, A> const& self, requires_arch<generic>) { | ||
return self.imag(); | ||
} | ||
|
||
// arg | ||
template<class A, class T> | ||
real_batch_type_t<batch<T, A>> arg(batch<T, A> const& self, requires_arch<generic>) { | ||
return atan2(imag(self), real(self)); | ||
} | ||
|
||
// conj | ||
template<class A, class T> | ||
complex_batch_type_t<batch<T, A>> conj(batch<T, A> const& self, requires_arch<generic>) { | ||
return {real(self), - imag(self)}; | ||
} | ||
|
||
// norm | ||
template<class A, class T> | ||
real_batch_type_t<batch<T, A>> norm(batch<T, A> const& self, requires_arch<generic>) { | ||
return {fma(real(self), real(self), imag(self) * imag(self))}; | ||
} | ||
|
||
// proj | ||
template<class A, class T> | ||
complex_batch_type_t<batch<T, A>> proj(batch<T, A> const& self, requires_arch<generic>) { | ||
using batch_type = complex_batch_type_t<batch<T, A>>; | ||
using real_batch = typename batch_type::real_batch; | ||
using real_value_type = typename real_batch::value_type; | ||
auto cond = xsimd::isinf(real(self)) || xsimd::isinf(imag(self)); | ||
return select(cond, | ||
batch_type(constants::infinity<real_batch>(), | ||
copysign(real_batch(real_value_type(0)), imag(self))), | ||
batch_type(self)); | ||
} | ||
|
||
template <class A, class T> | ||
batch_bool<T, A> isnan(batch<std::complex<T>, A> const& self, requires_arch<generic>) { | ||
return batch_bool<T, A>(isnan(self.real()) || isnan(self.imag())); | ||
} | ||
} | ||
} | ||
|
||
#endif | ||
|
Oops, something went wrong.