@@ -3,24 +3,32 @@ namespace GraphBLAS.FSharp
33open Brahma.FSharp .OpenCL .WorkflowBuilder .Evaluation
44open Brahma.FSharp .OpenCL .WorkflowBuilder .Basic
55
6- type MatrixTuples < 'a when 'a : struct and 'a : equality > = {
7- RowIndices: int []
8- ColumnIndices: int []
9- Values: 'a []
10- }
11- with
12- member this.ToHost () = opencl {
13- let! rows = ToHost this.RowIndices
14- let! cols = ToHost this.ColumnIndices
15- let! vals = ToHost this.Values
16-
17- return {
18- RowIndices = rows
19- ColumnIndices = cols
20- Values = vals
21- }
6+ // algebraic objects
7+
8+ type MatrixTuples < 'a when 'a : struct and 'a : equality > =
9+ {
10+ RowIndices: int []
11+ ColumnIndices: int []
12+ Values: 'a []
2213 }
2314
15+ member this.ToHost () =
16+ opencl {
17+ let! rows = ToHost this.RowIndices
18+ let! cols = ToHost this.ColumnIndices
19+ let! vals = ToHost this.Values
20+
21+ return {
22+ RowIndices = rows
23+ ColumnIndices = cols
24+ Values = vals
25+ }
26+ }
27+
28+ type Scalar < 'a when 'a : struct and 'a : equality > = Scalar of 'a
29+ with
30+ static member op_Implicit ( Scalar source ) = source
31+
2432[<AbstractClass>]
2533type Matrix < 'a when 'a : struct and 'a : equality >( nrow : int , ncol : int ) =
2634 abstract RowCount: int
@@ -48,17 +56,17 @@ type Matrix<'a when 'a : struct and 'a : equality>(nrow: int, ncol: int) =
4856 abstract Assign: ( Mask1D option * int ) * Scalar < 'a > -> OpenCLEvaluation < unit >
4957 abstract Assign: ( int * Mask1D option ) * Scalar < 'a > -> OpenCLEvaluation < unit >
5058
51- abstract Mxm: Matrix < 'a > -> Mask2D option -> Semiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
52- abstract Mxv: Vector < 'a > -> Mask1D option -> Semiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
53- abstract EWiseAdd: Matrix < 'a > -> Mask2D option -> Semiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
54- abstract EWiseMult: Matrix < 'a > -> Mask2D option -> Semiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
59+ abstract Mxm: Matrix < 'a > -> Mask2D option -> ISemiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
60+ abstract Mxv: Vector < 'a > -> Mask1D option -> ISemiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
61+ abstract EWiseAdd: Matrix < 'a > -> Mask2D option -> ISemiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
62+ abstract EWiseMult: Matrix < 'a > -> Mask2D option -> ISemiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
5563 abstract Apply: Mask2D option -> UnaryOp < 'a , 'b > -> OpenCLEvaluation < Matrix < 'b >>
5664 abstract Prune: Mask2D option -> UnaryOp < 'a , bool > -> OpenCLEvaluation < Matrix < 'a >>
57- abstract ReduceIn: Mask1D option -> Monoid < 'a > -> OpenCLEvaluation < Vector < 'a >>
58- abstract ReduceOut: Mask1D option -> Monoid < 'a > -> OpenCLEvaluation < Vector < 'a >>
59- abstract Reduce: Monoid < 'a > -> OpenCLEvaluation < Scalar < 'a >>
65+ abstract ReduceIn: Mask1D option -> IMonoid < 'a > -> OpenCLEvaluation < Vector < 'a >>
66+ abstract ReduceOut: Mask1D option -> IMonoid < 'a > -> OpenCLEvaluation < Vector < 'a >>
67+ abstract Reduce: IMonoid < 'a > -> OpenCLEvaluation < Scalar < 'a >>
6068 abstract Transpose: unit -> OpenCLEvaluation < Matrix < 'a >>
61- abstract Kronecker: Matrix < 'a > -> Mask2D option -> Semiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
69+ abstract Kronecker: Matrix < 'a > -> Mask2D option -> ISemiring < 'a > -> OpenCLEvaluation < Matrix < 'a >>
6270
6371and [<AbstractClass>] Vector < 'a when 'a : struct and 'a : equality >( size : int ) =
6472 abstract Size: int
@@ -78,12 +86,12 @@ and [<AbstractClass>] Vector<'a when 'a : struct and 'a : equality>(size: int) =
7886 abstract Assign: int * Scalar < 'a > -> OpenCLEvaluation < unit >
7987 abstract Assign: Mask1D option * Scalar < 'a > -> OpenCLEvaluation < unit >
8088
81- abstract Vxm: Matrix < 'a > -> Mask1D option -> Semiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
82- abstract EWiseAdd: Vector < 'a > -> Mask1D option -> Semiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
83- abstract EWiseMult: Vector < 'a > -> Mask1D option -> Semiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
89+ abstract Vxm: Matrix < 'a > -> Mask1D option -> ISemiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
90+ abstract EWiseAdd: Vector < 'a > -> Mask1D option -> ISemiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
91+ abstract EWiseMult: Vector < 'a > -> Mask1D option -> ISemiring < 'a > -> OpenCLEvaluation < Vector < 'a >>
8492 abstract Apply: Mask1D option -> UnaryOp < 'a , 'b > -> OpenCLEvaluation < Vector < 'b >>
8593 abstract Prune: Mask1D option -> UnaryOp < 'a , bool > -> OpenCLEvaluation < Vector < 'a >>
86- abstract Reduce: Monoid < 'a > -> OpenCLEvaluation < Scalar < 'a >>
94+ abstract Reduce: IMonoid < 'a > -> OpenCLEvaluation < Scalar < 'a >>
8795
8896and Mask1D ( indices : int [], size : int , isComplemented : bool ) =
8997 member this.Indices = indices
@@ -97,21 +105,23 @@ and Mask2D(rowIndices: int[], columnIndices: int[], rowCount: int, columnCount:
97105 member this.ColumnCount = columnCount
98106 member this.IsComplemented = isComplemented
99107
100- type COOFormat < 'a > = {
101- RowCount: int
102- ColumnCount: int
103- Rows: int []
104- Columns: int []
105- Values: 'a []
106- }
107-
108- type CSRFormat < 'a > = {
109- ColumnCount: int
110- RowPointers: int []
111- ColumnIndices: int []
112- Values: 'a []
113- }
114- with
108+ type COOFormat < 'a > =
109+ {
110+ RowCount: int
111+ ColumnCount: int
112+ Rows: int []
113+ Columns: int []
114+ Values: 'a []
115+ }
116+
117+ type CSRFormat < 'a > =
118+ {
119+ ColumnCount: int
120+ RowPointers: int []
121+ ColumnIndices: int []
122+ Values: 'a []
123+ }
124+
115125 static member CreateEmpty < 'a >() = {
116126 RowPointers = Array.zeroCreate< int> 0
117127 ColumnIndices = Array.zeroCreate< int> 0
0 commit comments