@@ -18,6 +18,15 @@ blockdim = 5
18
18
@test size (d_x,1 ) == m
19
19
@test size (d_x,2 ) == 1
20
20
@test ndims (d_x) == 1
21
+ CuArrays. @allowscalar begin
22
+ @test Array (d_x[:]) == x[:]
23
+ @test d_x[firstindex (d_x)] == x[firstindex (x)]
24
+ @test d_x[div (end , 2 )] == x[div (end , 2 )]
25
+ @test d_x[end ] == x[end ]
26
+ @test Array (d_x[firstindex (d_x): end ]) == x[firstindex (x): end ]
27
+ end
28
+ @test_throws BoundsError d_x[firstindex (d_x) - 1 ]
29
+ @test_throws BoundsError d_x[end + 1 ]
21
30
@test nnz (d_x) == nnz (x)
22
31
@test Array (nonzeros (d_x)) == nonzeros (x)
23
32
@test Array (SparseArrays. nonzeroinds (d_x)) == SparseArrays. nonzeroinds (x)
@@ -30,6 +39,26 @@ blockdim = 5
30
39
@test size (d_x,2 ) == n
31
40
@test size (d_x,3 ) == 1
32
41
@test ndims (d_x) == 2
42
+ CuArrays. @allowscalar begin
43
+ @test Array (d_x[:]) == x[:]
44
+ @test d_x[firstindex (d_x)] == x[firstindex (x)]
45
+ @test d_x[div (end , 2 )] == x[div (end , 2 )]
46
+ @test d_x[end ] == x[end ]
47
+ @test d_x[firstindex (d_x), firstindex (d_x)] == x[firstindex (x), firstindex (x)]
48
+ @test d_x[div (end , 2 ), div (end , 2 )] == x[div (end , 2 ), div (end , 2 )]
49
+ @test d_x[end , end ] == x[end , end ]
50
+ @test Array (d_x[firstindex (d_x): end , firstindex (d_x): end ]) == x[:, :]
51
+ end
52
+ @test_throws BoundsError d_x[firstindex (d_x) - 1 ]
53
+ @test_throws BoundsError d_x[end + 1 ]
54
+ @test_throws BoundsError d_x[firstindex (d_x) - 1 , firstindex (d_x) - 1 ]
55
+ @test_throws BoundsError d_x[end + 1 , end + 1 ]
56
+ @test_throws BoundsError d_x[firstindex (d_x) - 1 : end + 1 , :]
57
+ @test_throws BoundsError d_x[firstindex (d_x) - 1 , :]
58
+ @test_throws BoundsError d_x[end + 1 , :]
59
+ @test_throws BoundsError d_x[:, firstindex (d_x) - 1 : end + 1 ]
60
+ @test_throws BoundsError d_x[:, firstindex (d_x) - 1 ]
61
+ @test_throws BoundsError d_x[:, end + 1 ]
33
62
@test nnz (d_x) == nnz (x)
34
63
@test Array (nonzeros (d_x)) == nonzeros (x)
35
64
@test nnz (d_x) == length (nonzeros (d_x))
0 commit comments