Skip to content

Commit 7bb3c88

Browse files
committed
Add Mask1D test impl, remove tests
1 parent e53a0a9 commit 7bb3c88

7 files changed

Lines changed: 193 additions & 355 deletions

File tree

src/GraphBLAS-sharp/CSRMatrix.fs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type CSRMatrix<'a>(csrTuples: CSRFormat<'a>) =
3434
"vector"
3535
(sprintf "Argument has invalid dimension. Need %i, but given %i" csrMatrixColumnCount vectorLength)
3636

37+
// let (BinaryOp op) = context.Times
3738
let plus = !> context.PlusMonoid.Append
3839
let mult = !> context.Times
3940

@@ -78,36 +79,36 @@ type CSRMatrix<'a>(csrTuples: CSRFormat<'a>) =
7879

7980
override this.RowCount = rowCount
8081
override this.ColumnCount = columnCount
82+
override this.Mask = failwith "Not Implemented"
8183

8284
override this.Item
83-
with get (mask: Mask2D option) : Matrix<'a> = upcast CSRMatrix<'a>()
84-
and set (mask: Mask2D option) (value: Matrix<'a>) = ()
85+
with get (mask: Mask2D option) : Matrix<'a> = failwith "Not Implemented"
86+
and set (mask: Mask2D option) (value: Matrix<'a>) = failwith "Not Implemented"
8587
override this.Item
86-
with get (vectorMask: Mask1D option, colIdx: int) : Vector<'a> = upcast DenseVector<'a>()
87-
and set (vectorMask: Mask1D option, colIdx: int) (value: Vector<'a>) = ()
88+
with get (vectorMask: Mask1D option, colIdx: int) : Vector<'a> = failwith "Not Implemented"
89+
and set (vectorMask: Mask1D option, colIdx: int) (value: Vector<'a>) = failwith "Not Implemented"
8890
override this.Item
89-
with get (rowIdx: int, vectorMask: Mask1D option) : Vector<'a> = upcast DenseVector<'a>()
90-
and set (rowIdx: int, vectorMask: Mask1D option) (value: Vector<'a>) = ()
91+
with get (rowIdx: int, vectorMask: Mask1D option) : Vector<'a> = failwith "Not Implemented"
92+
and set (rowIdx: int, vectorMask: Mask1D option) (value: Vector<'a>) = failwith "Not Implemented"
9193
override this.Item
92-
with get (rowIdx: int, colIdx: int) : Scalar<'a> = Scalar Unchecked.defaultof<'a>
93-
and set (rowIdx: int, colIdx: int) (value: Scalar<'a>) = ()
94-
94+
with get (rowIdx: int, colIdx: int) : Scalar<'a> = failwith "Not Implemented"
95+
and set (rowIdx: int, colIdx: int) (value: Scalar<'a>) = failwith "Not Implemented"
9596
override this.Item
96-
with set (mask: Mask2D option) (value: Scalar<'a>) = ()
97+
with set (mask: Mask2D option) (value: Scalar<'a>) = failwith "Not Implemented"
9798
override this.Item
98-
with set (vectorMask: Mask1D option, colIdx: int) (value: Scalar<'a>) = ()
99+
with set (vectorMask: Mask1D option, colIdx: int) (value: Scalar<'a>) = failwith "Not Implemented"
99100
override this.Item
100-
with set (rowIdx: int, vectorMask: Mask1D option) (value: Scalar<'a>) = ()
101-
102-
override this.Mxm a b c = upcast CSRMatrix<'a>()
103-
override this.Mxv a b c = upcast DenseVector<'a>()
104-
override this.EWiseAdd a b c = upcast CSRMatrix<'a>()
105-
override this.EWiseMult a b c = upcast CSRMatrix<'a>()
106-
override this.Apply<'b> a b = upcast CSRMatrix<'b>()
107-
override this.ReduceIn a b = upcast DenseVector<'a>()
108-
override this.ReduceOut a b = upcast DenseVector<'a>()
109-
override this.T = upcast CSRMatrix<'a>()
110-
111-
override this.EWiseAddInplace a b c = ()
112-
override this.EWiseMultInplace a b c = ()
113-
override this.ApplyInplace a b = ()
101+
with set (rowIdx: int, vectorMask: Mask1D option) (value: Scalar<'a>) = failwith "Not Implemented"
102+
103+
override this.Mxm a b c = failwith "Not Implemented"
104+
override this.Mxv a b c = failwith "Not Implemented"
105+
override this.EWiseAdd a b c = failwith "Not Implemented"
106+
override this.EWiseMult a b c = failwith "Not Implemented"
107+
override this.Apply a b = failwith "Not Implemented"
108+
override this.ReduceIn a b = failwith "Not Implemented"
109+
override this.ReduceOut a b = failwith "Not Implemented"
110+
override this.T = failwith "Not Implemented"
111+
112+
override this.EWiseAddInplace a b c = failwith "Not Implemented"
113+
override this.EWiseMultInplace a b c = failwith "Not Implemented"
114+
override this.ApplyInplace a b = failwith "Not Implemented"

src/GraphBLAS-sharp/DenseVector.fs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ type DenseVector<'a>(vector: 'a[]) =
44
inherit Vector<'a>()
55

66
new() = DenseVector(Array.zeroCreate<'a> 0)
7+
new(listOfIndices: int list) = DenseVector(Array.zeroCreate<'a> 0)
78

8-
override this.Length = Array.length vector
9-
override this.AsArray = vector
10-
override this.Indices = []
9+
override this.Length = failwith "Not Implemented"
10+
override this.Mask = failwith "Not Implemented"
11+
override this.AsArray = failwith "Not Implemented"
1112

1213
override this.Item
13-
with get (mask: Mask1D option) : Vector<'a> = upcast DenseVector<'a>()
14-
and set (mask: Mask1D option) (value: Vector<'a>) = ()
14+
with get (mask: Mask1D option) : Vector<'a> = failwith "Not Implemented"
15+
and set (mask: Mask1D option) (value: Vector<'a>) = failwith "Not Implemented"
1516
override this.Item
16-
with get (rowIdx: int, colIdx: int) : Scalar<'a> = Scalar Unchecked.defaultof<'a>
17-
and set (rowIdx: int, colIdx: int) (value: Scalar<'a>) = ()
18-
17+
with get (rowIdx: int, colIdx: int) : Scalar<'a> = failwith "Not Implemented"
18+
and set (rowIdx: int, colIdx: int) (value: Scalar<'a>) = failwith "Not Implemented"
1919
override this.Item
20-
with set (mask: Mask1D option) (value: Scalar<'a>) = ()
20+
with set (mask: Mask1D option) (value: Scalar<'a>) = failwith "Not Implemented"
2121

22-
override this.Vxm a b c = upcast DenseVector<'a>()
23-
override this.EWiseAdd a b c = upcast DenseVector<'a>()
24-
override this.EWiseMult a b c = upcast DenseVector<'a>()
25-
override this.Apply<'b> a b = upcast DenseVector<'b>()
26-
override this.Reduce a = Scalar Unchecked.defaultof<'a>
22+
override this.Vxm a b c = failwith "Not Implemented"
23+
override this.EWiseAdd a b c = failwith "Not Implemented"
24+
override this.EWiseMult a b c = failwith "Not Implemented"
25+
override this.Apply a b = failwith "Not Implemented"
26+
override this.Reduce a = failwith "Not Implemented"
2727

28-
override this.EWiseAddInplace a b c = ()
29-
override this.EWiseMultInplace a b c = ()
30-
override this.ApplyInplace a b = ()
28+
override this.EWiseAddInplace a b c = failwith "Not Implemented"
29+
override this.EWiseMultInplace a b c = failwith "Not Implemented"
30+
override this.ApplyInplace a b = failwith "Not Implemented"

src/GraphBLAS-sharp/GraphBLAS-sharp.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<Compile Include="MatrixAndVector.fs" />
1717
<Compile Include="DenseVector.fs" />
1818
<Compile Include="CSRMatrix.fs" />
19-
<Compile Include="SparseMatrixMultiplication.fs" />
2019
<Compile Include="Semirings/Boolean.fs" />
2120
<Compile Include="Semirings/Float.fs" />
2221
</ItemGroup>

src/GraphBLAS-sharp/MatrixAndVector.fs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ namespace GraphBLAS.FSharp
44
type Matrix<'a>() =
55
abstract RowCount: int
66
abstract ColumnCount: int
7+
abstract Mask: Mask2D
78

89
abstract Item: Mask2D option -> Matrix<'a> with get, set
910
abstract Item: Mask1D option * int -> Vector<'a> with get, set
1011
abstract Item: int * Mask1D option -> Vector<'a> with get, set
1112
abstract Item: int * int -> Scalar<'a> with get, set
12-
1313
abstract Item: Mask2D option -> Scalar<'a> with set
1414
abstract Item: Mask1D option * int -> Scalar<'a> with set
1515
abstract Item: int * Mask1D option -> Scalar<'a> with set
@@ -36,12 +36,11 @@ type Matrix<'a>() =
3636

3737
and [<AbstractClass>] Vector<'a>() =
3838
abstract Length: int
39+
abstract Mask: Mask1D
3940
abstract AsArray: 'a[]
40-
abstract Indices: int list
4141

4242
abstract Item: Mask1D option -> Vector<'a> with get, set
4343
abstract Item: int * int -> Scalar<'a> with get, set
44-
4544
abstract Item: Mask1D option -> Scalar<'a> with set
4645

4746
abstract Vxm: Matrix<'a> -> Mask1D option -> Semiring<'a> -> Vector<'a>
@@ -64,18 +63,18 @@ and [<AbstractClass>] Vector<'a>() =
6463
// вместо множества сожно использовать упорядоченную очередь
6564
// можно сдлеать это DU с 1 элементом
6665
and Mask1D(size: int, indexList: int list) =
67-
let indices = Set.ofList indexList
66+
67+
member this.Item
68+
with get (idx: int) = indexList.[idx]
6869

6970
member this.GetComplement() =
71+
let indices = Set.ofList indexList
7072
let allIndices = List.init size id |> Set.ofList
7173
let complementIndices = Set.difference allIndices indices |> Set.toList
7274
Mask1D(size, complementIndices)
7375

74-
member this.ToArray() =
75-
indices |> Set.toArray |> Array.sort
76+
member this.GetEnumerator() = (indexList |> List.toSeq).GetEnumerator()
7677

77-
static member OfVector (vector: Vector<'a>) = Mask1D(vector.Length, vector.Indices)
7878
static member (~~) (mask: Mask1D) = mask.GetComplement()
7979

8080
and Mask2D() = class end
81-

src/GraphBLAS-sharp/SparseMatrixMultiplication.fs

Lines changed: 0 additions & 163 deletions
This file was deleted.

tests/GraphBLAS-sharp.Tests/CSRMatrixTests.fs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,31 @@ open FsCheck
77
open FsCheck.Xunit
88
open GraphBLAS.FSharp
99

10-
[<Properties(Verbose=true, MaxTest=100, EndSize=2500)>]
10+
// [<Properties(Verbose=true, MaxTest=100, EndSize=2500)>]
1111
module CSRMatrixTests =
12+
()
1213

13-
type FloatMatrix =
14-
static member FloatSparseMatrix () =
15-
Gen.oneof [
16-
Arb.Default.NormalFloat () |> Arb.toGen |> Gen.map float
17-
Gen.constant 0.
18-
]
19-
|> Gen.array2DOf
20-
|> Arb.fromGen
14+
// type FloatMatrix =
15+
// static member FloatSparseMatrix () =
16+
// Gen.oneof [
17+
// Arb.Default.NormalFloat () |> Arb.toGen |> Gen.map float
18+
// Gen.constant 0.
19+
// ]
20+
// |> Gen.array2DOf
21+
// |> Arb.fromGen
2122

22-
[<Property(Arbitrary=[| typeof<FloatMatrix> |])>]
23-
let ``Matrix should be original after inverse fromCsr transformation`` (matrix: float[,]) =
24-
let makeDenseFromCsr (matrix: CSRMatrix<float>) =
25-
let rowCount = matrix.RowCount
26-
let columnCount = matrix.ColumnCount
27-
let bufferMatrix = Array2D.zeroCreate<float> rowCount columnCount
28-
for rowIdx in 0 .. rowCount - 1 do
29-
for i in matrix.RowPointers.[rowIdx] .. matrix.RowPointers.[rowIdx + 1] - 1 do
30-
let columnIdx = matrix.Columns.[i]
31-
let value = matrix.Values.[i]
32-
bufferMatrix.[rowIdx, columnIdx] <- value
33-
bufferMatrix
23+
// [<Property(Arbitrary=[| typeof<FloatMatrix> |])>]
24+
// let ``Matrix should be original after inverse fromCsr transformation`` (matrix: float[,]) =
25+
// let makeDenseFromCsr (matrix: CSRMatrix<float>) =
26+
// let rowCount = matrix.RowCount
27+
// let columnCount = matrix.ColumnCount
28+
// let bufferMatrix = Array2D.zeroCreate<float> rowCount columnCount
29+
// for rowIdx in 0 .. rowCount - 1 do
30+
// for i in matrix.RowPointers.[rowIdx] .. matrix.RowPointers.[rowIdx + 1] - 1 do
31+
// let columnIdx = matrix.Columns.[i]
32+
// let value = matrix.Values.[i]
33+
// bufferMatrix.[rowIdx, columnIdx] <- value
34+
// bufferMatrix
3435

35-
let result = matrix |> CSRMatrix.ofDense |> makeDenseFromCsr
36-
result = matrix |@ (sprintf "\n %A \n %A \n" result matrix)
36+
// let result = matrix |> CSRMatrix.ofDense |> makeDenseFromCsr
37+
// result = matrix |@ (sprintf "\n %A \n %A \n" result matrix)

0 commit comments

Comments
 (0)