@@ -243,6 +243,90 @@ let a = SparseVector(8, [2, 5, 6], Int32[12, 35, 72])
243
243
@test sparsevec (ctranspose (ctranspose (acp))) == acp
244
244
end
245
245
246
+ let x1 = SparseVector (8 , [2 , 5 , 6 ], [12.2 , 1.4 , 5.0 ])
247
+ x2 = SparseVector (8 , [3 , 4 ], [1.2 , 3.4 ])
248
+ copy! (x2, x1)
249
+ @test x2 == x1
250
+ x2 = SparseVector (8 , [2 , 4 , 8 ], [10.3 , 7.4 , 3.1 ])
251
+ copy! (x2, x1)
252
+ @test x2 == x1
253
+ x2 = SparseVector (8 , [1 , 3 , 4 , 7 ], [0.3 , 1.2 , 3.4 , 0.1 ])
254
+ copy! (x2, x1)
255
+ @test x2 == x1
256
+ x2 = SparseVector (10 , [3 , 4 ], [1.2 , 3.4 ])
257
+ copy! (x2, x1)
258
+ @test x2[1 : 8 ] == x1
259
+ @test x2[9 : 10 ] == spzeros (2 )
260
+ x2 = SparseVector (10 , [3 , 4 , 9 ], [1.2 , 3.4 , 17.8 ])
261
+ copy! (x2, x1)
262
+ @test x2[1 : 8 ] == x1
263
+ @test x2[9 ] == 17.8
264
+ @test x2[10 ] == 0
265
+ x2 = SparseVector (10 , [3 , 4 , 5 , 6 , 9 ], [8.3 , 7.2 , 1.2 , 3.4 , 17.8 ])
266
+ copy! (x2, x1)
267
+ @test x2[1 : 8 ] == x1
268
+ @test x2[9 ] == 17.8
269
+ @test x2[10 ] == 0
270
+ x2 = SparseVector (6 , [3 , 4 ], [1.2 , 3.4 ])
271
+ @test_throws BoundsError copy! (x2, x1)
272
+ end
273
+
274
+ let x1 = sparse ([2 , 1 , 2 ], [1 , 3 , 3 ], [12.2 , 1.4 , 5.0 ], 2 , 4 )
275
+ x2 = SparseVector (8 , [3 , 4 ], [1.2 , 3.4 ])
276
+ copy! (x2, x1)
277
+ @test x2[:] == x1[:]
278
+ x2 = SparseVector (8 , [2 , 4 , 8 ], [10.3 , 7.4 , 3.1 ])
279
+ copy! (x2, x1)
280
+ @test x2[:] == x1[:]
281
+ x2 = SparseVector (8 , [1 , 3 , 4 , 7 ], [0.3 , 1.2 , 3.4 , 0.1 ])
282
+ copy! (x2, x1)
283
+ @test x2[:] == x1[:]
284
+ x2 = SparseVector (10 , [3 , 4 ], [1.2 , 3.4 ])
285
+ copy! (x2, x1)
286
+ @test x2[1 : 8 ] == x1[:]
287
+ @test x2[9 : 10 ] == spzeros (2 )
288
+ x2 = SparseVector (10 , [3 , 4 , 9 ], [1.2 , 3.4 , 17.8 ])
289
+ copy! (x2, x1)
290
+ @test x2[1 : 8 ] == x1[:]
291
+ @test x2[9 ] == 17.8
292
+ @test x2[10 ] == 0
293
+ x2 = SparseVector (10 , [3 , 4 , 5 , 6 , 9 ], [8.3 , 7.2 , 1.2 , 3.4 , 17.8 ])
294
+ copy! (x2, x1)
295
+ @test x2[1 : 8 ] == x1[:]
296
+ @test x2[9 ] == 17.8
297
+ @test x2[10 ] == 0
298
+ x2 = SparseVector (6 , [3 , 4 ], [1.2 , 3.4 ])
299
+ @test_throws BoundsError copy! (x2, x1)
300
+ end
301
+
302
+ let x1 = SparseVector (8 , [2 , 5 , 6 ], [12.2 , 1.4 , 5.0 ])
303
+ x2 = sparse ([1 , 2 ], [2 , 2 ], [1.2 , 3.4 ], 2 , 4 )
304
+ copy! (x2, x1)
305
+ @test x2[:] == x1[:]
306
+ x2 = sparse ([2 , 2 , 2 ], [1 , 3 , 4 ], [10.3 , 7.4 , 3.1 ], 2 , 4 )
307
+ copy! (x2, x1)
308
+ @test x2[:] == x1[:]
309
+ x2 = sparse ([1 , 1 , 2 , 1 ], [1 , 2 , 2 , 4 ], [0.3 , 1.2 , 3.4 , 0.1 ], 2 , 4 )
310
+ copy! (x2, x1)
311
+ @test x2[:] == x1[:]
312
+ x2 = sparse ([1 , 2 ], [2 , 2 ], [1.2 , 3.4 ], 2 , 5 )
313
+ copy! (x2, x1)
314
+ @test x2[1 : 8 ] == x1
315
+ @test x2[9 : 10 ] == spzeros (2 )
316
+ x2 = sparse ([1 , 2 , 1 ], [2 , 2 , 5 ], [1.2 , 3.4 , 17.8 ], 2 , 5 )
317
+ copy! (x2, x1)
318
+ @test x2[1 : 8 ] == x1
319
+ @test x2[9 ] == 17.8
320
+ @test x2[10 ] == 0
321
+ x2 = sparse ([1 , 2 , 1 , 2 , 1 ], [2 , 2 , 3 , 3 , 5 ], [8.3 , 7.2 , 1.2 , 3.4 , 17.8 ], 2 , 5 )
322
+ copy! (x2, x1)
323
+ @test x2[1 : 8 ] == x1
324
+ @test x2[9 ] == 17.8
325
+ @test x2[10 ] == 0
326
+ x2 = sparse ([1 , 2 ], [2 , 2 ], [1.2 , 3.4 ], 2 , 3 )
327
+ @test_throws BoundsError copy! (x2, x1)
328
+ end
329
+
246
330
# ## Type conversion
247
331
248
332
let x = convert (SparseVector, sparse ([2 , 5 , 6 ], [1 , 1 , 1 ], [1.25 , - 0.75 , 3.5 ], 8 , 1 ))
0 commit comments