3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-25 13:53:40 +01:00

Work on compilation speed.

- h5/make_h5.... only used in parameters.
- old boost includes before C++11
- remove boost serialization, make macro TRIQS_MAKE_NVP temporarely
- remove boost::is_complex (can be written in 2 lines...)
- move some lib in cpp
This commit is contained in:
Olivier Parcollet 2014-05-02 16:00:12 +02:00
parent 5172f342be
commit 8c725f8d5e
44 changed files with 180 additions and 168 deletions

View File

@ -1,5 +1,6 @@
#define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK #define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK
#include <triqs/gfs.hpp> #include <triqs/gfs.hpp>
#include <boost/serialization/complex.hpp>
using namespace triqs::gfs; using namespace triqs::gfs;
using namespace triqs::arrays; using namespace triqs::arrays;
#define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl; #define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) <<std::endl<<std::endl;

View File

@ -68,11 +68,11 @@ namespace triqs { namespace arrays { namespace blas {
} }
template< bool Star, typename T> template< bool Star, typename T>
typename std::enable_if<boost::is_complex<T>::value && Star,T>::type typename std::enable_if<triqs::is_complex<T>::value && Star,T>::type
_conj(T && x) { return conj(std::forward<T>(x));} _conj(T && x) { return conj(std::forward<T>(x));}
template< bool Star, typename T> template< bool Star, typename T>
typename std::enable_if<!( boost::is_complex<T>::value && Star),T>::type typename std::enable_if<!( triqs::is_complex<T>::value && Star),T>::type
_conj(T && x) { return std::forward<T>(x);} _conj(T && x) { return std::forward<T>(x);}
/** /**

View File

@ -20,9 +20,6 @@
******************************************************************************/ ******************************************************************************/
#ifndef TRIQS_ARRAYS_EXPRESSION_FOLD_H #ifndef TRIQS_ARRAYS_EXPRESSION_FOLD_H
#define TRIQS_ARRAYS_EXPRESSION_FOLD_H #define TRIQS_ARRAYS_EXPRESSION_FOLD_H
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/function.hpp>
#include "../array.hpp" #include "../array.hpp"
namespace triqs { namespace triqs {

View File

@ -32,7 +32,7 @@ namespace arrays {
static const size_t dim = R; static const size_t dim = R;
static const bool base_is_array = dim > 0; static const bool base_is_array = dim > 0;
size_t bufsize_, step, _size; size_t bufsize_, step, _size;
static const bool T_is_complex = boost::is_complex<T>::value; static const bool T_is_complex = triqs::is_complex<T>::value;
static const unsigned int RANK = dim + 1 + (T_is_complex ? 1 : 0); static const unsigned int RANK = dim + 1 + (T_is_complex ? 1 : 0);
utility::mini_vector<hsize_t, RANK> dims, offset, maxdims, dim_chunk, buffer_dim, zero; utility::mini_vector<hsize_t, RANK> dims, offset, maxdims, dim_chunk, buffer_dim, zero;
H5::DataSet dataset; H5::DataSet dataset;
@ -67,7 +67,7 @@ namespace arrays {
cparms.setChunk(RANK, dim_chunk.ptr()); // Modify dataset creation properties, i.e. enable chunking. cparms.setChunk(RANK, dim_chunk.ptr()); // Modify dataset creation properties, i.e. enable chunking.
try { try {
dataset = g.create_dataset(name, h5::native_type_from_C(typename h5::remove_complex<T>::type()), mspace1, cparms); dataset = g.create_dataset(name, h5::native_type_from_C(typename h5::remove_complex<T>::type()), mspace1, cparms);
if (boost::is_complex<T>::value) h5::write_string_attribute(&dataset, "__complex__", "1"); if (triqs::is_complex<T>::value) h5::write_string_attribute(&dataset, "__complex__", "1");
} }
TRIQS_ARRAYS_H5_CATCH_EXCEPTION; TRIQS_ARRAYS_H5_CATCH_EXCEPTION;
} }

View File

@ -42,7 +42,7 @@ namespace arrays {
if (S1[u] <= 0) TRIQS_RUNTIME_ERROR << " negative strides not permitted in h5"; if (S1[u] <= 0) TRIQS_RUNTIME_ERROR << " negative strides not permitted in h5";
S[u] = 1; S[u] = 1;
} }
static const bool is_complex = boost::is_complex<typename ArrayType::value_type>::value; static const bool is_complex = triqs::is_complex<typename ArrayType::value_type>::value;
return h5::dataspace_from_LS<R, is_complex>(A.indexmap().domain().lengths(), A.indexmap().domain().lengths(), S); return h5::dataspace_from_LS<R, is_complex>(A.indexmap().domain().lengths(), A.indexmap().domain().lengths(), S);
} }
@ -82,7 +82,7 @@ namespace arrays {
H5::DataSet ds = g.create_dataset(name, h5::data_type_file<T>(), data_space(A)); H5::DataSet ds = g.create_dataset(name, h5::data_type_file<T>(), data_space(A));
ds.write(__get_array_data_cptr(A), h5::data_type_memory<T>(), data_space(A)); ds.write(__get_array_data_cptr(A), h5::data_type_memory<T>(), data_space(A));
// if complex, to be python compatible, we add the __complex__ attribute // if complex, to be python compatible, we add the __complex__ attribute
if (boost::is_complex<T>::value) h5::write_string_attribute(&ds, "__complex__", "1"); if (triqs::is_complex<T>::value) h5::write_string_attribute(&ds, "__complex__", "1");
} }
TRIQS_ARRAYS_H5_CATCH_EXCEPTION; TRIQS_ARRAYS_H5_CATCH_EXCEPTION;
} }
@ -108,7 +108,7 @@ namespace arrays {
try { try {
H5::DataSet ds = g.open_dataset(name); H5::DataSet ds = g.open_dataset(name);
H5::DataSpace dataspace = ds.getSpace(); H5::DataSpace dataspace = ds.getSpace();
static const unsigned int Rank = ArrayType::rank + (boost::is_complex<typename ArrayType::value_type>::value ? 1 : 0); static const unsigned int Rank = ArrayType::rank + (triqs::is_complex<typename ArrayType::value_type>::value ? 1 : 0);
int rank = dataspace.getSimpleExtentNdims(); int rank = dataspace.getSimpleExtentNdims();
if (rank != Rank) if (rank != Rank)
TRIQS_RUNTIME_ERROR << "triqs::array::h5::read. Rank mismatch : the array has rank = " << Rank TRIQS_RUNTIME_ERROR << "triqs::array::h5::read. Rank mismatch : the array has rank = " << Rank

View File

@ -39,16 +39,16 @@ namespace triqs { namespace arrays {
} }
template<typename LHS, typename RHS, char OP> template<typename LHS, typename RHS, char OP>
void triqs_arrays_compound_assign_delegation (LHS & lhs, const RHS & rhs, mpl::char_<OP> ) { void triqs_arrays_compound_assign_delegation (LHS & lhs, const RHS & rhs, char_<OP> ) {
static_assert( !LHS::is_const, "Can not apply a compound operator to a const view !"); static_assert( !LHS::is_const, "Can not apply a compound operator to a const view !");
assignment::impl<LHS, RHS, OP>(lhs, rhs).invoke(); assignment::impl<LHS, RHS, OP>(lhs, rhs).invoke();
} }
#define TRIQS_DEFINE_COMPOUND_OPERATORS(MYTYPE)\ #define TRIQS_DEFINE_COMPOUND_OPERATORS(MYTYPE)\
template<typename RHS> MYTYPE & operator +=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'A'>()); return *this;}\ template<typename RHS> MYTYPE & operator +=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'A'>()); return *this;}\
template<typename RHS> MYTYPE & operator -=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'S'>()); return *this;}\ template<typename RHS> MYTYPE & operator -=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'S'>()); return *this;}\
template<typename RHS> MYTYPE & operator *=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'M'>()); return *this;}\ template<typename RHS> MYTYPE & operator *=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'M'>()); return *this;}\
template<typename RHS> MYTYPE & operator /=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'D'>()); return *this;} template<typename RHS> MYTYPE & operator /=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'D'>()); return *this;}
#define TRIQS_DELETE_COMPOUND_OPERATORS(MYTYPE)\ #define TRIQS_DELETE_COMPOUND_OPERATORS(MYTYPE)\
template<typename RHS> MYTYPE & operator +=(RHS const & rhs) = delete;\ template<typename RHS> MYTYPE & operator +=(RHS const & rhs) = delete;\

