/[escript]/trunk/cusplibrary/cusp/linear_operator.h
ViewVC logotype

Contents of /trunk/cusplibrary/cusp/linear_operator.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4955 - (show annotations)
Tue May 20 04:33:15 2014 UTC (6 years, 1 month ago) by caltinay
Original Path: branches/diaplayground/cusplibrary/cusp/linear_operator.h
File MIME type: text/plain
File size: 2095 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 linear_operator.h
18 * \brief Abstract interface for iterative solvers
19 */
20
21 #pragma once
22
23 #include <cusp/detail/config.h>
24
25 #include <cusp/format.h>
26 #include <cusp/blas.h>
27 #include <cusp/exception.h>
28 #include <cusp/detail/matrix_base.h>
29
30 namespace cusp
31 {
32
33 template <typename ValueType, typename MemorySpace, typename IndexType=int>
34 class linear_operator : public cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::unknown_format>
35 {
36 typedef cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::unknown_format> Parent;
37 public:
38 linear_operator()
39 : Parent() {}
40
41 linear_operator(IndexType num_rows, IndexType num_cols)
42 : Parent(num_rows, num_cols) {}
43
44 linear_operator(IndexType num_rows, IndexType num_cols, IndexType num_entries)
45 : Parent(num_rows, num_cols, num_entries) {}
46 }; // linear_operator
47
48 template <typename ValueType, typename MemorySpace, typename IndexType=int>
49 class identity_operator : public linear_operator<ValueType,MemorySpace,IndexType>
50 {
51 typedef linear_operator<ValueType,MemorySpace> Parent;
52 public:
53
54 identity_operator()
55 : Parent() {}
56
57 identity_operator(IndexType num_rows, IndexType num_cols)
58 : Parent(num_rows, num_cols) {}
59
60 template <typename VectorType1,
61 typename VectorType2>
62 void operator()(const VectorType1& x, VectorType2& y) const
63 {
64 cusp::blas::copy(x, y);
65 }
66 }; // identity_operator
67
68 } // end namespace cusp
69

  ViewVC Help
Powered by ViewVC 1.1.26