1 //------------------------------------------------------------------------------
2 // GB_unop:  hard-coded functions for each built-in unary operator
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 // If this file is in the Generated/ folder, do not edit it (auto-generated).
11 
12 #include "GB.h"
13 #ifndef GBCOMPACT
14 #include "GB_control.h"
15 #include "GB_atomics.h"
16 #include "GB_unop__include.h"
17 
18 // C=unop(A) is defined by the following types and operators:
19 
20 // op(A)  function:  GB (_unop_apply__identity_uint64_fc64)
21 // op(A') function:  GB (_unop_tran__identity_uint64_fc64)
22 
23 // C type:   uint64_t
24 // A type:   GxB_FC64_t
25 // cast:     uint64_t cij = GB_cast_to_uint64_t (creal (aij))
26 // unaryop:  cij = aij
27 
28 #define GB_ATYPE \
29     GxB_FC64_t
30 
31 #define GB_CTYPE \
32     uint64_t
33 
34 // aij = Ax [pA]
35 #define GB_GETA(aij,Ax,pA) \
36     GxB_FC64_t aij = Ax [pA]
37 
38 #define GB_CX(p) Cx [p]
39 
40 // unary operator
41 #define GB_OP(z, x) \
42     z = x ;
43 
44 // casting
45 #define GB_CAST(z, aij) \
46     uint64_t z = GB_cast_to_uint64_t (creal (aij)) ;
47 
48 // cij = op (aij)
49 #define GB_CAST_OP(pC,pA)           \
50 {                                   \
51     /* aij = Ax [pA] */             \
52     GxB_FC64_t aij = Ax [pA] ;          \
53     /* Cx [pC] = op (cast (aij)) */ \
54     uint64_t z = GB_cast_to_uint64_t (creal (aij)) ;               \
55     Cx [pC] = z ;        \
56 }
57 
58 // true if operator is the identity op with no typecasting
59 #define GB_OP_IS_IDENTITY_WITH_NO_TYPECAST \
60     0
61 
62 // disable this operator and use the generic case if these conditions hold
63 #define GB_DISABLE \
64     (GxB_NO_IDENTITY || GxB_NO_UINT64 || GxB_NO_FC64)
65 
66 //------------------------------------------------------------------------------
67 // Cx = op (cast (Ax)): apply a unary operator
68 //------------------------------------------------------------------------------
69 
GB(_unop_apply__identity_uint64_fc64)70 GrB_Info GB (_unop_apply__identity_uint64_fc64)
71 (
72     uint64_t *Cx,       // Cx and Ax may be aliased
73     const GxB_FC64_t *Ax,
74     const int8_t *restrict Ab,   // A->b if A is bitmap
75     int64_t anz,
76     int nthreads
77 )
78 {
79     #if GB_DISABLE
80     return (GrB_NO_VALUE) ;
81     #else
82     int64_t p ;
83 
84     // TODO: if OP is ONE and uniform-valued matrices are exploited, then
85     // do this in O(1) time
86 
87     if (Ab == NULL)
88     {
89         #if ( GB_OP_IS_IDENTITY_WITH_NO_TYPECAST )
90             GB_memcpy (Cx, Ax, anz * sizeof (GxB_FC64_t), nthreads) ;
91         #else
92             #pragma omp parallel for num_threads(nthreads) schedule(static)
93             for (p = 0 ; p < anz ; p++)
94             {
95                 GxB_FC64_t aij = Ax [p] ;
96                 uint64_t z = GB_cast_to_uint64_t (creal (aij)) ;
97                 Cx [p] = z ;
98             }
99         #endif
100     }
101     else
102     {
103         // bitmap case, no transpose; A->b already memcpy'd into C->b
104         #pragma omp parallel for num_threads(nthreads) schedule(static)
105         for (p = 0 ; p < anz ; p++)
106         {
107             if (!Ab [p]) continue ;
108             GxB_FC64_t aij = Ax [p] ;
109             uint64_t z = GB_cast_to_uint64_t (creal (aij)) ;
110             Cx [p] = z ;
111         }
112     }
113     return (GrB_SUCCESS) ;
114     #endif
115 }
116 
117 //------------------------------------------------------------------------------
118 // C = op (cast (A')): transpose, typecast, and apply a unary operator
119 //------------------------------------------------------------------------------
120 
GB(_unop_tran__identity_uint64_fc64)121 GrB_Info GB (_unop_tran__identity_uint64_fc64)
122 (
123     GrB_Matrix C,
124     const GrB_Matrix A,
125     int64_t *restrict *Workspaces,
126     const int64_t *restrict A_slice,
127     int nworkspaces,
128     int nthreads
129 )
130 {
131     #if GB_DISABLE
132     return (GrB_NO_VALUE) ;
133     #else
134     #include "GB_unop_transpose.c"
135     return (GrB_SUCCESS) ;
136     #endif
137 }
138 
139 #endif
140 
141