Skip to content

Commit ecacd8b

Browse files
added (Hyper,Hyper,Index) example
1 parent 3c63e9d commit ecacd8b

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

include/binsparse/c_bindings/binsparse_matrix.h

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,18 @@ bc_type_code ;
426426
in the axis0 dimension. Each object is a pointer of size 10
427427
plus one end marker.
428428
429-
pointer(1) = [ 0 1 1 1 4 4 4 5 5 5 5 5 5 5 7 7 7 12 12 12 12 14 15 15 15 15 15 15 15 15 ]
429+
pointer(1) = [ 0 0 1 1 4 4 4 5 5 5
430+
5 5 5 5 7 7 7 11 11 12
431+
12 12 14 15 15 15 15 15 15 15 15 ]
430432
431433
0 1 2 3 4 5 6 7 8 9 -
432434
. . . . . . . . . . 0 <= pointer for this 2D slice
433-
. . x . . . . . . . 1
435+
. . x . . . . . . . 0 (row 1)
434436
. . . . . . . . . . 1
435-
. . . x x . x . . . 1
437+
. . . x x . x . . . 1 (row 3)
436438
. . . . . . . . . . 4
437439
. . . . . . . . . . 4
438-
. . . . . . x . . . 4
440+
. . . . . . x . . . 4 (row 5): for (Hyper,Hyper,Index) below
439441
. . . . . . . . . . 5
440442
. . . . . . . . . . 5
441443
. . . . . . . . . . 5
@@ -444,18 +446,18 @@ bc_type_code ;
444446
. . . . . . . . . . 5
445447
. . . . . . . . . . 5
446448
. . . . . . . . . . 5
447-
. x . . . . . . x . 5
449+
. x . . . . . . x . 5 (row 3)
448450
. . . . . . . . . . 7
449451
. . . . . . . . . . 7
450-
. . . . . x x x x . 7
452+
. . . . . x x x x . 7 (row 6)
451453
. . . . . . . . . . 11
452-
. x . . . . . . . . 12
454+
. x . . . . . . . . 11 (row 8)
453455
. . . . . . . . . . 12
454456
455457
0 1 2 3 4 5 6 7 8 9 -
456458
. . . . . . . . . . 12
457-
x . . x . . . . . . 12
458-
. . . . . x . . . . 14
459+
x . . x . . . . . . 12 (row 2)
460+
. . . . . x . . . . 14 (row 3)
459461
. . . . . . . . . . 15
460462
. . . . . . . . . . 15
461463
. . . . . . . . . . 15
@@ -478,6 +480,32 @@ bc_type_code ;
478480
same as above, but drop pointer(0) as not needed. So
479481
this is better than (Hyper, Sparse, Index).
480482
483+
(Hyper, Hyper, Index): this is useful
484+
with the same 10-by-10-by-10 matrix above.
485+
486+
axis0: index(0) = [0 2 5], size 3
487+
pointer(0) = cumulative sum of (3, 3, 2) = [0 3 6 8], size 3+1
488+
since there are 3 non-empty rows in A(0,:,:),
489+
3 in A (2,:,:), and two in A(5,:,:),
490+
491+
The pointer(0) value tells us where each matrix starts
492+
in axis1.
493+
494+
axis1: index(1) = [ 1 3 5 3 6 8 2 3]
495+
since A(0,:,:) has nonempty rows 1,3,5
496+
A(2,:,:) has nonempty rows: 3,6,8
497+
A(5,:,:) has nonempty rows: 2,3
498+
pointer(1) = [
499+
500+
pointer(1) = [ 0 1 4 size 3, end marker is next matrx
501+
5 7 11 size 3, end marker is next matrx
502+
12 14 15 ] size 2 plus the end marker
503+
504+
axis2: same as (Index, Sparse, Index) case above.
505+
506+
(Index, Hyper, Index): invalid since the first axis0 has no way
507+
to refer to variable-sized parts in axis1.
508+
481509
Consider duplicates:
482510
483511
10-by-10-by-10
@@ -566,7 +594,7 @@ meant to be summed, in any axis.
566594
567595
*/
568596

569-
// rank = 3
597+
// rank = 3, a tensor of dimension M-by-N-by-K.
570598
//
571599
// possible formats:
572600

@@ -578,7 +606,10 @@ meant to be summed, in any axis.
578606

579607
// (Sparse, Index , Index) 1D dense array of 2D COO matrices
580608
// (Sparse, Hyper , Index) 1D dense array of 2D hypersparse
581-
// (Sparse, Sparse, Index) 1D dense array of 2D CSR/CSR matrices
609+
// (Sparse, Sparse, Index) 1D dense array of 2D CSR/CSR matrices,
610+
// but note that the axis0 has a very simple
611+
// pointer(0) = [0 N 2*N ... M*N M*N+1] of size M+1.
612+
// if the matrix is M-by-N-by-K.
582613

583614
// (Index , Index , Full ) like 2D COO, but each "entry" is an entire
584615
// dense vector

0 commit comments

Comments
 (0)