Rheolef  7.1
an efficient C++ finite element environment
msg_right_permutation_apply.h
Go to the documentation of this file.
1 #ifndef _RHEO_MSG_RIGHT_PERMUTATION_APPLY_H
2 #define _RHEO_MSG_RIGHT_PERMUTATION_APPLY_H
3 namespace rheolef {
24 /*F:
25 NAME: msg_right_permutation_apply -- sequentail apply (@PACKAGE@ @VERSION@)
26 DESCRIPTION:
27  Applies a permutation to an array.
28 ALGORITHM:
29  msg_right_permutation_apply
30 
31  "input": the length array
32  | perm(0:n-1), x(0:nx-1)
33  "output": the pointer array and the total size
34  | y(0:n)
35  begin
36  | for i := 0 to n-1 do
37  | y(i) := x(perm(i))
38  | endfor
39  end
40 COMPLEXITY:
41  Time and memory complexity is O(n).
42 METHODS: @msg_right_permutation_apply
43 AUTHORS:
44  LMC-IMAG, 38041 Grenoble cedex 9, France
45  | Pierre.Saramito@imag.fr
46 DATE: 6 january 1999
47 END:
48 */
49 
50 //<msg_right_permutation_apply:
51 template <
52  class InputIterator,
53  class InputRandomIterator,
54  class OutputIterator,
55  class SetOp>
56 OutputIterator
58  InputIterator perm,
59  InputIterator last_perm,
60  const InputRandomIterator& x,
61  OutputIterator y,
62  SetOp set_op)
63 {
64  for (; perm != last_perm; y++, perm++) {
65  // something like: (*y++) = x[(*perm++)];
66  set_op (y, x, *perm);
67  }
68  return y;
69 }
70 //>msg_right_permutation_apply:
71 
72 // set(rhs,lhs,i) <==> *rhs = lhs[i] or *rhs = pair(i,rhs[i])
73 
74 // 1) used by csr<Float>:
75 template<class OutputIterator, class InputRandomIterator, class Size>
77  void operator() (OutputIterator rhs, const InputRandomIterator& lhs, Size i) {
78  *rhs = lhs [i];
79  }
80 };
81 template <
82  class InputIterator,
83  class InputRandomIterator,
84  class OutputIterator>
85 inline
86 OutputIterator
88  InputIterator perm,
89  InputIterator last_perm,
90  const InputRandomIterator& x,
91  OutputIterator y)
92 {
93  typedef typename std::iterator_traits<InputIterator>::value_type size_type;
95  return msg_right_permutation_apply (perm, last_perm, x, y, set_op);
96 }
97 #ifdef TO_CLEAN
98 // used by polymorphic_array<geo_element> in geo<Float>:
99 template<class OutputIterator, class InputRandomIterator, class Size>
100 struct msg_right_permutation_set_pair {
101  typedef typename std::iterator_traits<OutputIterator>::value_type T;
102  void operator() (OutputIterator rhs, const InputRandomIterator& lhs, Size i) {
103  *rhs = std::pair<Size,T>(i,lhs [i]);
104  }
105 };
106 #endif // TO_CLEAN
107 
108 
109 } // namespace rheolef
110 #endif // _RHEO_MSG_RIGHT_PERMUTATION_APPLY_H
rheolef::msg_right_permutation_set_default
Definition: msg_right_permutation_apply.h:76
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::msg_right_permutation_set_default::operator()
void operator()(OutputIterator rhs, const InputRandomIterator &lhs, Size i)
Definition: msg_right_permutation_apply.h:77
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::msg_right_permutation_apply
OutputIterator msg_right_permutation_apply(InputIterator perm, InputIterator last_perm, const InputRandomIterator &x, OutputIterator y, SetOp set_op)
Definition: msg_right_permutation_apply.h:57
rheolef::set_op
Definition: msg_util.h:56
T
Expr1::float_type T
Definition: field_expr.h:218