Conversation
Implement: - Vector.filter / Matrix.filter - Vector.exists / Vector.forall (short-circuit || / &&) - Matrix.exists / Matrix.forall (short-circuit || / &&) Tests (64 total): - Vector.filter: 9 - Vector.exists: 12 - Vector.forall: 12 - Matrix.filter: 9 - Matrix.exists: 11 - Matrix.forall: 11 Benchmarks: - Filters.fs: Vector/Matrix filter (dense + sparse), N=64,256,4096 - Exists.fs: Vector/Matrix exists (dense + sparse), N=64,256,4096 - Forall.fs: Vector/Matrix forall (dense + sparse), N=64,256,4096 - Register in BenchmarkSwitcher and .fsproj
|
Правда ли, что то, что Вы сделали, не выражается через map тривиальным образом, |
filter выразить можно, но это было одной из моих задач в проекте |
… test suite (188 tests)
| ) | ||
| | Error e -> failwithf "unexpected error %A" e | ||
|
|
||
| [<Fact>] |
There was a problem hiding this comment.
А чего ни одного Property-based теста?
| Assert.Equal(Ok(Some 11), get result 0UL<rowindex> 0UL<colindex>) | ||
| Assert.Equal(Ok(Some 121), get result 1UL<rowindex> 1UL<colindex>) | ||
|
|
||
| [<Fact>] |
| (Leaf(UserValue(res)), nnz) |> Ok | ||
| let get (matrix: SparseMatrix<'a>) (row: uint64<rowindex>) (col: uint64<colindex>) : Result<option<'a>, Error> = | ||
| if uint64 row >= uint64 matrix.nrows || uint64 col >= uint64 matrix.ncols then | ||
| Error Error.InvalidElementIndex |
There was a problem hiding this comment.
Посмотрите, как обычно называется такая ситуация в .NET
| | LeftValuesOnlyIndexed of (uint64<rowindex> -> uint64<colindex> -> 'a -> Option<'b> -> Option<'c>) | ||
|
|
||
| let private applyBinary | ||
| (op: BinaryOp<'a, 'b, 'c>) |
There was a problem hiding this comment.
А нельзя ли всё это дело как-то не копировать?
…ds access, deduplicate applyBinary
…COO to COOArray - COOArray: walk the sorted array with a cursor in full-cell cooMap/cooMapi paths and buffer results in ResizeArray instead of building a lookup Map; rewrite mergeBinary as a two-pointer merge over sorted arrays - COOArray/COOList: strengthen mxmcoo optimization detection by probing all distinct values rather than only the first entry - COOList: replace Map-based lookup in full-cell cooMap/cooMap2 with a pointer walk over the sorted list - Tests: add FsCheck property tests for mxmcoo against a naive reference and cross-checks between the array and list implementations - Benchmark: add list-backed get/set cases (COOLIST_get/set, resultListVal) to Format, DenseFormat and RealMatrix benchmarks - Rename module COO to COOArray for consistency with COOList: file rename, fsproj entries, open statements, test module, and Fantomas formatting
Implement:
Tests (64 total):
Benchmarks: