Skip to content

Commit 6f8e0e7

Browse files
add basic documentation
1 parent 61e8bb4 commit 6f8e0e7

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

src/Object_Methods/Matrix_Methods.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
GrB_Matrix_new(A, type, nrows, ncols)
3+
4+
Create a new matrix with specified domain and dimensions.
5+
"""
16
function GrB_Matrix_new(A::GrB_Matrix, type::GrB_Type, nrows::T, ncols::T) where T <: GrB_Index
27
A_ptr = pointer_from_objref(A)
38

@@ -11,6 +16,11 @@ function GrB_Matrix_new(A::GrB_Matrix, type::GrB_Type, nrows::T, ncols::T) where
1116
)
1217
end
1318

19+
"""
20+
GrB_Matrix_build(C, I, J, X, nvals, dup)
21+
22+
Store elements from tuples into a vector.
23+
"""
1424
function GrB_Matrix_build(C::GrB_Matrix, I::Vector{U}, J::Vector{U}, X::Vector{T}, nvals::U, dup::GrB_BinaryOp) where{U <: GrB_Index, T <: valid_types}
1525
I_ptr = pointer(I)
1626
J_ptr = pointer(J)
@@ -26,6 +36,12 @@ function GrB_Matrix_build(C::GrB_Matrix, I::Vector{U}, J::Vector{U}, X::Vector{T
2636
)
2737
end
2838

39+
"""
40+
GrB_Matrix_nrows(A)
41+
42+
Return the number of rows in a matrix if successful.
43+
Else return value of type GrB Info.
44+
"""
2945
function GrB_Matrix_nrows(A::GrB_Matrix)
3046
nrows = Ref(UInt64(0))
3147
result = GrB_Info(
@@ -40,6 +56,12 @@ function GrB_Matrix_nrows(A::GrB_Matrix)
4056
return _GrB_Index(nrows[])
4157
end
4258

59+
"""
60+
GrB_Matrix_ncols(A)
61+
62+
Return the number of columns in a matrix if successful.
63+
Else return value of type GrB Info.
64+
"""
4365
function GrB_Matrix_ncols(A::GrB_Matrix)
4466
ncols = Ref(UInt64(0))
4567
result = GrB_Info(
@@ -54,6 +76,12 @@ function GrB_Matrix_ncols(A::GrB_Matrix)
5476
return _GrB_Index(ncols[])
5577
end
5678

79+
"""
80+
GrB_Matrix_nvals(A)
81+
82+
Return the number of stored elements in a matrix if successful.
83+
Else return value of type GrB Info.
84+
"""
5785
function GrB_Matrix_nvals(A::GrB_Matrix)
5886
nvals = Ref(UInt64(0))
5987
result = GrB_Info(
@@ -68,6 +96,11 @@ function GrB_Matrix_nvals(A::GrB_Matrix)
6896
return _GrB_Index(nvals[])
6997
end
7098

99+
"""
100+
GrB_Matrix_dup(C, A)
101+
102+
Create a new matrix with the same domain, dimensions, and contents as another matrix.
103+
"""
71104
function GrB_Matrix_dup(C::GrB_Matrix, A::GrB_Matrix)
72105
C_ptr = pointer_from_objref(C)
73106

@@ -81,6 +114,11 @@ function GrB_Matrix_dup(C::GrB_Matrix, A::GrB_Matrix)
81114
)
82115
end
83116

117+
"""
118+
GrB_Matrix_clear(A)
119+
120+
Remove all elements from a matrix.
121+
"""
84122
function GrB_Matrix_clear(A::GrB_Matrix)
85123
return GrB_Info(
86124
ccall(
@@ -92,6 +130,11 @@ function GrB_Matrix_clear(A::GrB_Matrix)
92130
)
93131
end
94132

133+
"""
134+
GrB_Matrix_setElement(C, X, I, J)
135+
136+
Set one element of a matrix to a given value, C[I][J] = X.
137+
"""
95138
function GrB_Matrix_setElement(C::GrB_Matrix, X::T, I::U, J::U) where {U <: GrB_Index, T <: valid_int_types}
96139
fn_name = "GrB_Matrix_setElement_" * get_suffix(T)
97140
return GrB_Info(
@@ -128,6 +171,12 @@ function GrB_Matrix_setElement(C::GrB_Matrix, X::Float64, I::U, J::U) where U <:
128171
)
129172
end
130173

174+
"""
175+
GrB_Matrix_extractElement(A, row_index, col_index)
176+
177+
Return element of a vector at a given index (A[row_index][col_index]) if successful.
178+
Else return value of type GrB Info.
179+
"""
131180
function GrB_Matrix_extractElement(A::GrB_Matrix, row_index::U, col_index::U) where U <: GrB_Index
132181
res, A_type = GxB_Matrix_type(A)
133182
res != GrB_SUCCESS && return res
@@ -147,6 +196,11 @@ function GrB_Matrix_extractElement(A::GrB_Matrix, row_index::U, col_index::U) wh
147196
return element[]
148197
end
149198

199+
"""
200+
GrB_Matrix_extractTuples(A)
201+
202+
Return tuples stored in a matrix.
203+
"""
150204
function GrB_Matrix_extractTuples(A::GrB_Matrix)
151205
res, A_type = GxB_Matrix_type(A)
152206
res != GrB_SUCCESS && return res

src/Object_Methods/Vector_Methods.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
GrB_Vector_new(v, type, n)
3+
4+
Create a new vector with specified domain and size.
5+
"""
16
function GrB_Vector_new(v::GrB_Vector, type::GrB_Type, n::T) where T <: GrB_Index
27
v_ptr = pointer_from_objref(v)
38

