//-----------------------------------------------------------------------bl- //-------------------------------------------------------------------------- // // Antioch - A Gas Dynamics Thermochemistry Library // // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk, // Sylvain Plessis, Roy H. Stonger // // Copyright (C) 2013 The PECOS Development Team // // This library is free software; you can redistribute it and/or // modify it under the terms of the Version 2.1 GNU Lesser General // Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc. 51 Franklin Street, Fifth Floor, // Boston, MA 02110-1301 USA // //-----------------------------------------------------------------------el- #ifndef ANTIOCH_METAPROGRAMMING_H #define ANTIOCH_METAPROGRAMMING_H // Antioch #include "antioch/metaprogramming_decl.h" // C++ #include // For size_t namespace Antioch { template inline void set_zero(T& output) { output = 0; } template inline T zero_clone(const T& /* example */) { return 0; } template inline void zero_clone(T& output, const T2& /* example */) { output = 0; } template inline void init_clone(T& output, const T& example) { output = example; } template inline void init_constant(Vector& output, const Scalar& example) { for (typename Antioch::size_type::type i=0; i != output.size(); ++i) init_clone(output[i], example); } template inline T constant_clone(const T& /* example */, const Scalar& value) { return value; } template inline void constant_fill(T& output, const Scalar& value) { output = value; } template inline T custom_clone(const T& /*example*/, const VectorScalar& values, unsigned int indexes) {return values[indexes];} template inline T custom_clone(const T& /*example*/, const VectorScalar& values, const typename Antioch::rebind::type & indexes) { T returnval(indexes.size()); //bof bof - metaphysicl has size within type, this suppose that size_type::type can be changed in value_type::type for(unsigned int i = 0; i < indexes.size(); i++) { returnval[i] = values[indexes[i]]; } return returnval; } template inline typename value_type::type eval_index(const VectorT& vec, unsigned int index) { return vec[index]; } inline bool conjunction(const bool & vec) { return vec; } template inline bool conjunction(const T & vec) { typedef typename tag_type::type tag; return conjunction_root(vec,tag()); } template inline bool conjunction_root(const T & vec, numeric_library_tag) { for(unsigned int i = 0; i < vec.size(); i++) { if(!vec[i])return false; } return true; } inline bool disjunction(const bool & vec) { return vec; } template inline bool disjunction(const T & vec) { typedef typename tag_type::type tag; return disjunction_root(vec,tag()); } template inline bool disjunction_root(const T & vec, numeric_library_tag) { for(unsigned int i = 0; i < vec.size(); i++) { if(vec[i])return true; } return false; } } // end namespace Antioch #endif //ANTIOCH_METAPROGRAMMING_H