You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.8 KiB

  1. /* -*- c++ -*- (enables emacs c++ mode) */
  2. /*===========================================================================
  3. Copyright (C) 2002-2012 Yves Renard
  4. This file is a part of GETFEM++
  5. Getfem++ is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU Lesser General Public License as published
  7. by the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version along with the GCC Runtime Library
  9. Exception either version 3.1 or (at your option) any later version.
  10. This program is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License and GCC Runtime Library Exception for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  17. As a special exception, you may use this file as it is a part of a free
  18. software library without restriction. Specifically, if other files
  19. instantiate templates or use macros or inline functions from this file,
  20. or you compile this file and link it with other files to produce an
  21. executable, this file does not by itself cause the resulting executable
  22. to be covered by the GNU Lesser General Public License. This exception
  23. does not however invalidate any other reasons why the executable file
  24. might be covered by the GNU Lesser General Public License.
  25. ===========================================================================*/
  26. /**@file gmm_interface_bgeot.h
  27. @author Yves Renard <Yves.Renard@insa-lyon.fr>
  28. @date October 13, 2002.
  29. @brief interface for bgeot::small_vector
  30. */
  31. #ifndef GMM_INTERFACE_BGEOT_H__
  32. #define GMM_INTERFACE_BGEOT_H__
  33. namespace gmm {
  34. /* ********************************************************************* */
  35. /* */
  36. /* Traits for bgeot objects */
  37. /* */
  38. /* ********************************************************************* */
  39. template <typename T> struct linalg_traits<bgeot::small_vector<T> > {
  40. typedef bgeot::small_vector<T> this_type;
  41. typedef this_type origin_type;
  42. typedef linalg_false is_reference;
  43. typedef abstract_vector linalg_type;
  44. typedef T value_type;
  45. typedef T& reference;
  46. typedef typename this_type::iterator iterator;
  47. typedef typename this_type::const_iterator const_iterator;
  48. typedef abstract_dense storage_type;
  49. typedef linalg_true index_sorted;
  50. static size_type size(const this_type &v) { return v.size(); }
  51. static iterator begin(this_type &v) { return v.begin(); }
  52. static const_iterator begin(const this_type &v) { return v.begin(); }
  53. static iterator end(this_type &v) { return v.end(); }
  54. static const_iterator end(const this_type &v) { return v.end(); }
  55. static origin_type* origin(this_type &v) { return &v; }
  56. static const origin_type* origin(const this_type &v) { return &v; }
  57. static void clear(origin_type* o, const iterator &it, const iterator &ite)
  58. { std::fill(it, ite, value_type(0)); }
  59. static void do_clear(this_type &v)
  60. { std::fill(v.begin(), v.end(), value_type(0)); }
  61. static value_type access(const origin_type *, const const_iterator &it,
  62. const const_iterator &, size_type i)
  63. { return it[i]; }
  64. static reference access(origin_type *, const iterator &it,
  65. const iterator &, size_type i)
  66. { return it[i]; }
  67. static void resize(this_type &v, size_type n) { v.resize(n); }
  68. };
  69. }
  70. #endif // GMM_INTERFACE_BGEOT_H__