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

Contents of /branches/diaplayground/cusplibrary/cusp/krylov/bicgstab.h

Parent Directory Parent Directory | Revision Log Revision Log


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

1 /*
2 * Copyright 2008-2009 NVIDIA Corporation
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 bicgstab.h
18 * \brief Biconjugate Gradient Stabilized (BiCGstab) method
19 */
20
21 #pragma once
22
23 #include <cusp/detail/config.h>
24
25 namespace cusp
26 {
27 namespace krylov
28 {
29 /*! \addtogroup iterative_solvers Iterative Solvers
30 * \addtogroup krylov_methods Krylov Methods
31 * \ingroup iterative_solvers
32 * \{
33 */
34
35 /*! \p bicgstab : Biconjugate Gradient Stabilized method
36 *
37 * Solves the linear system A x = b using the default convergence criteria.
38 */
39 template <class LinearOperator,
40 class Vector>
41 void bicgstab(LinearOperator& A,
42 Vector& x,
43 Vector& b);
44
45 /*! \p bicgstab : Biconjugate Gradient Stabilized method
46 *
47 * Solves the linear system A x = b without preconditioning.
48 */
49 template <class LinearOperator,
50 class Vector,
51 class Monitor>
52 void bicgstab(LinearOperator& A,
53 Vector& x,
54 Vector& b,
55 Monitor& monitor);
56
57 /*! \p bicgstab : Biconjugate Gradient Stabilized method
58 *
59 * Solves the linear system A x = b with preconditioner \p M.
60 *
61 * \param A matrix of the linear system
62 * \param x approximate solution of the linear system
63 * \param b right-hand side of the linear system
64 * \param monitor montiors iteration and determines stopping conditions
65 * \param M preconditioner for A
66 *
67 * \tparam LinearOperator is a matrix or subclass of \p linear_operator
68 * \tparam Vector vector
69 * \tparam Monitor is a monitor such as \p default_monitor or \p verbose_monitor
70 * \tparam Preconditioner is a matrix or subclass of \p linear_operator
71 *
72 * The following code snippet demonstrates how to use \p bicgstab to
73 * solve a 10x10 Poisson problem.
74 *
75 * \code
76 * #include <cusp/csr_matrix.h>
77 * #include <cusp/monitor.h>
78 * #include <cusp/krylov/bicgstab.h>
79 * #include <cusp/gallery/poisson.h>
80 *
81 * int main(void)
82 * {
83 * // create an empty sparse matrix structure (CSR format)
84 * cusp::csr_matrix<int, float, cusp::device_memory> A;
85 *
86 * // initialize matrix
87 * cusp::gallery::poisson5pt(A, 10, 10);
88 *
89 * // allocate storage for solution (x) and right hand side (b)
90 * cusp::array1d<float, cusp::device_memory> x(A.num_rows, 0);
91 * cusp::array1d<float, cusp::device_memory> b(A.num_rows, 1);
92 *
93 * // set stopping criteria:
94 * // iteration_limit = 100
95 * // relative_tolerance = 1e-6
96 * cusp::verbose_monitor<float> monitor(b, 100, 1e-6);
97 *
98 * // set preconditioner (identity)
99 * cusp::identity_operator<float, cusp::device_memory> M(A.num_rows, A.num_rows);
100 *
101 * // solve the linear system A x = b
102 * cusp::krylov::bicgstab(A, x, b, monitor, M);
103 *
104 * return 0;
105 * }
106 * \endcode
107 *
108 * \see \p default_monitor
109 * \see \p verbose_monitor
110 */
111 template <class LinearOperator,
112 class Vector,
113 class Monitor,
114 class Preconditioner>
115 void bicgstab(LinearOperator& A,
116 Vector& x,
117 Vector& b,
118 Monitor& monitor,
119 Preconditioner& M);
120 /*! \}
121 */
122
123 } // end namespace krylov
124 } // end namespace cusp
125
126 #include <cusp/krylov/detail/bicgstab.inl>
127

  ViewVC Help
Powered by ViewVC 1.1.26