Skip to content

Commit 2bac7e5

Browse files
committed
Add Mask2D implementation as index list
1 parent 7bb3c88 commit 2bac7e5

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/GraphBLAS-sharp/MatrixAndVector.fs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ and [<AbstractClass>] Vector<'a>() =
5959
static member inline (.+) (x: Vector<'a>, y: Vector<'a>) = x.EWiseAddInplace y
6060
static member inline (.*) (x: Vector<'a>, y: Vector<'a>) = x.EWiseMultInplace y
6161

62-
// двойственная к вектору структура, пока это не явно, но должно легуо приводиться друг в друга
63-
// вместо множества сожно использовать упорядоченную очередь
64-
// можно сдлеать это DU с 1 элементом
6562
and Mask1D(size: int, indexList: int list) =
6663

6764
member this.Item
@@ -77,4 +74,18 @@ and Mask1D(size: int, indexList: int list) =
7774

7875
static member (~~) (mask: Mask1D) = mask.GetComplement()
7976

80-
and Mask2D() = class end
77+
and Mask2D(size: int, indexList: (int * int) list) =
78+
79+
member this.Item
80+
with get (idx: int) = indexList.[idx]
81+
82+
member this.GetComplement() =
83+
let indices = Set.ofList indexList
84+
let allIndices = List.init size (fun i -> (i, i)) |> Set.ofList
85+
let complementIndices = Set.difference allIndices indices |> Set.toList
86+
Mask2D(size, complementIndices)
87+
88+
member this.GetEnumerator() = (indexList |> List.toSeq).GetEnumerator()
89+
90+
static member (~~) (mask: Mask2D) = mask.GetComplement()
91+

0 commit comments

Comments
 (0)