repeated.hpp 1.24 KB
Newer Older
1
// Software License for MTL
2
3
//
// Copyright (c) 2007 The Trustees of Indiana University.
4
//               2008 Dresden University of Technology and the Trustees of Indiana University.
5
//               2010 SimuNova UG (haftungsbeschränkt), www.simunova.com.
6
7
// All rights reserved.
// Authors: Peter Gottschling and Andrew Lumsdaine
8
//
9
// This file is part of the Matrix Template Library
10
//
11
12
13
14
15
16
17
18
19
20
21
22
23
// See also license.mtl.txt in the distribution.

#ifndef ITL_REPEATED_INCLUDE
#define ITL_REPEATED_INCLUDE

namespace itl {

/// Repeat the smoother
template <typename Smoother, std::size_t N= 1>
class repeated
{
  public:

24
    typedef Smoother smoother_type;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

    /// Construct with \p smoother
    repeated(const Smoother& smoother) : smoother(smoother) {}

    /// Construct with \p smoother and number of repetitions \p n
    template <typename Matrix>
    repeated(const Matrix& A) : smoother(A) {}

    /// Apply smoother n times on vector \p x, i.e. \p x is changed
    template <typename Vector, typename RHSVector>
    Vector& operator()(Vector& x, const RHSVector& b) const
    {
	for (std::size_t i= 0; i < N; i++)
	    smoother(x, b);
 	return x;
    }

  private:
    Smoother    smoother;
    std::size_t n;
};


} // namespace itl

#endif // ITL_REPEATED_INCLUDE