View File

@ -31,10 +31,11 @@
#include <assert.h> #include <assert.h>
#include <triqs/utility/exceptions.hpp> #include <triqs/utility/exceptions.hpp>
#include <sstream> #include <sstream>
#include <type_traits>
#include <boost/mpl/char.hpp> template<char C> using char_ = std::integral_constant<char,C>;
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/type_traits/is_complex.hpp> #include <triqs/utility/is_complex.hpp>
#include <triqs/utility/compiler_details.hpp> #include <triqs/utility/compiler_details.hpp>
#include <triqs/utility/macros.hpp> #include <triqs/utility/macros.hpp>
// LEADS to an error on OS X??? // LEADS to an error on OS X???

View File

@ -28,8 +28,6 @@
#include "triqs/utility/exceptions.hpp" #include "triqs/utility/exceptions.hpp"
#include "triqs/utility/typeid_name.hpp" #include "triqs/utility/typeid_name.hpp"
#include "triqs/utility/view_tools.hpp" #include "triqs/utility/view_tools.hpp"
#include <boost/serialization/utility.hpp>
#include <boost/serialization/vector.hpp>
#include <type_traits> #include <type_traits>
#ifdef TRIQS_WITH_PYTHON_SUPPORT #ifdef TRIQS_WITH_PYTHON_SUPPORT
#include "../python/numpy_extractor.hpp" #include "../python/numpy_extractor.hpp"
@ -328,8 +326,8 @@ namespace triqs { namespace arrays {
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive & ar, const unsigned int version) { void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::make_nvp("storage",this->storage_); ar & TRIQS_MAKE_NVP("storage",this->storage_);
ar & boost::serialization::make_nvp("indexmap",this->indexmap_); ar & TRIQS_MAKE_NVP("indexmap",this->indexmap_);
} }
// pretty print of the array // pretty print of the array

View File

