1 //------------------------------------------------------------------------------
2 // GrB_mxv: matrix-vector multiply
3 //------------------------------------------------------------------------------
4
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7
8 //------------------------------------------------------------------------------
9
10 // w<M> = accum (w,t) where t = A*u or A'*u (u is never transposed)
11
12 // The input matrix A is optionally transposed, as determined by the
13 // Descriptor desc.
14
15 #include "GB_mxm.h"
16
GrB_mxv(GrB_Vector w,const GrB_Vector M,const GrB_BinaryOp accum,const GrB_Semiring semiring,const GrB_Matrix A,const GrB_Vector u,const GrB_Descriptor desc)17 GrB_Info GrB_mxv // w<M> = accum (w, A*u)
18 (
19 GrB_Vector w, // input/output vector for results
20 const GrB_Vector M, // optional mask for w, unused if NULL
21 const GrB_BinaryOp accum, // optional accum for z=accum(w,t)
22 const GrB_Semiring semiring, // defines '+' and '*' for matrix multiply
23 const GrB_Matrix A, // first input: matrix A
24 const GrB_Vector u, // second input: vector u
25 const GrB_Descriptor desc // descriptor for w, M, A,
26 // and method used for C=A*B
27 )
28 {
29
30 //--------------------------------------------------------------------------
31 // check inputs
32 //--------------------------------------------------------------------------
33
34 GB_WHERE (w, "GrB_mxv (w, M, accum, semiring, A, u, desc)") ;
35 GB_BURBLE_START ("GrB_mxv") ;
36 GB_RETURN_IF_NULL_OR_FAULTY (w) ;
37 GB_RETURN_IF_FAULTY (M) ;
38 GB_RETURN_IF_NULL_OR_FAULTY (A) ;
39 GB_RETURN_IF_NULL_OR_FAULTY (u) ;
40 ASSERT (GB_VECTOR_OK (w)) ;
41 ASSERT (M == NULL || GB_VECTOR_OK (M)) ;
42 ASSERT (GB_VECTOR_OK (u)) ;
43
44 // get the descriptor
45 GB_GET_DESCRIPTOR (info, desc, C_replace, Mask_comp, Mask_struct,
46 A_transpose, xx, AxB_method, do_sort) ;
47
48 //--------------------------------------------------------------------------
49 // w<M> = accum (w,A*u) and variations, using the mxm kernel
50 //--------------------------------------------------------------------------
51
52 // w, M, and u are passed as matrices to GB_mxm.
53 info = GB_mxm (
54 (GrB_Matrix) w, C_replace, // w and its descriptor
55 (GrB_Matrix) M, Mask_comp, Mask_struct, // mask and its descriptor
56 accum, // for accum (w,t)
57 semiring, // definition of matrix multiply
58 A, A_transpose, // allow A to be transposed
59 (GrB_Matrix) u, false, // u is never transposed
60 false, // fmult(x,y), flipxy = false
61 AxB_method, do_sort, // algorithm selector
62 Context) ;
63
64 GB_BURBLE_END ;
65 return (info) ;
66 }
67
68