CUSP
Loading...
Searching...
No Matches
linear_operator.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2014 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
21#pragma once
22
23#include <cusp/detail/config.h>
24
25#include <cusp/detail/format.h>
26#include <cusp/exception.h>
27#include <cusp/blas/blas.h>
28#include <cusp/detail/matrix_base.h>
29
30namespace cusp
31{
32
110template <typename ValueType, typename MemorySpace, typename IndexType=int>
111class linear_operator : public cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::unknown_format>
112{
113private:
114
115 typedef cusp::detail::matrix_base<IndexType,ValueType,MemorySpace,cusp::unknown_format> Parent;
116
117public:
118
122 : Parent() {}
123
129 linear_operator(IndexType num_rows, IndexType num_cols)
130 : Parent(num_rows, num_cols) {}
131
139 linear_operator(IndexType num_rows, IndexType num_cols, IndexType num_entries)
140 : Parent(num_rows, num_cols, num_entries) {}
141}; // linear_operator
142
182template <typename ValueType, typename MemorySpace, typename IndexType=int>
183class identity_operator : public linear_operator<ValueType,MemorySpace,IndexType>
184{
185private:
186
188
189public:
190
194 : Parent() {}
195
201 identity_operator(IndexType num_rows, IndexType num_cols)
202 : Parent(num_rows, num_cols) {}
203
213 template <typename DerivedPolicy, typename VectorType1, typename VectorType2>
214 void operator()(thrust::execution_policy<DerivedPolicy>& exec, const VectorType1& x, VectorType2& y) const
215 {
216 cusp::blas::copy(exec, x, y);
217 }
218
227 template <typename VectorType1, typename VectorType2>
228 void operator()(const VectorType1& x, VectorType2& y) const
229 {
230 cusp::blas::copy(x, y);
231 }
232}; // identity_operator
233
234} // end namespace cusp
235
BLAS-like functions.
Simple identity operator.
void operator()(thrust::execution_policy< DerivedPolicy > &exec, const VectorType1 &x, VectorType2 &y) const
Apply the identity operator to vector x using an explicit execution policy.
void operator()(const VectorType1 &x, VectorType2 &y) const
identity_operator(IndexType num_rows, IndexType num_cols)
Abstract representation of a linear operator.
linear_operator(IndexType num_rows, IndexType num_cols, IndexType num_entries)
linear_operator(IndexType num_rows, IndexType num_cols)