1 //------------------------------------------------------------------------------
2 // GrB_vxm: vector-matrix 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 = u'*A or u'*A'
11
12 // Rows w', u', and M' are simply columns w, u, and M. Thus:
13 // w<M> = accum (w,t) where t = A'*u or A*u, but with the multiply operator
14 // flipped. The input descriptor for A, inp1, is also negated.
15
16 #include "GB_mxm.h"
17
GrB_vxm(GrB_Vector w,const GrB_Vector M,const GrB_BinaryOp accum,const GrB_Semiring semiring,const GrB_Vector u,const GrB_Matrix A,const GrB_Descriptor desc)18 GrB_Info GrB_vxm // w'<M> = accum (w', u'*A)
19 (
20 GrB_Vector w, // input/output vector for results
21 const GrB_Vector M, // optional mask for w, unused if NULL
22 const GrB_BinaryOp accum, // optional accum for z=accum(w,t)
23 const GrB_Semiring semiring, // defines '+' and '*' for matrix multiply
24 const GrB_Vector u, // first input: vector u
25 const GrB_Matrix A, // second input: matrix A
26 const GrB_Descriptor desc // descriptor for w, M, and A
27 )
28 {
29
30 //--------------------------------------------------------------------------
31 // check inputs
32 //--------------------------------------------------------------------------
33
34 GB_WHERE (w, "GrB_vxm (w, M, accum, semiring, u, A, desc)") ;
35 GB_BURBLE_START ("GrB_vxm") ;
36 GB_RETURN_IF_NULL_OR_FAULTY (w) ;
37 GB_RETURN_IF_FAULTY (M) ;
38 GB_RETURN_IF_NULL_OR_FAULTY (u) ;
39 GB_RETURN_IF_NULL_OR_FAULTY (A) ;
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 xx, A_transpose, AxB_method, do_sort) ;
47
48 //--------------------------------------------------------------------------
49 // w'<M'> = accum (w',u'*A) and variations, using the mxm kernel
50 //--------------------------------------------------------------------------
51
52 // w, M, and u are treated as column vectors and passed as n-by-1 matrices
53 // to GB_mxm A and u are swapped, and A_transpose is negated:
54 // u'*A == A'*u
55 // u'*A' == A*u
56 // Since A and u are swapped, in all the matrix multiply kernels,
57 // the multiplier must be flipped, so flipxy is passed in as true.
58
59 info = GB_mxm (
60 (GrB_Matrix) w, C_replace, // w and its descriptor
61 (GrB_Matrix) M, Mask_comp, Mask_struct, // mask and its descriptor
62 accum, // for accum (w,t)
63 semiring, // definition of matrix multiply
64 A, !A_transpose, // allow A to be transposed
65 (GrB_Matrix) u, false, // u is never transposed
66 true, // fmult(y,x), flipxy = true
67 AxB_method, do_sort, // algorithm selector
68 Context) ;
69
70 GB_BURBLE_END ;
71 return (info) ;
72 }
73
74