/******************************************************************************* * * TRIQS: a Toolbox for Research in Interacting Quantum Systems * * Copyright (C) 2011 by 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 . * ******************************************************************************/ #ifndef TRIQS_ARRAYS_MINI_VECTOR_H #define TRIQS_ARRAYS_MINI_VECTOR_H #include "./first_include.hpp" #include #include "./compiler_details.hpp" #include "./exceptions.hpp" #include #include #include #include #include #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 { template class mini_vector { T _data[Rank]; friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("_data",_data); } void init() { for (int i=0;i mini_vector(const mini_vector & x){ *this = x; } mini_vector(const std::vector & v){ if (v.size()!=Rank) TRIQS_RUNTIME_ERROR<< "mini_vector construction : vector size incorrect : expected "< mini_vector & operator=(const mini_vector & x){ for (int i=0;i to_vector () const { std::vector V(Rank); for (int i=0;i append (T const & x) const { mini_vector res; for (int i=0;i front_append (T const & x) const { mini_vector res; for (int i=0;i pop () const { mini_vector res; for (int i=0;i front_pop () const { mini_vector res; for (int i=1;i bool operator ==(mini_vector const & v1, mini_vector const & v2) { for (int i=0;i bool operator !=(mini_vector const & v1, mini_vector const & v2) { return (!(v1==v2));} template mini_vector join (mini_vector const & v1, mini_vector const & v2) { mini_vector res; for (int i=0;i T1 dot_product(mini_vector const & v1, mini_vector const & v2) { T1 res=0; for (int i=0;i V * operator()(M const & m, V * v) { *v = m; return ++v;}}; // change : the first version crash clang 3.3, but not svn version. // must be a bug, corrected since then /* template mini_vector tuple_to_mini_vector(std::tuple const & t) { mini_vector res; triqs::tuple::fold(tuple_to_mini_vector_aux(),t,&res[0]); return res; } */ template mini_vector::value> tuple_to_mini_vector(TU const & t) { mini_vector::value> res; triqs::tuple::fold(tuple_to_mini_vector_aux(),t,&res[0]); return res; } }}//namespace triqs::arrays #endif