/******************************************************************************* * * TRIQS: a Toolbox for Research in Interacting Quantum Systems * * Copyright (C) 2011-2014 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 "./macros.hpp" #include "./c14.hpp" #include "./compiler_details.hpp" #include "./exceptions.hpp" #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 { struct no_init_tag{}; template class mini_vector { T _data[(Rank!=0 ? Rank : 1)]; 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 class mini_vector { T _data[1]; public: mini_vector(){} mini_vector(no_init_tag){} T & operator[](size_t i) { return _data[i];} const T & operator[](size_t i) const { return _data[i];} T * restrict ptr() { return _data;} const T * restrict ptr() const { return _data;} friend std::ostream & operator << ( std::ostream & out, mini_vector const & v ) {return out<<"[]";} }; // ------------- Comparison -------------------------------------- template 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));} // ------------- join -------------------------------------- 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 mini_vector::value> tuple_to_mini_vector(TU const &t) { // return tuple::apply_construct_parenthesis::value>>(t); // } //#endif }}//namespace triqs::arrays namespace std { // overload std::get to work with it template AUTO_DECL get(triqs::utility::mini_vector &v) RETURN(v[i]); template AUTO_DECL get(triqs::utility::mini_vector const &v) RETURN(v[i]); template struct tuple_size>: std::integral_constant{}; } #endif