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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (show annotations)
Mon Sep 15 01:25:23 2014 UTC (5 years, 8 months ago) by caltinay
File MIME type: text/plain
File size: 3032 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

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 multiply.h
18 * \brief Matrix multiplication
19 */
20
21 #pragma once
22
23 #include <cusp/detail/config.h>
24
25 namespace cusp
26 {
27
28 /*! \addtogroup algorithms Algorithms
29 * \ingroup algorithms
30 * \{
31 */
32
33 /*! \p multiply : Implements matrix-matrix and matrix-vector multiplication
34 *
35 * \p multiply can be used with dense matrices, sparse matrices, and user-defined
36 * \p linear_operator objects.
37 *
38 * \param A input matrix
39 * \param B input matrix or vector
40 * \param C output matrix or vector
41 *
42 * \tparam LinearOperator matrix
43 * \tparam MatrixOrVector1 matrix or vector
44 * \tparam MatrixOrVector2 matrix or vector
45 *
46 * The following code snippet demonstrates how to use \p multiply to
47 * compute a matrix-vector product.
48 *
49 * \code
50 * #include <cusp/multiply.h>
51 * #include <cusp/array2d.h>
52 * #include <cusp/print.h>
53 *
54 * int main(void)
55 * {
56 * // initialize matrix
57 * cusp::array2d<float, cusp::host_memory> A(2,2);
58 * A(0,0) = 10; A(0,1) = 20;
59 * A(1,0) = 40; A(1,1) = 50;
60 *
61 * // initialize input vector
62 * cusp::array1d<float, cusp::host_memory> x(2);
63 * x[0] = 1;
64 * x[1] = 2;
65 *
66 * // allocate output vector
67 * cusp::array1d<float, cusp::host_memory> y(2);
68 *
69 * // compute y = A * x
70 * cusp::multiply(A, x, y);
71 *
72 * // print y
73 * cusp::print(y);
74 *
75 * return 0;
76 * }
77 * \endcode
78 */
79 template <typename LinearOperator,
80 typename MatrixOrVector1,
81 typename MatrixOrVector2>
82 void multiply(LinearOperator& A,
83 MatrixOrVector1& B,
84 MatrixOrVector2& C);
85
86 template <typename LinearOperator,
87 typename MatrixOrVector1,
88 typename MatrixOrVector2>
89 void multiply(const LinearOperator& A,
90 const MatrixOrVector1& B,
91 const MatrixOrVector2& C);
92
93 template <typename LinearOperator,
94 typename MatrixOrVector1,
95 typename MatrixOrVector2>
96 void transposed_multiply(LinearOperator& A,
97 MatrixOrVector1& B,
98 MatrixOrVector2& C);
99
100 template <typename LinearOperator,
101 typename MatrixOrVector1,
102 typename MatrixOrVector2>
103 void transposed_multiply(const LinearOperator& A,
104 const MatrixOrVector1& B,
105 const MatrixOrVector2& C);
106 /*! \}
107 */
108
109 } // end namespace cusp
110
111 #include <cusp/detail/multiply.inl>
112

  ViewVC Help
Powered by ViewVC 1.1.26