Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
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
23namespace rheolef {
24/*F:
25NAME: msg_right_permutation_apply -- sequentail apply (@PACKAGE@ @VERSION@)
26DESCRIPTION:
27 Applies a permutation to an array.
28ALGORITHM:
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
40COMPLEXITY:
41 Time and memory complexity is O(n).
42METHODS: @msg_right_permutation_apply
43AUTHORS:
44 LMC-IMAG, 38041 Grenoble cedex 9, France
45 | Pierre.Saramito@imag.fr
46DATE: 6 january 1999
47END:
48*/
49
50//<msg_right_permutation_apply:
51template <
52 class InputIterator,
53 class InputRandomIterator,
54 class OutputIterator,
55 class SetOp>
56OutputIterator
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>:
75template<class OutputIterator, class InputRandomIterator, class Size>
77 void operator() (OutputIterator rhs, const InputRandomIterator& lhs, Size i) {
78 *rhs = lhs [i];
79 }
80};
81template <
82 class InputIterator,
83 class InputRandomIterator,
84 class OutputIterator>
85inline
86OutputIterator
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>:
99template<class OutputIterator, class InputRandomIterator, class Size>
100struct 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
field::size_type size_type
Definition branch.cc:430
Expr1::float_type T
Definition field_expr.h:230
This file is part of Rheolef.
OutputIterator msg_right_permutation_apply(InputIterator perm, InputIterator last_perm, const InputRandomIterator &x, OutputIterator y, SetOp set_op)
void operator()(OutputIterator rhs, const InputRandomIterator &lhs, Size i)