@@ -56,48 +56,43 @@ SpValProxy<T1>::operator=(const SpValProxy<T2>& rhs)
5656
5757
5858template <typename T1>
59- arma_inline
59+ inline
6060SpValProxy<T1>&
6161SpValProxy<T1>::operator =(const eT rhs)
6262 {
6363 if (rhs != eT (0 )) // A nonzero element is being assigned.
6464 {
65-
6665 if (val_ptr)
6766 {
6867 // The value exists and merely needs to be updated.
6968 *val_ptr = rhs;
7069 parent.invalidate_cache ();
7170 }
72-
7371 else
7472 {
7573 // The value is nonzero and must be inserted.
7674 val_ptr = &parent.insert_element (row, col, rhs);
7775 }
78-
7976 }
8077 else // A zero is being assigned.~
8178 {
82-
8379 if (val_ptr)
8480 {
8581 // The element exists, but we need to remove it, because it is being set to 0.
8682 parent.delete_element (row, col);
8783 val_ptr = nullptr ;
8884 }
89-
85+
9086 // If the element does not exist, we do not need to do anything at all.
91-
9287 }
93-
88+
9489 return *this ;
9590 }
9691
9792
9893
9994template <typename T1>
100- arma_inline
95+ inline
10196SpValProxy<T1>&
10297SpValProxy<T1>::operator +=(const eT rhs)
10398 {
@@ -123,7 +118,7 @@ SpValProxy<T1>::operator+=(const eT rhs)
123118
124119
125120template <typename T1>
126- arma_inline
121+ inline
127122SpValProxy<T1>&
128123SpValProxy<T1>::operator -=(const eT rhs)
129124 {
@@ -142,65 +137,58 @@ SpValProxy<T1>::operator-=(const eT rhs)
142137 val_ptr = &parent.insert_element (row, col, -rhs);
143138 }
144139 }
145-
140+
146141 return *this ;
147142 }
148143
149144
150145
151146template <typename T1>
152- arma_inline
147+ inline
153148SpValProxy<T1>&
154149SpValProxy<T1>::operator *=(const eT rhs)
155150 {
156151 if (rhs != eT (0 ))
157152 {
158-
159153 if (val_ptr)
160154 {
161155 // The value already exists and merely needs to be updated.
162156 *val_ptr *= rhs;
163157 parent.invalidate_cache ();
164158 check_zero ();
165159 }
166-
167160 }
168161 else
169162 {
170-
171163 if (val_ptr)
172164 {
173165 // Since we are multiplying by zero, the value can be deleted.
174166 parent.delete_element (row, col);
175167 val_ptr = nullptr ;
176168 }
177-
178169 }
179-
170+
180171 return *this ;
181172 }
182173
183174
184175
185176template <typename T1>
186- arma_inline
177+ inline
187178SpValProxy<T1>&
188179SpValProxy<T1>::operator /=(const eT rhs)
189180 {
190181 if (rhs != eT (0 )) // I hope this is true!
191182 {
192-
193183 if (val_ptr)
194184 {
195185 *val_ptr /= rhs;
196186 parent.invalidate_cache ();
197187 check_zero ();
198188 }
199-
200189 }
201190 else
202191 {
203-
204192 if (val_ptr)
205193 {
206194 *val_ptr /= rhs; // That is where it gets ugly.
@@ -211,27 +199,25 @@ SpValProxy<T1>::operator/=(const eT rhs)
211199 val_ptr = nullptr ;
212200 }
213201 }
214-
215202 else
216203 {
217204 eT val = eT (0 ) / rhs; // This may vary depending on type and implementation.
218-
205+
219206 if (val != eT (0 ))
220207 {
221208 // Ok, now we have to insert it.
222209 val_ptr = &parent.insert_element (row, col, val);
223210 }
224-
225211 }
226212 }
227-
213+
228214 return *this ;
229215 }
230216
231217
232218
233219template <typename T1>
234- arma_inline
220+ inline
235221SpValProxy<T1>&
236222SpValProxy<T1>::operator ++()
237223 {
@@ -241,19 +227,18 @@ SpValProxy<T1>::operator++()
241227 parent.invalidate_cache ();
242228 check_zero ();
243229 }
244-
245230 else
246231 {
247232 val_ptr = &parent.insert_element (row, col, eT (1 ));
248233 }
249-
234+
250235 return *this ;
251236 }
252237
253238
254239
255240template <typename T1>
256- arma_inline
241+ inline
257242SpValProxy<T1>&
258243SpValProxy<T1>::operator --()
259244 {
@@ -263,19 +248,18 @@ SpValProxy<T1>::operator--()
263248 parent.invalidate_cache ();
264249 check_zero ();
265250 }
266-
267251 else
268252 {
269253 val_ptr = &parent.insert_element (row, col, eT (-1 ));
270254 }
271-
255+
272256 return *this ;
273257 }
274258
275259
276260
277261template <typename T1>
278- arma_inline
262+ inline
279263typename T1::elem_type
280264SpValProxy<T1>::operator ++(const int )
281265 {
@@ -285,12 +269,11 @@ SpValProxy<T1>::operator++(const int)
285269 parent.invalidate_cache ();
286270 check_zero ();
287271 }
288-
289272 else
290273 {
291274 val_ptr = &parent.insert_element (row, col, eT (1 ));
292275 }
293-
276+
294277 if (val_ptr) // It may have changed to now be 0.
295278 {
296279 return *(val_ptr) - eT (1 );
@@ -304,7 +287,7 @@ SpValProxy<T1>::operator++(const int)
304287
305288
306289template <typename T1>
307- arma_inline
290+ inline
308291typename T1::elem_type
309292SpValProxy<T1>::operator --(const int )
310293 {
@@ -314,12 +297,11 @@ SpValProxy<T1>::operator--(const int)
314297 parent.invalidate_cache ();
315298 check_zero ();
316299 }
317-
318300 else
319301 {
320302 val_ptr = &parent.insert_element (row, col, eT (-1 ));
321303 }
322-
304+
323305 if (val_ptr) // It may have changed to now be 0.
324306 {
325307 return *(val_ptr) + eT (1 );
0 commit comments