Skip to content

Commit 0c82ae5

Browse files
committed
More standard operations added
1 parent 15de543 commit 0c82ae5

1 file changed

Lines changed: 96 additions & 16 deletions

File tree

src/GraphBLAS-sharp.Backend/Common/StandardOperations.fs

Lines changed: 96 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module StandardOperations =
2121
| None, Some s -> res <- s
2222
| None, None -> ()
2323

24-
if res = 0 then None else (Some res) @>
24+
if res = 0 then None else Some res @>
2525

2626
let byteSum =
2727
<@ fun (x: byte option) (y: byte option) ->
@@ -33,7 +33,7 @@ module StandardOperations =
3333
| None, Some s -> res <- s
3434
| None, None -> ()
3535

36-
if res = 0uy then None else (Some res) @>
36+
if res = 0uy then None else Some res @>
3737

3838
let floatSum =
3939
<@ fun (x: float option) (y: float option) ->
@@ -45,7 +45,7 @@ module StandardOperations =
4545
| None, Some s -> res <- s
4646
| None, None -> ()
4747

48-
if res = 0 then None else (Some res) @>
48+
if res = 0 then None else Some res @>
4949

5050
let float32Sum =
5151
<@ fun (x: float32 option) (y: float32 option) ->
@@ -57,7 +57,7 @@ module StandardOperations =
5757
| None, Some s -> res <- s
5858
| None, None -> ()
5959

60-
if res = 0f then None else (Some res) @>
60+
if res = 0f then None else Some res @>
6161

6262
let boolSumAtLeastOne =
6363
<@ fun (_: AtLeastOne<bool, bool>) -> Some true @>
@@ -71,7 +71,7 @@ module StandardOperations =
7171
| Left f -> res <- f
7272
| Right s -> res <- s
7373

74-
if res = 0 then None else (Some res) @>
74+
if res = 0 then None else Some res @>
7575

7676
let byteSumAtLeastOne =
7777
<@ fun (values: AtLeastOne<byte, byte>) ->
@@ -82,7 +82,7 @@ module StandardOperations =
8282
| Left f -> res <- f
8383
| Right s -> res <- s
8484

85-
if res = 0uy then None else (Some res) @>
85+
if res = 0uy then None else Some res @>
8686

8787
let floatSumAtLeastOne =
8888
<@ fun (values: AtLeastOne<float, float>) ->
@@ -93,7 +93,7 @@ module StandardOperations =
9393
| Left f -> res <- f
9494
| Right s -> res <- s
9595

96-
if res = 0.0 then None else (Some res) @>
96+
if res = 0.0 then None else Some res @>
9797

9898
let float32SumAtLeastOne =
9999
<@ fun (values: AtLeastOne<float32, float32>) ->
@@ -104,24 +104,104 @@ module StandardOperations =
104104
| Left f -> res <- f
105105
| Right s -> res <- s
106106

107-
if res = 0f then None else (Some res) @>
107+
if res = 0f then None else Some res @>
108+
109+
let boolMul =
110+
<@ fun (x: bool option) (y: bool option) ->
111+
let mutable res = false
112+
113+
match x, y with
114+
| Some _, Some _ -> res <- true
115+
| _ -> ()
116+
117+
if res then Some true else None @>
118+
119+
let intMul =
120+
<@ fun (x: int option) (y: int option) ->
121+
let mutable res = 0
122+
123+
match x, y with
124+
| Some f, Some s -> res <- f * s
125+
| _ -> ()
126+
127+
if res = 0 then None else Some res @>
128+
129+
let byteMul =
130+
<@ fun (x: byte option) (y: byte option) ->
131+
let mutable res = 0uy
132+
133+
match x, y with
134+
| Some f, Some s -> res <- f * s
135+
| _ -> ()
136+
137+
if res = 0uy then None else Some res @>
138+
139+
let floatMul =
140+
<@ fun (x: float option) (y: float option) ->
141+
let mutable res = 0.0
142+
143+
match x, y with
144+
| Some f, Some s -> res <- f * s
145+
| _ -> ()
146+
147+
if res = 0 then None else Some res @>
108148

109149
let float32Mul =
110-
<@ fun (values: AtLeastOne<float32, float32>) ->
111-
let mutable res = 0f
150+
<@ fun (x: float32 option) (y: float32 option) ->
151+
let mutable res = 0.0f
112152

113-
match values with
114-
| Both (f, s) -> res <- f * s
115-
| _ -> res <- 0f
153+
match x, y with
154+
| Some f, Some s -> res <- f * s
155+
| _ -> ()
116156

117-
if res = 0f then None else (Some res) @>
157+
if res = 0f then None else Some res @>
118158

119-
let boolMul =
159+
let boolMulAtLeastOne =
120160
<@ fun (values: AtLeastOne<bool, bool>) ->
121161
let mutable res = false
122162

123163
match values with
124164
| Both _ -> res <- true
125-
| _ -> res <- false
165+
| _ -> ()
126166

127167
if res then None else (Some true) @>
168+
169+
let intMulAtLeastOne =
170+
<@ fun (values: AtLeastOne<int, int>) ->
171+
let mutable res = 0
172+
173+
match values with
174+
| Both (f, s) -> res <- f * s
175+
| _ -> ()
176+
177+
if res = 0 then None else Some res @>
178+
179+
let byteMulAtLeastOne =
180+
<@ fun (values: AtLeastOne<byte, byte>) ->
181+
let mutable res = 0uy
182+
183+
match values with
184+
| Both (f, s) -> res <- f * s
185+
| _ -> ()
186+
187+
if res = 0uy then None else Some res @>
188+
189+
let floatMulAtLeastOne =
190+
<@ fun (values: AtLeastOne<float, float>) ->
191+
let mutable res = 0.0
192+
193+
match values with
194+
| Both (f, s) -> res <- f * s
195+
| _ -> ()
196+
197+
if res = 0.0 then None else Some res @>
198+
199+
let float32MulAtLeastOne =
200+
<@ fun (values: AtLeastOne<float32, float32>) ->
201+
let mutable res = 0f
202+
203+
match values with
204+
| Both (f, s) -> res <- f * s
205+
| _ -> ()
206+
207+
if res = 0f then None else Some res @>

0 commit comments

Comments
 (0)