@@ -11,6 +16,11 @@ function GrB_Vector_new(v::GrB_Vector, type::GrB_Type, n::T) where T <: GrB_Inde
1116
)
1217
end
1318

19+
"""
20+
GrB_Vector_dup(w, u)
21+
22+
Create a new vector with the same domain, size, and contents as another vector.
23+
"""
1424
function GrB_Vector_dup(w::GrB_Vector, u::GrB_Vector)
1525
w_ptr = pointer_from_objref(w)
1626

@@ -24,6 +34,11 @@ function GrB_Vector_dup(w::GrB_Vector, u::GrB_Vector)
2434
)
2535
end
2636

37+
"""
38+
GrB_Vector_clear(v)
39+
40+
Remove all the elements (tuples) from a vector.
41+
"""
2742
function GrB_Vector_clear(v::GrB_Vector)
2843
return GrB_Info(
2944
ccall(
@@ -35,6 +50,11 @@ function GrB_Vector_clear(v::GrB_Vector)
3550
)
3651
end
3752

53+
"""
54+
GrB_Vector_size(v)
55+
56+
Return the size of a vector if successful else return value of type GrB Info.
57+
"""
3858
function GrB_Vector_size(v::GrB_Vector)
3959
n = Ref(UInt64(0))
4060
result = GrB_Info(
@@ -49,6 +69,12 @@ function GrB_Vector_size(v::GrB_Vector)
4969
return _GrB_Index(n[])
5070
end
5171

72+
"""
73+
GrB_Vector_nvals(v)
74+
75+
Return the number of stored elements in a vector if successful.
76+
Else return value of type GrB Info.
77+
"""
5278
function GrB_Vector_nvals(v::GrB_Vector)
5379
nvals = Ref(UInt64(0))
5480
result = GrB_Info(
@@ -63,6 +89,11 @@ function GrB_Vector_nvals(v::GrB_Vector)
6389
return _GrB_Index(nvals[])
6490
end
6591

92+
"""
93+
GrB_Vector_build(w, I, X, nvals, dup)
94+
95+
Store elements from tuples into a vector.
96+
"""
6697
function GrB_Vector_build(w::GrB_Vector, I::Vector{U}, X::Vector{T}, nvals::U, dup::GrB_BinaryOp) where{U <: GrB_Index, T <: valid_types}
6798
I_ptr = pointer(I)
6899
X_ptr = pointer(X)
@@ -78,6 +109,11 @@ function GrB_Vector_build(w::GrB_Vector, I::Vector{U}, X::Vector{T}, nvals::U, d
78109
)
79110
end
80111

112+
"""
113+
GrB_Vector_setElement(w, x, i)
114+
115+
Set one element of a vector to a given value, w[i] = x.
116+
"""
81117
function GrB_Vector_setElement(w::GrB_Vector, x::T, i::U) where {U <: GrB_Index, T <: valid_int_types}
82118
fn_name = "GrB_Vector_setElement_" * get_suffix(T)
83119
return GrB_Info(
@@ -114,6 +150,12 @@ function GrB_Vector_setElement(w::GrB_Vector, x::Float64, i::U) where U <: GrB_I
114150
)
115151
end
116152

153+
"""
154+
GrB_Vector_extractElement(v, i)
155+
156+
Return element of a vector at a given index (v[i]) if successful.
157+
Else return value of type GrB Info.
158+
"""
117159
function GrB_Vector_extractElement(v::GrB_Vector, i::U) where U <: GrB_Index
118160
res, v_type = GxB_Vector_type(v)
119161
res != GrB_SUCCESS && return res
@@ -133,6 +175,11 @@ function GrB_Vector_extractElement(v::GrB_Vector, i::U) where U <: GrB_Index
133175
return element[]
134176
end
135177

178+
"""
179+
GrB_Vector_extractTuples(v)
180+
181+
Return tuples stored in a vector.
182+
"""
136183
function GrB_Vector_extractTuples(v::GrB_Vector)
137184
res, v_type = GxB_Vector_type(v)
138185
res != GrB_SUCCESS && return res

0 commit comments

Comments
 (0)