/[escript]/branches/diaplayground/cusplibrary/cusp/krylov/gmres.h
ViewVC logotype

Annotation of /branches/diaplayground/cusplibrary/cusp/krylov/gmres.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4955 - (hide annotations)
Tue May 20 04:33:15 2014 UTC (6 years, 4 months ago) by caltinay
File MIME type: text/plain
File size: 4385 byte(s)
added pristine copy of cusplibrary (apache license) to be used by ripley.

1 caltinay 4955 /*
2     * Copyright 2011 The Regents of the University of California
3     *
4     * Licensed under the Apache License, Version 2.0 (the "License");
5     * you may not use this file except in compliance with the License.
6     * You may obtain a copy of the License at
7     *
8     * http://www.apache.org/licenses/LICENSE-2.0
9     *
10     * Unless required by applicable law or agreed to in writing, software
11     * distributed under the License is distributed on an "AS IS" BASIS,
12     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     * See the License for the specific language governing permissions and
14     * limitations under the License.
15     */
16    
17     /*! \file gmres.h
18     * \brief Generalized Minimum Residual (GMRES) method
19     */
20    
21     #pragma once
22    
23     #include <cusp/detail/config.h>
24    
25     namespace cusp
26     {
27     namespace krylov
28     {
29    
30     /*! \addtogroup iterative_solvers Iterative Solvers
31     * \addtogroup krylov_methods Krylov Methods
32     * \ingroup iterative_solvers
33     * \{
34     */
35    
36     /*! \p gmres : GMRES method
37     *
38     * Solves the nonsymmetric, linear system A x = b
39     * using the default convergence criteria.
40     */
41     template <class LinearOperator, class Vector>
42     void gmres(LinearOperator& A,
43     Vector& x,
44     Vector& b,
45     const size_t restart);
46    
47     /*! \p gmres : GMRES method
48     *
49     * Solves the nonsymmetric, linear system A x = b without preconditioning.
50     */
51     template <class LinearOperator,
52     class Vector,
53     class Monitor>
54     void gmres(LinearOperator& A,
55     Vector& x,
56     Vector& b,
57     const size_t restart,
58     Monitor& monitor);
59    
60     /*! \p gmres : GMRES method
61     *
62     * Solves the nonsymmetric, linear system A x = b
63     * with preconditioner \p M.
64     *
65     * \param A matrix of the linear system
66     * \param x approximate solution of the linear system
67     * \param b right-hand side of the linear system
68     * \param restart the method every restart inner iterations
69     * \param monitor montiors iteration and determines stopping conditions
70     * \param M preconditioner for A
71     *
72     * \tparam LinearOperator is a matrix or subclass of \p linear_operator
73     * \tparam Vector vector
74     * \tparam Monitor is a monitor such as \p default_monitor or \p verbose_monitor
75     * \tparam Preconditioner is a matrix or subclass of \p linear_operator
76     *
77     * The following code snippet demonstrates how to use \p gmres to
78     * solve a 10x10 Poisson problem.
79     *
80     * \code
81     * #include <cusp/csr_matrix.h>
82     * #include <cusp/monitor.h>
83     * #include <cusp/krylov/gmres.h>
84     * #include <cusp/gallery/poisson.h>
85     *
86     * int main(void)
87     * {
88     * // create an empty sparse matrix structure (CSR format)
89     * cusp::csr_matrix<int, float, cusp::device_memory> A;
90     *
91     * // initialize matrix
92     * cusp::gallery::poisson5pt(A, 10, 10);
93     *
94     * // allocate storage for solution (x) and right hand side (b)
95     * cusp::array1d<float, cusp::device_memory> x(A.num_rows, 0);
96     * cusp::array1d<float, cusp::device_memory> b(A.num_rows, 1);
97     *
98     * // set stopping criteria:
99     * // iteration_limit = 100
100     * // relative_tolerance = 1e-6
101     * cusp::verbose_monitor<float> monitor(b, 100, 1e-6);
102     * int restart = 50;
103     *
104     * // set preconditioner (identity)
105     * cusp::identity_operator<float, cusp::device_memory> M(A.num_rows, A.num_rows);
106     *
107     * // solve the linear system A x = b
108     * cusp::krylov::gmres(A, x, b,restart, monitor, M);
109     *
110     * return 0;
111     * }
112     * \endcode
113    
114     * \see \p default_monitor
115     * \see \p verbose_monitor
116     *
117     */
118     template <class LinearOperator,
119     class Vector,
120     class Monitor,
121     class Preconditioner>
122     void gmres(LinearOperator& A,
123     Vector& x,
124     Vector& b,
125     const size_t restart,
126     Monitor& monitor,
127     Preconditioner& M);
128     /*! \}
129     */
130    
131     } // end namespace krylov
132     } // end namespace cusp
133    
134     #include <cusp/krylov/detail/gmres.inl>
135    

  ViewVC Help
Powered by ViewVC 1.1.26