33open GraphBLAS.FSharp .Backend .Objects
44
55module ArithmeticOperations =
6- let byteSumOption =
7- <@ fun ( x : byte option ) ( y : byte option ) ->
8- let mutable res = 0
9-
10- let xInt =
11- match x with
12- | Some x -> Some( int x)
13- | None -> None
14-
15- let yInt =
16- match y with
17- | Some y -> Some( int y)
18- | None -> None
19-
20- match xInt, yInt with
21- | Some f, Some s -> res <- f + s
22- | Some f, None -> res <- f
23- | None, Some s -> res <- s
24- | None, None -> ()
25-
26- let byteRes = byte res
27-
28- if byteRes = 0 uy then
29- None
30- else
31- Some byteRes @>
32-
33- let byteMulOption =
34- <@ fun ( x : byte option ) ( y : byte option ) ->
35- let mutable res = 0
36-
37- let xInt =
38- match x with
39- | Some x -> Some( int x)
40- | None -> None
41-
42- let yInt =
43- match y with
44- | Some y -> Some( int y)
45- | None -> None
46-
47- match xInt, yInt with
48- | Some f, Some s -> res <- f * s
49- | _ -> ()
50-
51- let byteRes = byte res
52-
53- if byteRes = 0 uy then
54- None
55- else
56- Some byteRes @>
57-
586 let inline mkUnaryOp zero unaryOp =
597 <@ fun x ->
608 let mutable res = zero
@@ -108,6 +56,33 @@ module ArithmeticOperations =
10856
10957 if res = zero then None else Some res @>
11058
59+ let byteSumOption =
60+ <@ fun ( x : byte option ) ( y : byte option ) ->
61+ let mutable res = 0
62+
63+ let xInt =
64+ match x with
65+ | Some x -> Some( int x)
66+ | None -> None
67+
68+ let yInt =
69+ match y with
70+ | Some y -> Some( int y)
71+ | None -> None
72+
73+ match xInt, yInt with
74+ | Some f, Some s -> res <- f + s
75+ | Some f, None -> res <- f
76+ | None, Some s -> res <- s
77+ | None, None -> ()
78+
79+ let byteRes = byte res
80+
81+ if byteRes = 0 uy then
82+ None
83+ else
84+ Some byteRes @>
85+
11186 let boolSumOption =
11287 <@ fun ( x : bool option ) ( y : bool option ) ->
11388 let mutable res = false
@@ -137,6 +112,31 @@ module ArithmeticOperations =
137112 let floatSumAtLeastOne = mkNumericSumAtLeastOne 0.0
138113 let float32SumAtLeastOne = mkNumericSumAtLeastOne 0 f
139114
115+ let byteMulOption =
116+ <@ fun ( x : byte option ) ( y : byte option ) ->
117+ let mutable res = 0
118+
119+ let xInt =
120+ match x with
121+ | Some x -> Some( int x)
122+ | None -> None
123+
124+ let yInt =
125+ match y with
126+ | Some y -> Some( int y)
127+ | None -> None
128+
129+ match xInt, yInt with
130+ | Some f, Some s -> res <- f * s
131+ | _ -> ()
132+
133+ let byteRes = byte res
134+
135+ if byteRes = 0 uy then
136+ None
137+ else
138+ Some byteRes @>
139+
140140 let boolMulOption =
141141 <@ fun ( x : bool option ) ( y : bool option ) ->
142142 let mutable res = false
@@ -154,7 +154,6 @@ module ArithmeticOperations =
154154 mkUnaryOp zero <@ fun x -> x * constant @>
155155
156156 let intMulOption = mkNumericMul 0
157- // let byteMulOption = mkNumericMul 0uy
158157 let floatMulOption = mkNumericMul 0.0
159158 let float32MulOption = mkNumericMul 0 f
160159
0 commit comments