Line data Source code
1 : /*! \file
2 : Copyright (c) 2003, The Regents of the University of California, through
3 : Lawrence Berkeley National Laboratory (subject to receipt of any required
4 : approvals from U.S. Dept. of Energy)
5 :
6 : All rights reserved.
7 :
8 : The source code is distributed under BSD license, see the file License.txt
9 : at the top-level directory.
10 : */
11 :
12 : /*! @file dsp_blas3.c
13 : * \brief Sparse BLAS3, using some dense BLAS3 operations
14 : *
15 : * <pre>
16 : * -- SuperLU routine (version 2.0) --
17 : * Univ. of California Berkeley, Xerox Palo Alto Research Center,
18 : * and Lawrence Berkeley National Lab.
19 : * November 15, 1997
20 : * </pre>
21 : */
22 : /*
23 : * File name: sp_blas3.c
24 : * Purpose: Sparse BLAS3, using some dense BLAS3 operations.
25 : */
26 :
27 : #include "slu_ddefs.h"
28 :
29 : /*! \brief
30 : *
31 : * <pre>
32 : * Purpose
33 : * =======
34 : *
35 : * sp_d performs one of the matrix-matrix operations
36 : *
37 : * C := alpha*op( A )*op( B ) + beta*C,
38 : *
39 : * where op( X ) is one of
40 : *
41 : * op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ),
42 : *
43 : * alpha and beta are scalars, and A, B and C are matrices, with op( A )
44 : * an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
45 : *
46 : *
47 : * Parameters
48 : * ==========
49 : *
50 : * TRANSA - (input) char*
51 : * On entry, TRANSA specifies the form of op( A ) to be used in
52 : * the matrix multiplication as follows:
53 : * TRANSA = 'N' or 'n', op( A ) = A.
54 : * TRANSA = 'T' or 't', op( A ) = A'.
55 : * TRANSA = 'C' or 'c', op( A ) = conjg( A' ).
56 : * Unchanged on exit.
57 : *
58 : * TRANSB - (input) char*
59 : * On entry, TRANSB specifies the form of op( B ) to be used in
60 : * the matrix multiplication as follows:
61 : * TRANSB = 'N' or 'n', op( B ) = B.
62 : * TRANSB = 'T' or 't', op( B ) = B'.
63 : * TRANSB = 'C' or 'c', op( B ) = conjg( B' ).
64 : * Unchanged on exit.
65 : *
66 : * M - (input) int
67 : * On entry, M specifies the number of rows of the matrix
68 : * op( A ) and of the matrix C. M must be at least zero.
69 : * Unchanged on exit.
70 : *
71 : * N - (input) int
72 : * On entry, N specifies the number of columns of the matrix
73 : * op( B ) and the number of columns of the matrix C. N must be
74 : * at least zero.
75 : * Unchanged on exit.
76 : *
77 : * K - (input) int
78 : * On entry, K specifies the number of columns of the matrix
79 : * op( A ) and the number of rows of the matrix op( B ). K must
80 : * be at least zero.
81 : * Unchanged on exit.
82 : *
83 : * ALPHA - (input) double
84 : * On entry, ALPHA specifies the scalar alpha.
85 : *
86 : * A - (input) SuperMatrix*
87 : * Matrix A with a sparse format, of dimension (A->nrow, A->ncol).
88 : * Currently, the type of A can be:
89 : * Stype = NC or NCP; Dtype = SLU_D; Mtype = GE.
90 : * In the future, more general A can be handled.
91 : *
92 : * B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is
93 : * n when TRANSB = 'N' or 'n', and is k otherwise.
94 : * Before entry with TRANSB = 'N' or 'n', the leading k by n
95 : * part of the array B must contain the matrix B, otherwise
96 : * the leading n by k part of the array B must contain the
97 : * matrix B.
98 : * Unchanged on exit.
99 : *
100 : * LDB - (input) int
101 : * On entry, LDB specifies the first dimension of B as declared
102 : * in the calling (sub) program. LDB must be at least max( 1, n ).
103 : * Unchanged on exit.
104 : *
105 : * BETA - (input) double
106 : * On entry, BETA specifies the scalar beta. When BETA is
107 : * supplied as zero then C need not be set on input.
108 : *
109 : * C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
110 : * Before entry, the leading m by n part of the array C must
111 : * contain the matrix C, except when beta is zero, in which
112 : * case C need not be set on entry.
113 : * On exit, the array C is overwritten by the m by n matrix
114 : * ( alpha*op( A )*B + beta*C ).
115 : *
116 : * LDC - (input) int
117 : * On entry, LDC specifies the first dimension of C as declared
118 : * in the calling (sub)program. LDC must be at least max(1,m).
119 : * Unchanged on exit.
120 : *
121 : * ==== Sparse Level 3 Blas routine.
122 : * </pre>
123 : */
124 :
125 : int
126 0 : sp_dgemm(char *transa, char *transb, int m, int n, int k,
127 : double alpha, SuperMatrix *A, double *b, int ldb,
128 : double beta, double *c, int ldc)
129 : {
130 : int incx = 1, incy = 1;
131 : int j;
132 :
133 0 : for (j = 0; j < n; ++j) {
134 0 : sp_dgemv(transa, alpha, A, &b[ldb*j], incx, beta, &c[ldc*j], incy);
135 : }
136 0 : return 0;
137 : }
|