/[escript]/branches/diaplayground/cusplibrary/cusp/detail/multiply.inl
ViewVC logotype

Annotation of /branches/diaplayground/cusplibrary/cusp/detail/multiply.inl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4955 - (hide annotations)
Tue May 20 04:33:15 2014 UTC (5 years, 2 months ago) by caltinay
File size: 2688 byte(s)
added pristine copy of cusplibrary (apache license) to be used by ripley.

1 caltinay 4955 /*
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     #include <cusp/detail/dispatch/multiply.h>
18    
19     #include <cusp/linear_operator.h>
20     #include <thrust/detail/type_traits.h>
21    
22     namespace cusp
23     {
24     namespace detail
25     {
26    
27     template <typename LinearOperator,
28     typename MatrixOrVector1,
29     typename MatrixOrVector2>
30     void multiply(LinearOperator& A,
31     MatrixOrVector1& B,
32     MatrixOrVector2& C,
33     cusp::unknown_format)
34     {
35     // user-defined LinearOperator
36     A(B,C);
37     }
38    
39     template <typename LinearOperator,
40     typename MatrixOrVector1,
41     typename MatrixOrVector2>
42     void multiply(LinearOperator& A,
43     MatrixOrVector1& B,
44     MatrixOrVector2& C,
45     cusp::known_format)
46     {
47     // built-in format
48     cusp::detail::dispatch::multiply(A, B, C,
49     typename LinearOperator::memory_space(),
50     typename MatrixOrVector1::memory_space(),
51     typename MatrixOrVector2::memory_space());
52     }
53    
54     } // end namespace detail
55    
56     template <typename LinearOperator,
57     typename MatrixOrVector1,
58     typename MatrixOrVector2>
59     void multiply(LinearOperator& A,
60     MatrixOrVector1& B,
61     MatrixOrVector2& C)
62     {
63     CUSP_PROFILE_SCOPED();
64    
65     // TODO check that dimensions are compatible
66    
67     typedef typename LinearOperator::value_type ValueType;
68     typedef typename LinearOperator::memory_space MemorySpace;
69    
70     cusp::detail::multiply(A, B, C,
71     typename LinearOperator::format());
72     }
73    
74     template <typename LinearOperator,
75     typename MatrixOrVector1,
76     typename MatrixOrVector2>
77     void multiply(const LinearOperator& A,
78     const MatrixOrVector1& B,
79     const MatrixOrVector2& C)
80     {
81     CUSP_PROFILE_SCOPED();
82    
83     // TODO check that dimensions are compatible
84    
85     typedef typename LinearOperator::value_type ValueType;
86     typedef typename LinearOperator::memory_space MemorySpace;
87    
88     cusp::detail::multiply(A, B, C,
89     typename LinearOperator::format());
90     }
91    
92     } // end namespace cusp
93    

  ViewVC Help
Powered by ViewVC 1.1.26