File: GxB_colIterator.c

package info (click to toggle)
suitesparse 1%3A7.11.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 258,172 kB
  • sloc: ansic: 1,153,566; cpp: 48,145; makefile: 4,997; fortran: 2,087; java: 1,826; sh: 1,113; ruby: 725; python: 676; asm: 371; sed: 166; awk: 44
file content (87 lines) | stat: -rw-r--r-- 2,585 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//------------------------------------------------------------------------------
// GxB_colIterator_*: iterate over columns of a matrix
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

#include "GB.h"

#undef GxB_colIterator_attach
#undef GxB_colIterator_kount
#undef GxB_colIterator_seekCol
#undef GxB_colIterator_kseek
#undef GxB_colIterator_nextCol
#undef GxB_colIterator_nextRow
#undef GxB_colIterator_getColIndex
#undef GxB_colIterator_getRowIndex

#if !defined ( GBMATLAB )

//------------------------------------------------------------------------------

// The column iterator is analoguous to the row iterator.

// These methods are not tested by the GraphBLAS/Test or GraphBLAS/Tcov
// test coverage suite, because the conflict with libmwgraphblas.so inside
// MATLAB.

GrB_Info GxB_colIterator_attach
(
    GxB_Iterator iterator,
    GrB_Matrix A,
    GrB_Descriptor desc
)
{
    // attach a column iterator to a matrix
    return (GB(Iterator_attach)(iterator, A, GxB_BY_COL, desc)) ;
}

uint64_t GxB_colIterator_kount (GxB_Iterator iterator)
{
    // return # of nonempty columns of the matrix
    return (iterator->anvec) ;
}

GrB_Info GxB_colIterator_seekCol (GxB_Iterator iterator, uint64_t col)
{
    // move a column iterator that is already attached to A, to the first
    // entry of A(:,col)
    return (GB(Iterator_rc_seek)(iterator, col, false)) ;
}

GrB_Info GxB_colIterator_kseek (GxB_Iterator iterator, uint64_t k)
{
    // move a column iterator that is already attached to A, to the first
    // entry of the kth non-empty column of A
    return (GB(Iterator_rc_seek)(iterator, k, true)) ;
}

GrB_Info GxB_colIterator_nextCol (GxB_Iterator iterator)
{
    // move a column iterator to the first entry of the next column
    return (GB_Iterator_rc_knext (iterator)) ;
}

GrB_Info GxB_colIterator_nextRow (GxB_Iterator iterator)
{
    // move a column iterator to the next row in the same column
    return (GB_Iterator_rc_inext (iterator)) ;
}

uint64_t GxB_colIterator_getColIndex (GxB_Iterator iterator)
{
    // return the column index of the current entry for a column iterator
    return (GB_Iterator_rc_getj (iterator)) ;
}

uint64_t GxB_colIterator_getRowIndex (GxB_Iterator iterator)
{
    // return the row index of the current entry for a column iterator
    return (GB_Iterator_rc_geti (iterator)) ;
}

#endif