diff --git a/include/teqp/models/multifluid.hpp b/include/teqp/models/multifluid.hpp index a8a8155d27c449b45ad4acb43602d9c0ca1f230b..6b01aa2584e2de85b43ed7559b24940c6bf9ccf4 100644 --- a/include/teqp/models/multifluid.hpp +++ b/include/teqp/models/multifluid.hpp @@ -433,42 +433,6 @@ T powi(const T& x, int n) { } } -template<typename T> -inline auto powIVi(const T& x, const Eigen::ArrayXi& e) { - //return e.binaryExpr(e.cast<T>(), [&x](const auto&& a_, const auto& e_) {return static_cast<T>(powi(x, a_)); }); - static Eigen::Array<T, Eigen::Dynamic, 1> o; - o.resize(e.size()); - for (auto i = 0; i < e.size(); ++i) { - o[i] = powi(x, e[i]); - } - return o; - //return e.cast<T>().unaryExpr([&x](const auto& e_) {return powi(x, e_); }).eval(); -} - -//template<typename T> -//auto powIV(const T& x, const Eigen::ArrayXd& e) { -// Eigen::Array<T, Eigen::Dynamic, 1> o = e.cast<T>(); -// return o.unaryExpr([&x](const auto& e_) {return powi(x, e_); } ).eval(); -//} - -template<typename T> -auto pow(const std::complex<T> &x, const Eigen::ArrayXd& e) { - Eigen::Array<std::complex<T>, Eigen::Dynamic, 1> o(e.size()); - for (auto i = 0; i < e.size(); ++i) { - o[i] = pow(x, e[i]); - } - return o; -} - -template<typename T> -auto pow(const mcx::MultiComplex<T> &x, const Eigen::ArrayXd& e) { - Eigen::Array<mcx::MultiComplex<T>, Eigen::Dynamic, 1> o(e.size()); - for (auto i = 0; i < e.size(); ++i) { - o[i] = pow(x, e[i]); - } - return o; -} - inline auto get_EOS_terms(const std::string& coolprop_root, const std::string& name) { using namespace nlohmann; diff --git a/include/teqp/types.hpp b/include/teqp/types.hpp index e84f21d80bc74268698862176ec4552bae12cb5f..bf1c1ba4bfca322f0b3e11d515d9b15597cff767 100644 --- a/include/teqp/types.hpp +++ b/include/teqp/types.hpp @@ -2,6 +2,8 @@ #include "nlohmann/json.hpp" +#include "MultiComplex/MultiComplex.hpp" + #include <vector> #include <valarray> #include <set> @@ -69,4 +71,40 @@ public: auto elap = std::chrono::duration<double>(std::chrono::steady_clock::now() - tic).count(); std::cout << elap / N * 1e6 << " us/call" << std::endl; } -}; \ No newline at end of file +}; + +template<typename T> +inline auto powIVi(const T& x, const Eigen::ArrayXi& e) { + //return e.binaryExpr(e.cast<T>(), [&x](const auto&& a_, const auto& e_) {return static_cast<T>(powi(x, a_)); }); + static Eigen::Array<T, Eigen::Dynamic, 1> o; + o.resize(e.size()); + for (auto i = 0; i < e.size(); ++i) { + o[i] = powi(x, e[i]); + } + return o; + //return e.cast<T>().unaryExpr([&x](const auto& e_) {return powi(x, e_); }).eval(); +} + +//template<typename T> +//auto powIV(const T& x, const Eigen::ArrayXd& e) { +// Eigen::Array<T, Eigen::Dynamic, 1> o = e.cast<T>(); +// return o.unaryExpr([&x](const auto& e_) {return powi(x, e_); } ).eval(); +//} + +template<typename T> +auto pow(const std::complex<T> &x, const Eigen::ArrayXd& e) { + Eigen::Array<std::complex<T>, Eigen::Dynamic, 1> o(e.size()); + for (auto i = 0; i < e.size(); ++i) { + o[i] = pow(x, e[i]); + } + return o; +} + +template<typename T> +auto pow(const mcx::MultiComplex<T> &x, const Eigen::ArrayXd& e) { + Eigen::Array<mcx::MultiComplex<T>, Eigen::Dynamic, 1> o(e.size()); + for (auto i = 0; i < e.size(); ++i) { + o[i] = pow(x, e[i]); + } + return o; +} \ No newline at end of file