@@ -287,10 +287,10 @@ Pairs must not be duplicated.
287287
288288Coordinate format is an alias for [[#coor_format]] format.
289289
290- ### Version 2.0 only: Custom Formats ### {#custom_formats}
290+ ### Custom Formats ### {#custom_formats}
291291
292- The contents of this section will be finalized with the release of Binsparse
293- V2.0, and are subject to change until then .
292+ The contents of this section are optional for all parsers, but enable
293+ customizable sparse formats for matrices and tensors .
294294
295295Binsparse describes custom multidimensional formats hierarchically. We can
296296understand these formats as arrays of arrays, where the parent array and
@@ -318,7 +318,7 @@ and tensors. For example, a dense vector of sparse vectors is equivalent to the
318318CSR matrix format, and a sparse vector of sparse vectors is equivalent to the
319319hypersparse DCSR matrix format.
320320
321- When defining a custom format, the outermost `subformat ` key is defined as the
321+ When defining a custom format, the outermost `level ` key is defined as the
322322root level descriptor (a level which will only hold one array). If a level holds
323323many different arrays, we refer to the `p`th array as the array in position `p`.
324324
@@ -329,24 +329,25 @@ to represent is `A` and the tensor described by the format descriptor is `B`,
329329then `A[i_1, ..., i_n] = B[i_(transpose[1] ), ..., i_(transpose[n] )]`. `transpose` must
330330be a permutation.
331331
332- If the format key is a dictionary, the `level` key must be present and shall
333- describe the storage format of the level used to represent the sparse array.
332+ If the `custom` key is present, it holds a dictionary for custom formats. The
333+ root level is stored under the `level` key. Each level mush have a `level_desc`
334+ attribute which describe the storage format of the level.
334335
335336The level descriptors are dictionaries defined as follows:
336337
337338#### Element #### {#element_level}
338339
339- If the level key is "element", the level represents zero or more scalars.
340+ If the level descriptor is "element", the level represents zero or more scalars.
340341
341342: values
342343:: Array of size `number_of_positions` whose `p`th element holds the value of the scalar at position `p`.
343344
344345#### Dense #### {#dense_level}
345346
346- If the level key is "dense", the `subformat ` key must be present. The `rank`
347+ If the level descriptor is "dense", the `level ` key must be present. The `rank`
347348key must be present, and set to an integer `r` greater than or equal to 1. The
348349dense level represents zero or more r-dimensional dense arrays whose elements
349- are themselves arrays specified by `subformat `. For example, a dense level
350+ are themselves arrays specified by `level `. For example, a dense level
350351of
351352rank 2 represents a collection of dense matrices of subarrays.
352353
@@ -363,10 +364,10 @@ of the sublevel.
363364
364365#### Sparse #### {#sparse_level}
365366
366- If the level key is "sparse", the `subformat ` key must be present. The
367+ If the level descriptor is "sparse", the `level ` key must be present. The
367368`rank` key must be present, and set to an integer `r` greater than or equal to
368369`1`. The sparse level represents zero or more `r`-dimensional sparse arrays
369- whose non-implicit elements are themselves arrays specified by `subformat `. For
370+ whose non-implicit elements are themselves arrays specified by `level `. For
370371example, a sparse level of rank 1 represents a collection of sparse vectors of
371372subarrays.
372373
@@ -387,17 +388,17 @@ length of any of the `indices` arrays in this level.
387388
388389### Equivalent Formats ### {#equivalent_formats}
389390
390- The following formats are equivalent
391+ The following formats are equivalent. Parsers which support custom formats should also write `format` aliases when appropriate.
391392
392393#### DVEC #### {#dvec_format_equiv}
393394
394395```json
395- "format ": {
396- "subformat ": {
397- "level ": "dense",
396+ "custom ": {
397+ "level ": {
398+ "level_desc ": "dense",
398399 "rank": 1,
399- "subformat ": {
400- "level ": "element",
400+ "level ": {
401+ "level_desc ": "element",
401402 }
402403 }
403404}
@@ -406,15 +407,15 @@ The following formats are equivalent
406407#### DMATR #### {#dmatr_format_equiv}
407408
408409```json
409- "format ": {
410- "subformat ": {
411- "level ": "dense",
410+ "custom ": {
411+ "level ": {
412+ "level_desc ": "dense",
412413 "rank": 1,
413- "subformat ": {
414- "level ": "dense",
414+ "level ": {
415+ "level_desc ": "dense",
415416 "rank": 1,
416- "subformat ": {
417- "level ": "element",
417+ "level ": {
418+ "level_desc ": "element",
418419 }
419420 }
420421 }
@@ -424,16 +425,16 @@ The following formats are equivalent
424425#### DMATC #### {#dmatr_format_equiv}
425426
426427```json
427- "format ": {
428+ "custom ": {
428429 "transpose": [1, 0] ,
429- "subformat ": {
430- "level ": "dense",
430+ "level ": {
431+ "level_desc ": "dense",
431432 "rank": 1,
432- "subformat ": {
433- "level ": "dense",
433+ "level ": {
434+ "level_desc ": "dense",
434435 "rank": 1,
435- "subformat ": {
436- "level ": "element",
436+ "level ": {
437+ "level_desc ": "element",
437438 }
438439 }
439440 }
@@ -443,12 +444,12 @@ The following formats are equivalent
443444#### CVEC #### {#cvec_format_equiv}
444445
445446```json
446- "format ": {
447- "subformat ": {
448- "level ": "sparse",
447+ "custom ": {
448+ "level ": {
449+ "level_desc ": "sparse",
449450 "rank": 1,
450- "subformat ": {
451- "level ": "element",
451+ "level ": {
452+ "level_desc ": "element",
452453 }
453454 }
454455}
@@ -457,15 +458,15 @@ The following formats are equivalent
457458#### CSR #### {#csr_format_equiv}
458459
459460```json
460- "format ": {
461- "subformat ": {
462- "level ": "dense",
461+ "custom ": {
462+ "level ": {
463+ "level_desc ": "dense",
463464 "rank": 1,
464- "subformat ": {
465- "level ": "sparse",
465+ "level ": {
466+ "level_desc ": "sparse",
466467 "rank": 1,
467- "subformat ": {
468- "level ": "element",
468+ "level ": {
469+ "level_desc ": "element",
469470 }
470471 }
471472 }
@@ -475,16 +476,16 @@ The following formats are equivalent
475476#### CSC #### {#csc_format_equiv}
476477
477478```json
478- "format ": {
479+ "custom ": {
479480 "transpose": [1, 0] ,
480- "subformat ": {
481- "level ": "dense",
481+ "level ": {
482+ "level_desc ": "dense",
482483 "rank": 1,
483- "subformat ": {
484- "level ": "sparse",
484+ "level ": {
485+ "level_desc ": "sparse",
485486 "rank": 1,
486- "subformat ": {
487- "level ": "element",
487+ "level ": {
488+ "level_desc ": "element",
488489 }
489490 }
490491 }
@@ -494,15 +495,15 @@ The following formats are equivalent
494495#### DCSR #### {#dcsr_format_equiv}
495496
496497```json
497- "format ": {
498- "subformat ": {
499- "level ": "sparse",
498+ "custom ": {
499+ "level ": {
500+ "level_desc ": "sparse",
500501 "rank": 1,
501- "subformat ": {
502- "level ": "sparse",
502+ "level ": {
503+ "level_desc ": "sparse",
503504 "rank": 1,
504- "subformat ": {
505- "level ": "element",
505+ "level ": {
506+ "level_desc ": "element",
506507 }
507508 }
508509 }
@@ -512,16 +513,16 @@ The following formats are equivalent
512513#### DCSC #### {#dcsc_format_equiv}
513514
514515```json
515- "format ": {
516+ "custom ": {
516517 "transpose": [1, 0] ,
517- "subformat ": {
518- "level ": "sparse",
518+ "level ": {
519+ "level_desc ": "sparse",
519520 "rank": 1,
520- "subformat ": {
521- "level ": "sparse",
521+ "level ": {
522+ "level_desc ": "sparse",
522523 "rank": 1,
523- "subformat ": {
524- "level ": "element",
524+ "level ": {
525+ "level_desc ": "element",
525526 }
526527 }
527528 }
@@ -531,12 +532,12 @@ The following formats are equivalent
531532#### COOR #### {#coor_format_equiv}
532533
533534```json
534- "format ": {
535- "subformat ": {
536- "level ": "sparse",
535+ "custom ": {
536+ "level ": {
537+ "level_desc ": "sparse",
537538 "rank": 2,
538- "subformat ": {
539- "level ": "element",
539+ "level ": {
540+ "level_desc ": "element",
540541 }
541542 }
542543}
@@ -547,13 +548,13 @@ The following formats are equivalent
547548Column-wise Coordinate format
548549
549550```json
550- "format ": {
551+ "custom ": {
551552 "transpose": [1, 0] ,
552- "subformat ": {
553- "level ": "sparse",
553+ "level ": {
554+ "level_desc ": "sparse",
554555 "rank": 2,
555- "subformat ": {
556- "level ": "element",
556+ "level ": {
557+ "level_desc ": "element",
557558 }
558559 }
559560}
0 commit comments