@ -19,11 +19,8 @@
* TRIQS. If not, see <http://www.gnu.org/licenses/>. * TRIQS. If not, see <http://www.gnu.org/licenses/>.
* *
******************************************************************************/ ******************************************************************************/
#ifndef TRIQS_ARRAYS_MAKE_CONST_H #ifndef TRIQS_ARRAYS_MAKE_CONST_H
#define TRIQS_ARRAYS_MAKE_CONST_H #define TRIQS_ARRAYS_MAKE_CONST_H
#include <boost/mpl/if.hpp>
#include <boost/type_traits/add_const.hpp>
namespace triqs { namespace arrays { namespace triqs { namespace arrays {
@ -32,7 +29,7 @@ namespace triqs { namespace arrays {
* make_const_type : make the type constant. * make_const_type : make the type constant.
* For a storage, it transforms it into a storage<const Valuetype> * For a storage, it transforms it into a storage<const Valuetype>
*/ */
template<bool Const, typename T> struct make_const_type : boost::mpl::if_c<Const, typename boost::add_const<T>::type, T> {}; template<bool Const, typename T> struct make_const_type : std::conditional<Const, typename std::add_const<T>::type, T> {};
} }
}}//namespace triqs::arrays }}//namespace triqs::arrays
#endif #endif

View File

@ -22,6 +22,8 @@
#define TRIQS_ARRAYS_IMPL_TRAITS_H #define TRIQS_ARRAYS_IMPL_TRAITS_H
#include <triqs/utility/concept_tools.hpp> #include <triqs/utility/concept_tools.hpp>
#include <triqs/utility/traits.hpp> #include <triqs/utility/traits.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
namespace triqs { namespace triqs {
namespace arrays { namespace arrays {
@ -67,11 +69,11 @@ namespace arrays {
template <class T> struct is_amv_view_class : _or<is_array_view<T>, is_matrix_view<T>, is_vector_view<T>> {}; template <class T> struct is_amv_view_class : _or<is_array_view<T>, is_matrix_view<T>, is_vector_view<T>> {};
template <class T> struct is_amv_value_or_view_class : _or<is_amv_value_class<T>, is_amv_view_class<T>> {}; template <class T> struct is_amv_value_or_view_class : _or<is_amv_value_class<T>, is_amv_view_class<T>> {};
template <class S> struct is_scalar : _or<std::is_arithmetic<S>, boost::is_complex<S>> {}; template <class S> struct is_scalar : _or<std::is_arithmetic<S>, triqs::is_complex<S>> {};
template <class S, class A> template <class S, class A>
struct is_scalar_for struct is_scalar_for
: std::conditional<is_scalar<typename A::value_type>::value, is_scalar<S>, boost::is_same<S, typename A::value_type>>::type { : std::conditional<is_scalar<typename A::value_type>::value, is_scalar<S>, std::is_same<S, typename A::value_type>>::type {
}; };
} }
} // namespace triqs::arrays } // namespace triqs::arrays

View File

@ -23,7 +23,6 @@
#include "../impl/common.hpp" #include "../impl/common.hpp"
#include <triqs/utility/mini_vector.hpp> #include <triqs/utility/mini_vector.hpp>
//#include "../impl/tuple_tools.hpp" //#include "../impl/tuple_tools.hpp"
#include <boost/ref.hpp>
#include <iostream> #include <iostream>
namespace boost { namespace serialization { class access;}} namespace boost { namespace serialization { class access;}}

View File

@ -41,7 +41,7 @@ namespace triqs { namespace arrays { namespace indexmaps { namespace cuboid {
typedef mini_vector<size_t,Rank> n_uple; typedef mini_vector<size_t,Rank> n_uple;
n_uple lengths_; n_uple lengths_;
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("dimensions",lengths_);} template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("dimensions",lengths_);}
public : public :
static constexpr unsigned int rank = Rank; static constexpr unsigned int rank = Rank;
typedef n_uple index_value_type; typedef n_uple index_value_type;

View File

@ -133,9 +133,9 @@ namespace triqs { namespace arrays { namespace indexmaps { namespace cuboid {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { template<class Archive> void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::make_nvp("domain",mydomain); ar & TRIQS_MAKE_NVP("domain",mydomain);
ar & boost::serialization::make_nvp("strides",strides_); ar & TRIQS_MAKE_NVP("strides",strides_);
ar & boost::serialization::make_nvp("start_shift",start_shift_); ar & TRIQS_MAKE_NVP("start_shift",start_shift_);
} }
// for construction // for construction
void compute_stride_compact() { void compute_stride_compact() {

View File

@ -265,8 +265,8 @@ namespace triqs { namespace arrays { namespace storages { //namespace details {
template<class Archive> template<class Archive>
void save(Archive & ar, const unsigned int version) const { void save(Archive & ar, const unsigned int version) const {
ar << boost::serialization::make_nvp("size",size_); ar << TRIQS_MAKE_NVP("size",size_);
for (size_t i=0; i<size_; ++i) ar << boost::serialization::make_nvp("data",p[i]); for (size_t i=0; i<size_; ++i) ar << TRIQS_MAKE_NVP("data",p[i]);
} }
template<class Archive> template<class Archive>

View File

@ -25,7 +25,7 @@
namespace triqs { namespace arrays { namespace storages { namespace triqs { namespace arrays { namespace storages {
// beware : complex is not a pod // beware : complex is not a pod
template <class S> struct is_scalar_or_pod : std::integral_constant<bool, std::is_arithmetic<S>::value || boost::is_complex<S>::value || std::is_pod<S>::value > {}; template <class S> struct is_scalar_or_pod : std::integral_constant<bool, std::is_arithmetic<S>::value || triqs::is_complex<S>::value || std::is_pod<S>::value > {};
// copy such that it is a fast memcpy for scalar / pod objects // copy such that it is a fast memcpy for scalar / pod objects
// when not a scalar object, loop on elements // when not a scalar object, loop on elements

View File

@ -103,11 +103,11 @@ namespace triqs { namespace arrays { namespace storages {
friend class shared_block<ValueType,!Weak>; friend class shared_block<ValueType,!Weak>;
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("ptr",sptr); } void save(Archive & ar, const unsigned int version) const { ar << TRIQS_MAKE_NVP("ptr",sptr); }
template<class Archive> template<class Archive>
void load(Archive & ar, const unsigned int version) { void load(Archive & ar, const unsigned int version) {
if (sptr) dec_ref<Weak>(sptr); if (sptr) dec_ref<Weak>(sptr);
ar >> boost::serialization::make_nvp("ptr",sptr); data_ = (sptr ? sptr->p : nullptr); s = (sptr ? sptr->size() : 0); ar >> TRIQS_MAKE_NVP("ptr",sptr); data_ = (sptr ? sptr->p : nullptr); s = (sptr ? sptr->size() : 0);
if (sptr) inc_ref<Weak>(sptr); if (sptr) inc_ref<Weak>(sptr);
} }
BOOST_SERIALIZATION_SPLIT_MEMBER(); BOOST_SERIALIZATION_SPLIT_MEMBER();

View File

@ -247,25 +247,25 @@ namespace triqs { namespace arrays {
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_vector_or_view <RHS > >::type typename boost::enable_if< is_vector_or_view <RHS > >::type
triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, mpl::char_<'A'>) { triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, char_<'A'>) {
T a = 1.0; blas::axpy(a,rhs,lhs); T a = 1.0; blas::axpy(a,rhs,lhs);
} }
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_vector_or_view <RHS > >::type typename boost::enable_if< is_vector_or_view <RHS > >::type
triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, mpl::char_<'S'>) { triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, char_<'S'>) {
T a = -1.0; blas::axpy(a,rhs,lhs); T a = -1.0; blas::axpy(a,rhs,lhs);
} }
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_scalar_for<RHS,vector<T,Opt> > >::type typename boost::enable_if< is_scalar_for<RHS,vector<T,Opt> > >::type
triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, mpl::char_<'M'>) { triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, char_<'M'>) {
T a = rhs; blas::scal(a,lhs); T a = rhs; blas::scal(a,lhs);
} }
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_scalar_for<RHS,vector<T,Opt> > >::type typename boost::enable_if< is_scalar_for<RHS,vector<T,Opt> > >::type
triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, mpl::char_<'D'>) { triqs_arrays_compound_assign_delegation (vector<T,Opt> & lhs, RHS const & rhs, char_<'D'>) {
T a = 1/rhs; blas::scal(a,lhs); T a = 1/rhs; blas::scal(a,lhs);
} }
@ -275,25 +275,25 @@ namespace triqs { namespace arrays {
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_vector_or_view <RHS > >::type typename boost::enable_if< is_vector_or_view <RHS > >::type
triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, mpl::char_<'A'>) { triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, char_<'A'>) {
T a = 1.0; blas::axpy(a,rhs,lhs); T a = 1.0; blas::axpy(a,rhs,lhs);
} }
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_vector_or_view <RHS > >::type typename boost::enable_if< is_vector_or_view <RHS > >::type
triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, mpl::char_<'S'>) { triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, char_<'S'>) {
T a = -1.0; blas::axpy(a,rhs,lhs); T a = -1.0; blas::axpy(a,rhs,lhs);
} }
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_scalar_for<RHS,vector_view<T,Opt> > >::type typename boost::enable_if< is_scalar_for<RHS,vector_view<T,Opt> > >::type
triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, mpl::char_<'M'>) { triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, char_<'M'>) {
T a = rhs; blas::scal(a,lhs); T a = rhs; blas::scal(a,lhs);
} }
template<typename RHS, typename T, ull_t Opt> template<typename RHS, typename T, ull_t Opt>
typename boost::enable_if< is_scalar_for<RHS,vector_view<T,Opt> > >::type typename boost::enable_if< is_scalar_for<RHS,vector_view<T,Opt> > >::type
triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, mpl::char_<'D'>) { triqs_arrays_compound_assign_delegation (vector_view<T,Opt> & lhs, RHS const & rhs, char_<'D'>) {
T a = 1/rhs; blas::scal(a,lhs); T a = 1/rhs; blas::scal(a,lhs);
} }

View File

@ -51,7 +51,7 @@ namespace triqs { namespace det_manip {
typedef typename f_tr::template decay_arg<0>::type xy_type; typedef typename f_tr::template decay_arg<0>::type xy_type;
typedef typename f_tr::result_type value_type; typedef typename f_tr::result_type value_type;
static_assert( std::is_floating_point<value_type>::value || boost::is_complex<value_type>::value, "det_manip : the function must return a floating number or a complex number"); static_assert( std::is_floating_point<value_type>::value || triqs::is_complex<value_type>::value, "det_manip : the function must return a floating number or a complex number");
typedef arrays::vector<value_type> vector_type; typedef arrays::vector<value_type> vector_type;
typedef arrays::matrix<value_type> matrix_type; typedef arrays::matrix<value_type> matrix_type;
@ -78,13 +78,12 @@ namespace triqs { namespace det_manip {
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive & ar) { void serialize(Archive & ar) {
using boost::serialization::make_nvp; ar & TRIQS_MAKE_NVP("Nmax",Nmax) & TRIQS_MAKE_NVP("N",N)
ar & make_nvp("Nmax",Nmax) & make_nvp("N",N) & TRIQS_MAKE_NVP("n_opts",n_opts) & TRIQS_MAKE_NVP("n_opts_max_before_check",n_opts_max_before_check)
& make_nvp("n_opts",n_opts) & make_nvp("n_opts_max_before_check",n_opts_max_before_check) & TRIQS_MAKE_NVP("det",det) & TRIQS_MAKE_NVP("sign",sign)
& make_nvp("det",det) & make_nvp("sign",sign) & TRIQS_MAKE_NVP("Minv",mat_inv)
& make_nvp("Minv",mat_inv) & TRIQS_MAKE_NVP("row_num",row_num) & TRIQS_MAKE_NVP("col_num",col_num)
& make_nvp("row_num",row_num) & make_nvp("col_num",col_num) & TRIQS_MAKE_NVP("x_values",x_values) & TRIQS_MAKE_NVP("y_values",y_values);
& make_nvp("x_values",x_values) & make_nvp("y_values",y_values);
} }
/// Write into HDF5 /// Write into HDF5

View File

@ -75,9 +75,9 @@ namespace gfs {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive& ar, const unsigned int version) { template <class Archive> void serialize(Archive& ar, const unsigned int version) {
ar& boost::serialization::make_nvp("n_max", Nmax); ar& TRIQS_MAKE_NVP("n_max", Nmax);
ar& boost::serialization::make_nvp("names", _names); ar& TRIQS_MAKE_NVP("names", _names);
ar& boost::serialization::make_nvp("names_inv", _inv_names); ar& TRIQS_MAKE_NVP("names_inv", _inv_names);
} }
}; };
} }

View File

@ -66,9 +66,9 @@ namespace gfs {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive& ar, const unsigned int version) { template <class Archive> void serialize(Archive& ar, const unsigned int version) {
ar& boost::serialization::make_nvp("n_max", Nmax); ar& TRIQS_MAKE_NVP("n_max", Nmax);
ar& boost::serialization::make_nvp("beta", beta); ar& TRIQS_MAKE_NVP("beta", beta);
ar& boost::serialization::make_nvp("statistic", statistic); ar& TRIQS_MAKE_NVP("statistic", statistic);
} }
}; };
} }

View File

@ -97,8 +97,8 @@ namespace gfs {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
ar &boost::serialization::make_nvp("beta", beta); ar &TRIQS_MAKE_NVP("beta", beta);
ar &boost::serialization::make_nvp("statistic", statistic); ar &TRIQS_MAKE_NVP("statistic", statistic);
} }
}; };

View File

@ -316,10 +316,10 @@ namespace gfs {
//----------------------------- BOOST Serialization ----------------------------- //----------------------------- BOOST Serialization -----------------------------
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
ar &boost::serialization::make_nvp("data", _data); ar &TRIQS_MAKE_NVP("data", _data);
ar &boost::serialization::make_nvp("singularity", _singularity); ar &TRIQS_MAKE_NVP("singularity", _singularity);
ar &boost::serialization::make_nvp("mesh", _mesh); ar &TRIQS_MAKE_NVP("mesh", _mesh);
ar &boost::serialization::make_nvp("symmetry", _symmetry); ar &TRIQS_MAKE_NVP("symmetry", _symmetry);
} }
/// print /// print

View File

@ -167,9 +167,9 @@ namespace triqs { namespace gfs { namespace local {
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive & ar, const unsigned int version) { void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::make_nvp("omin",omin); ar & TRIQS_MAKE_NVP("omin",omin);
ar & boost::serialization::make_nvp("mask",mask); ar & TRIQS_MAKE_NVP("mask",mask);
ar & boost::serialization::make_nvp("data",_data); ar & TRIQS_MAKE_NVP("data",_data);
} }
friend std::ostream & operator << (std::ostream & out, tail_impl const & x) { friend std::ostream & operator << (std::ostream & out, tail_impl const & x) {

View File

@ -89,7 +89,7 @@ namespace gfs {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
ar &boost::serialization::make_nvp("domain", _dom); ar &TRIQS_MAKE_NVP("domain", _dom);
} }
friend std::ostream &operator<<(std::ostream &sout, discrete_mesh const &m) { return sout << "Discrete Mesh"; } friend std::ostream &operator<<(std::ostream &sout, discrete_mesh const &m) { return sout << "Discrete Mesh"; }

View File

@ -165,14 +165,14 @@ namespace gfs {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
ar &boost::serialization::make_nvp("domain", _dom); ar &TRIQS_MAKE_NVP("domain", _dom);
ar &boost::serialization::make_nvp("a_pt", a_pt); ar &TRIQS_MAKE_NVP("a_pt", a_pt);
ar &boost::serialization::make_nvp("b_pt", b_pt); ar &TRIQS_MAKE_NVP("b_pt", b_pt);
ar &boost::serialization::make_nvp("xmin", xmin); ar &TRIQS_MAKE_NVP("xmin", xmin);
ar &boost::serialization::make_nvp("xmax", xmax); ar &TRIQS_MAKE_NVP("xmax", xmax);
ar &boost::serialization::make_nvp("del", del); ar &TRIQS_MAKE_NVP("del", del);
ar &boost::serialization::make_nvp("size", L); ar &TRIQS_MAKE_NVP("size", L);
ar &boost::serialization::make_nvp("kind", meshk); ar &TRIQS_MAKE_NVP("kind", meshk);
} }
friend std::ostream &operator<<(std::ostream &sout, linear_mesh const &m) { return sout << "Linear Mesh of size " << m.L; } friend std::ostream &operator<<(std::ostream &sout, linear_mesh const &m) { return sout << "Linear Mesh of size " << m.L; }

View File

@ -147,9 +147,9 @@ namespace gfs {
friend class boost::serialization::access; friend class boost::serialization::access;
/// BOOST Serialization /// BOOST Serialization
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
ar &boost::serialization::make_nvp("domain", _dom); ar &TRIQS_MAKE_NVP("domain", _dom);
ar &boost::serialization::make_nvp("size", _n_pts); ar &TRIQS_MAKE_NVP("size", _n_pts);
ar &boost::serialization::make_nvp("kind", _positive_only); ar &TRIQS_MAKE_NVP("kind", _positive_only);
} }
/// Simple print (just blabla and the size) /// Simple print (just blabla and the size)

View File

@ -235,7 +235,7 @@ namespace gfs {
template <typename M> size_t operator()(M &m, size_t N) { template <typename M> size_t operator()(M &m, size_t N) {
std::stringstream fs; std::stringstream fs;
fs << "MeshComponent" << N; fs << "MeshComponent" << N;
ar &boost::serialization::make_nvp(fs.str().c_str(), m); ar &TRIQS_MAKE_NVP(fs.str().c_str(), m);
return N + 1; return N + 1;
} }
}; };

View File

@ -159,7 +159,7 @@ namespace gfs {
/// BOOST Serialization /// BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
auto l = [&ar](auto &m, int N) { ar &boost::serialization::make_nvp("MeshComponent" + std::to_string(N), m); }; auto l = [&ar](auto &m, int N) { ar &TRIQS_MAKE_NVP("MeshComponent" + std::to_string(N), m); };
triqs::tuple::for_each_enumerate(m_tuple, l); triqs::tuple::for_each_enumerate(m_tuple, l);
} }

View File

@ -24,6 +24,6 @@
#include "./h5/scalar.hpp" #include "./h5/scalar.hpp"
#include "./h5/vector.hpp" #include "./h5/vector.hpp"
#include "./h5/string.hpp" #include "./h5/string.hpp"
#include "./h5/make_h5_read_write.hpp" //#include "./h5/make_h5_read_write.hpp"
#endif #endif

View File

@ -24,7 +24,7 @@
#include <type_traits> #include <type_traits>
#include <H5Cpp.h> #include <H5Cpp.h>
#include "hdf5_hl.h" #include "hdf5_hl.h"
#include <boost/type_traits/is_complex.hpp> #include <triqs/utility/is_complex.hpp>
namespace triqs { namespace triqs {
@ -97,14 +97,14 @@ namespace triqs {
//------------- compute void * pointer to the data ---------------------------------- //------------- compute void * pointer to the data ----------------------------------
template <typename S> template <typename S>
typename std::enable_if< boost::is_complex<S>::value, typename std::conditional<std::is_const<S>::value, const void *, void *>::type >::type typename std::enable_if< triqs::is_complex<S>::value, typename std::conditional<std::is_const<S>::value, const void *, void *>::type >::type
get_data_ptr (S * p) { get_data_ptr (S * p) {
typedef typename std::conditional<std::is_const<S>::value, const typename S::value_type, typename S::value_type>::type T; typedef typename std::conditional<std::is_const<S>::value, const typename S::value_type, typename S::value_type>::type T;
return reinterpret_cast<T*>(p); return reinterpret_cast<T*>(p);
} }
template <typename S > template <typename S >
typename std::enable_if< !boost::is_complex<S>::value, typename std::conditional<std::is_const<S>::value, const void *, void *>::type >::type typename std::enable_if< !triqs::is_complex<S>::value, typename std::conditional<std::is_const<S>::value, const void *, void *>::type >::type
get_data_ptr (S * p) {return p;} get_data_ptr (S * p) {return p;}
// dataspace from lengths and strides. Correct for the complex. strides must be >0 // dataspace from lengths and strides. Correct for the complex. strides must be >0

View File

@ -54,7 +54,7 @@ namespace triqs {
template <typename T> template <typename T>
H5::DataSpace data_space_for_vector (std::vector<T> const & V) { H5::DataSpace data_space_for_vector (std::vector<T> const & V) {
mini_vector<hsize_t,1> L,S; S[0]=1;L[0] = V.size(); mini_vector<hsize_t,1> L,S; S[0]=1;L[0] = V.size();
return h5::dataspace_from_LS<1, boost::is_complex<T>::value > (L,L,S); return h5::dataspace_from_LS<1, triqs::is_complex<T>::value > (L,L,S);
} }
template<typename T> template<typename T>
@ -63,7 +63,7 @@ namespace triqs {
H5::DataSet ds = g.create_dataset(name, h5::data_type_file<T>(), data_space_for_vector(V) ); H5::DataSet ds = g.create_dataset(name, h5::data_type_file<T>(), data_space_for_vector(V) );
ds.write( &V[0], h5::data_type_memory<T>(), data_space_for_vector(V) ); ds.write( &V[0], h5::data_type_memory<T>(), data_space_for_vector(V) );
// if complex, to be python compatible, we add the __complex__ attribute // if complex, to be python compatible, we add the __complex__ attribute
if (boost::is_complex<T>::value) h5::write_string_attribute(&ds,"__complex__","1"); if (triqs::is_complex<T>::value) h5::write_string_attribute(&ds,"__complex__","1");
} }
TRIQS_ARRAYS_H5_CATCH_EXCEPTION; TRIQS_ARRAYS_H5_CATCH_EXCEPTION;
} }
@ -73,7 +73,7 @@ namespace triqs {
try { try {
H5::DataSet ds = g.open_dataset(name); H5::DataSet ds = g.open_dataset(name);
H5::DataSpace dataspace = ds.getSpace(); H5::DataSpace dataspace = ds.getSpace();
static const unsigned int Rank = 1 + (boost::is_complex<T>::value ? 1 : 0); static const unsigned int Rank = 1 + (triqs::is_complex<T>::value ? 1 : 0);
int rank = dataspace.getSimpleExtentNdims(); int rank = dataspace.getSimpleExtentNdims();
if (rank != Rank) TRIQS_RUNTIME_ERROR << "triqs : h5 : read vector. Rank mismatch : the array stored in the hdf5 file has rank = "<<rank; if (rank != Rank) TRIQS_RUNTIME_ERROR << "triqs : h5 : read vector. Rank mismatch : the array stored in the hdf5 file has rank = "<<rank;
mini_vector<hsize_t,Rank> dims_out; mini_vector<hsize_t,Rank> dims_out;

View File

@ -67,9 +67,9 @@ namespace lattice {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive& ar, const unsigned int version) { template <class Archive> void serialize(Archive& ar, const unsigned int version) {
ar& boost::serialization::make_nvp("units", units_); ar& TRIQS_MAKE_NVP("units", units_);
ar& boost::serialization::make_nvp("atom_orb_pos", atom_orb_pos); ar& TRIQS_MAKE_NVP("atom_orb_pos", atom_orb_pos);
ar& boost::serialization::make_nvp("atom_orb_name", atom_orb_name); ar& TRIQS_MAKE_NVP("atom_orb_name", atom_orb_name);
} }
private: private:

View File

@ -55,7 +55,7 @@ namespace lattice {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive& ar, const unsigned int version) { template <class Archive> void serialize(Archive& ar, const unsigned int version) {
ar& boost::serialization::make_nvp("bravais_lattice", lattice_); ar& TRIQS_MAKE_NVP("bravais_lattice", lattice_);
} }
private: private:

View File

@ -94,8 +94,8 @@ namespace lattice {
// BOOST Serialization // BOOST Serialization
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, const unsigned int version) { template <class Archive> void serialize(Archive &ar, const unsigned int version) {
ar &boost::serialization::make_nvp("domain", bz); ar &TRIQS_MAKE_NVP("domain", bz);
ar &boost::serialization::make_nvp("k_pt_stack", k_pt_stack); ar &TRIQS_MAKE_NVP("k_pt_stack", k_pt_stack);
} }
friend std::ostream &operator<<(std::ostream &sout, bz_mesh const &m) { return sout << "Mesh over BZ "; } friend std::ostream &operator<<(std::ostream &sout, bz_mesh const &m) { return sout << "Mesh over BZ "; }

View File

@ -47,7 +47,7 @@ namespace triqs { namespace utility {
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("object_map",object_map); } void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("object_map",object_map); }
template<typename T> parameter_defaults & insert(std::string const & key, T && def_val, std::string const & doc, bool opt) { template<typename T> parameter_defaults & insert(std::string const & key, T && def_val, std::string const & doc, bool opt) {
object_map[key] = std::forward<T>(def_val); object_map[key] = std::forward<T>(def_val);

View File

@ -32,6 +32,7 @@
#include <triqs/utility/serialization.hpp> #include <triqs/utility/serialization.hpp>
#include <triqs/arrays.hpp> #include <triqs/arrays.hpp>
#include <triqs/python_tools/array_interface.hpp> #include <triqs/python_tools/array_interface.hpp>
#include <triqs/h5/make_h5_read_write.hpp>
namespace triqs { namespace utility { namespace triqs { namespace utility {
@ -171,14 +172,14 @@ namespace triqs { namespace utility {
template<class Archive> template<class Archive>
void save(Archive & ar, const unsigned int version) const { void save(Archive & ar, const unsigned int version) const {
std::string s = serialize_(); std::string s = serialize_();
ar << boost::serialization::make_nvp("type_name", type_code_to_type_name[type_code_]); ar << TRIQS_MAKE_NVP("type_name", type_code_to_type_name[type_code_]);
ar << boost::serialization::make_nvp("seria_str", s); ar << TRIQS_MAKE_NVP("seria_str", s);
} }
template<class Archive> template<class Archive>
void load(Archive & ar, const unsigned int version) { void load(Archive & ar, const unsigned int version) {
std::string s, tnn; std::string s, tnn;
ar >> boost::serialization::make_nvp("type_name", tnn); ar >> TRIQS_MAKE_NVP("type_name", tnn);
ar >> boost::serialization::make_nvp("seria_str", s); ar >> TRIQS_MAKE_NVP("seria_str", s);
auto it = type_name_to_type_code.find(tnn); auto it = type_name_to_type_code.find(tnn);
if (it== type_name_to_type_code.end()) if (it== type_name_to_type_code.end())
TRIQS_RUNTIME_ERROR << " Can not deserialize the type "<< tnn<< "\n Did you forget to register it ?"; TRIQS_RUNTIME_ERROR << " Can not deserialize the type "<< tnn<< "\n Did you forget to register it ?";

View File

@ -49,7 +49,7 @@ namespace triqs { namespace utility {
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("object_map",object_map); } void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("object_map",object_map); }
public: public:

View File

@ -22,8 +22,6 @@
#define TRIQS_UTILITY_CONCEPT_TOOLS_H #define TRIQS_UTILITY_CONCEPT_TOOLS_H
#include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp> #include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_complex.hpp>
#define TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) MyBeautifulConcept##__concept_tag #define TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) MyBeautifulConcept##__concept_tag
@ -31,7 +29,7 @@
#define TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT(MyBeautifulConcept) \ #define TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT(MyBeautifulConcept) \
struct TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) {};\ struct TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) {};\
template<typename T> struct MyBeautifulConcept : boost::is_base_of<TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) , T> {};\ template<typename T> struct MyBeautifulConcept : std::is_base_of<TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) , T> {};\
template<typename T> struct MyBeautifulConcept<const T> : MyBeautifulConcept<T>{};\ template<typename T> struct MyBeautifulConcept<const T> : MyBeautifulConcept<T>{};\
template<typename T> struct MyBeautifulConcept<T&> : MyBeautifulConcept<T>{};\ template<typename T> struct MyBeautifulConcept<T&> : MyBeautifulConcept<T>{};\
template<typename T> struct MyBeautifulConcept<T&&> : MyBeautifulConcept<T>{}; template<typename T> struct MyBeautifulConcept<T&&> : MyBeautifulConcept<T>{};
@ -41,7 +39,7 @@
#define TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MyBeautifulConcept,Rs) \ #define TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MyBeautifulConcept,Rs) \
struct TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) : BOOST_PP_SEQ_FOR_EACH_I (TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R_AUX,nil,Rs) {};\ struct TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) : BOOST_PP_SEQ_FOR_EACH_I (TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R_AUX,nil,Rs) {};\
template<typename T> struct MyBeautifulConcept : boost::is_base_of<TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept), T> {};\ template<typename T> struct MyBeautifulConcept : std::is_base_of<TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept), T> {};\
template<typename T> struct MyBeautifulConcept<const T> : MyBeautifulConcept<T>{};\ template<typename T> struct MyBeautifulConcept<const T> : MyBeautifulConcept<T>{};\
template<typename T> struct MyBeautifulConcept<T&> : MyBeautifulConcept<T>{};\ template<typename T> struct MyBeautifulConcept<T&> : MyBeautifulConcept<T>{};\
template<typename T> struct MyBeautifulConcept<T&&> : MyBeautifulConcept<T>{}; template<typename T> struct MyBeautifulConcept<T&&> : MyBeautifulConcept<T>{};

View File

@ -55,7 +55,7 @@ namespace triqs {
// Boost serialization. Can I use std::shared_ptr directly ? Or use boost::shared_ptr // Boost serialization. Can I use std::shared_ptr directly ? Or use boost::shared_ptr
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("data",*p); } void save(Archive & ar, const unsigned int version) const { ar << TRIQS_MAKE_NVP("data",*p); }
template<class Archive> template<class Archive>
void load(Archive & ar, const unsigned int version) { T x; ar >> x; p = std::make_shared<T>(x); } void load(Archive & ar, const unsigned int version) { T x; ar >> x; p = std::make_shared<T>(x); }
BOOST_SERIALIZATION_SPLIT_MEMBER(); BOOST_SERIALIZATION_SPLIT_MEMBER();
@ -85,7 +85,7 @@ namespace triqs {
// Boost serialization. Can I use std::shared_ptr directly ? Or use boost::shared_ptr // Boost serialization. Can I use std::shared_ptr directly ? Or use boost::shared_ptr
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> template<class Archive>
void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("data",*p); } void save(Archive & ar, const unsigned int version) const { ar << TRIQS_MAKE_NVP("data",*p); }
template<class Archive> template<class Archive>
void load(Archive & ar, const unsigned int version) { T x; ar >> x; p = std::make_shared<T>(x); } void load(Archive & ar, const unsigned int version) { T x; ar >> x; p = std::make_shared<T>(x); }
BOOST_SERIALIZATION_SPLIT_MEMBER(); BOOST_SERIALIZATION_SPLIT_MEMBER();

View File

@ -1,9 +1,8 @@
/******************************************************************************* /*******************************************************************************
* *
* TRIQS: a Toolbox for Research in Interacting Quantum Systems * TRIQS: a Toolbox for Research in Interacting Quantum Systems
* *
* Copyright (C) 2011 by M. Ferrero, O. Parcollet * Copyright (C) 2014 by O. Parcollet
* *
* TRIQS is free software: you can redistribute it and/or modify it under the * TRIQS is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software * terms of the GNU General Public License as published by the Free Software
@ -19,26 +18,13 @@
* TRIQS. If not, see <http://www.gnu.org/licenses/>. * TRIQS. If not, see <http://www.gnu.org/licenses/>.
* *
******************************************************************************/ ******************************************************************************/
#pragma once
#include <complex>
#include <type_traits>
#ifndef TRIQS_H5_EXCEPTIONS_H namespace triqs {
#define TRIQS_H5_EXCEPTIONS_H template<typename T> struct is_complex : std::false_type{};
template<typename T> struct is_complex<std::complex<T>> : std::true_type{};
}
#include <Python.h>
#include <boost/python.hpp>
#include <H5Cpp.h>
#include <sstream>
namespace triqs { namespace utility {
// transcription of H5 error
inline void translatorH5Error(H5::Exception const& x) {
std::stringstream f; f<< " H5 exception\n"<<x.getCDetailMsg()<<"\n in function "<< x.getCFuncName()<<"\n";
PyErr_SetString(PyExc_RuntimeError, f.str().c_str() );
};
void register_h5_exception() { boost::python::register_exception_translator<H5::Exception>(translatorH5Error);}
}}
#endif

View File

@ -25,18 +25,22 @@
#include "./compiler_details.hpp" #include "./compiler_details.hpp"
#include "./exceptions.hpp" #include "./exceptions.hpp"
#include <boost/serialization/utility.hpp> #include <boost/serialization/utility.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <vector> #include <vector>
#include <triqs/utility/tuple_tools.hpp> #include <triqs/utility/tuple_tools.hpp>
#define TRIQS_MINI_VECTOR_NRANK_MAX 10 #define TRIQS_MINI_VECTOR_NRANK_MAX 10
#define TRIQS_MAKE_NVP(NAME,X) X
//#define TRIQS_MAKE_NVP(NAME,X) boost::serialization::make_nvp(NAME,X)
namespace triqs { namespace utility { namespace triqs { namespace utility {
template <typename T, int Rank> template <typename T, int Rank>
class mini_vector { class mini_vector {
T _data[Rank]; T _data[Rank];
friend class boost::serialization::access; friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("_data",_data); } template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("_data",_data); }
void init() { for (int i=0;i<Rank; ++i) _data[i] = 0;} void init() { for (int i=0;i<Rank; ++i) _data[i] = 0;}
public : public :

View File

@ -94,7 +94,7 @@ namespace triqs { namespace mpi {
// ------------------------------ // ------------------------------
// overload for basic types // overload for basic types
// ------------------------------ // ------------------------------
template<typename A> struct mpi_impl<A,ENABLE_IFC(std::is_arithmetic<A>::value || boost::is_complex<A>::value)> { template<typename A> struct mpi_impl<A,ENABLE_IFC(std::is_arithmetic<A>::value || triqs::is_complex<A>::value)> {
static void reduce_in_place (communicator _c, A & a, int root) { static void reduce_in_place (communicator _c, A & a, int root) {
MPI_Reduce ((_c.rank()==root ? MPI_IN_PLACE:&a),&a,1, mpi_datatype<A>::invoke(), MPI_SUM, root, _c); MPI_Reduce ((_c.rank()==root ? MPI_IN_PLACE:&a),&a,1, mpi_datatype<A>::invoke(), MPI_SUM, root, _c);

View File

@ -0,0 +1,57 @@
/*******************************************************************************
*
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
*
* Copyright (C) 2011 by M. Ferrero, O. Parcollet
*
* TRIQS is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* TRIQS 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* TRIQS. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include <triqs/utility/first_include.hpp>
#include "./typeid_name.hpp"
#include <sstream>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include <boost/algorithm/string/erase.hpp>
namespace triqs { namespace utility {
std::string demangle(const char * name) {
std::stringstream fs;
#ifdef __GNUC__
int status;
char * demangled = abi::__cxa_demangle(name, NULL, NULL, &status);
if (!status) {
std::string res(demangled);
boost::erase_all(res,", boost::tuples::null_type");
boost::erase_all(res,", -1");
boost::erase_all(res,", void");
fs<< res;
free(demangled);
} else fs<< name;
//fs<<abi::__cxa_demangle(typeid(A).name(), 0, 0, &status);
#else
fs<<name;
#endif
return fs.str();
}
std::string demangle(std::string const & name) { return demangle (name.c_str());}
std::string get_name(std::type_info const &info) { return demangle(info.name());}
}}

View File

@ -19,47 +19,19 @@
* TRIQS. If not, see <http://www.gnu.org/licenses/>. * TRIQS. If not, see <http://www.gnu.org/licenses/>.
* *
******************************************************************************/ ******************************************************************************/
#ifndef TRIQS_TYPE_ID_NAME_H #pragma once
#define TRIQS_TYPE_ID_NAME_H
#include <string> #include <string>
#include <sstream>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
#include <boost/algorithm/string/erase.hpp>
namespace triqs { namespace utility { namespace triqs { namespace utility {
inline std::string demangle(const char * name) { std::string demangle(const char * name);
std::stringstream fs; std::string demangle(std::string const & name);
#ifdef __GNUC__ std::string get_name(std::type_info const &info);
int status;
char * demangled = abi::__cxa_demangle(name, NULL, NULL, &status);
if (!status) {
std::string res(demangled);
boost::erase_all(res,", boost::tuples::null_type");
boost::erase_all(res,", -1");
boost::erase_all(res,", void");
fs<< res;
free(demangled);
} else fs<< name;
//fs<<abi::__cxa_demangle(typeid(A).name(), 0, 0, &status);
#else
fs<<name;
#endif
return fs.str();
}
inline std::string demangle(std::string const & name) { return demangle (name.c_str());}
template<typename T> template<typename T>
std::string typeid_name(T const & A) { return demangle(typeid(A).name());} std::string typeid_name(T const & A) { return get_name(typeid(A));}
template<typename T> template<typename T>
std::string typeid_name() { return demangle(typeid(std::declval<T>()).name());} std::string typeid_name() { return get_name(typeid(std::declval<T>()));}
}} }}
#endif