@@ -39,13 +39,18 @@ colstop(A::RaggedMatrix,j::Integer) = min(A.cols[j+1]-A.cols[j],size(A,1))
39
39
40
40
Base. IndexStyle (:: Type{RM} ) where {RM<: RaggedMatrix } = IndexCartesian ()
41
41
42
+ @inline function incol (A, k, j, ind = A. cols[j]+ k- 1 )
43
+ ind < A. cols[j+ 1 ]
44
+ end
45
+
42
46
function getindex (A:: RaggedMatrix ,k:: Int ,j:: Int )
43
47
if k> size (A,1 ) || k < 1 || j> size (A,2 ) || j < 1
44
48
throw (BoundsError (A,(k,j)))
45
49
end
46
50
47
- if A. cols[j]+ k- 1 < A. cols[j+ 1 ]
48
- A. data[A. cols[j]+ k- 1 ]
51
+ ind = A. cols[j]+ k- 1
52
+ if incol (A, k, j, ind)
53
+ A. data[ind]
49
54
else
50
55
zero (eltype (A))
51
56
end
@@ -56,8 +61,9 @@ function Base.setindex!(A::RaggedMatrix,v,k::Int,j::Int)
56
61
throw (BoundsError (A,(k,j)))
57
62
end
58
63
59
- if A. cols[j]+ k- 1 < A. cols[j+ 1 ]
60
- A. data[A. cols[j]+ k- 1 ]= v
64
+ ind = A. cols[j]+ k- 1
65
+ if incol (A, k, j, ind)
66
+ A. data[ind]= v
61
67
elseif v ≠ 0
62
68
throw (BoundsError (A,(k,j)))
63
69
end
131
137
132
138
RaggedMatrix (A:: AbstractMatrix , colns:: AbstractVector{Int} ) = RaggedMatrix {eltype(A)} (A, colns)
133
139
140
+ function Base. replace_in_print_matrix (A:: RaggedMatrix ,i:: Integer ,j:: Integer ,s:: AbstractString )
141
+ incol (A, i, j) ? s : Base. replace_with_centered_mark (s)
142
+ end
134
143
135
144
# # BLAS
136
145
0 commit comments