11# This file is a part of Julia. License is MIT: https://julialang.org/license
22
33using Base: findprevnot, findnextnot
4- using Random, LinearAlgebra, Test
4+ using Random, Test, LinearAlgebra # Ideally, these tests should not depend on LinearAlgebra
55
66isdefined (Main, :SizedArrays ) || @eval Main include (" testhelpers/SizedArrays.jl" )
77using . Main. SizedArrays
@@ -15,7 +15,6 @@ tc(r1,r2) = false
1515
1616bitcheck (b:: BitArray ) = Test. _check_bitarray_consistency (b)
1717bitcheck (x) = true
18- bcast_setindex! (b, x, I... ) = (b[I... ] .= x; b)
1918
2019function check_bitop_call (ret_type, func, args... ; kwargs... )
2120 r2 = func (map (x-> (isa (x, BitArray) ? Array (x) : x), args)... ; kwargs... )
@@ -34,6 +33,9 @@ macro check_bit_operation(ex)
3433 Expr (:call , :check_bitop_call , nothing , map (esc, ex. args)... )
3534end
3635
36+ bcast_setindex! (b, x, I... ) = (b[I... ] .= x; b)
37+
38+
3739let t0 = time_ns ()
3840 global timesofar
3941 function timesofar (str)
@@ -1641,69 +1643,6 @@ end
16411643
16421644timesofar (" cat" )
16431645
1644- @testset " Linear algebra" begin
1645- b1 = bitrand (v1)
1646- b2 = bitrand (v1)
1647- @check_bit_operation dot (b1, b2) Int
1648-
1649- b1 = bitrand (n1, n2)
1650- @test_throws ArgumentError tril (b1, - n1 - 2 )
1651- @test_throws ArgumentError tril (b1, n2)
1652- @test_throws ArgumentError triu (b1, - n1)
1653- @test_throws ArgumentError triu (b1, n2 + 2 )
1654- for k in (- n1 - 1 ): (n2 - 1 )
1655- @check_bit_operation tril (b1, k) BitMatrix
1656- end
1657- for k in (- n1 + 1 ): (n2 + 1 )
1658- @check_bit_operation triu (b1, k) BitMatrix
1659- end
1660-
1661- for sz = [(n1,n1), (n1,n2), (n2,n1)], (f,isf) = [(tril,istril), (triu,istriu)]
1662- b1 = bitrand (sz... )
1663- @check_bit_operation isf (b1) Bool
1664- b1 = f (bitrand (sz... ))
1665- @check_bit_operation isf (b1) Bool
1666- end
1667-
1668- b1 = bitrand (n1,n1)
1669- b1 .| = copy (b1' )
1670- @check_bit_operation issymmetric (b1) Bool
1671- @check_bit_operation ishermitian (b1) Bool
1672-
1673- b1 = bitrand (n1)
1674- b2 = bitrand (n2)
1675- @check_bit_operation kron (b1, b2) BitVector
1676-
1677- b1 = bitrand (s1, s2)
1678- b2 = bitrand (s3, s4)
1679- @check_bit_operation kron (b1, b2) BitMatrix
1680-
1681- b1 = bitrand (v1)
1682- @check_bit_operation diff (b1) Vector{Int}
1683-
1684- b1 = bitrand (n1, n2)
1685- @check_bit_operation diff (b1, dims= 1 ) Matrix{Int}
1686- @check_bit_operation diff (b1, dims= 2 ) Matrix{Int}
1687-
1688- b1 = bitrand (n1, n1)
1689- @test ((svdb1, svdb1A) = (svd (b1), svd (Array (b1)));
1690- svdb1. U == svdb1A. U && svdb1. S == svdb1A. S && svdb1. V == svdb1A. V)
1691- @test ((qrb1, qrb1A) = (qr (b1), qr (Array (b1)));
1692- Matrix (qrb1. Q) == Matrix (qrb1A. Q) && qrb1. R == qrb1A. R)
1693-
1694- b1 = bitrand (v1)
1695- @check_bit_operation diagm (0 => b1) BitMatrix
1696-
1697- b1 = bitrand (v1)
1698- b2 = bitrand (v1)
1699- @check_bit_operation diagm (- 1 => b1, 1 => b2) BitMatrix
1700-
1701- b1 = bitrand (n1, n1)
1702- @check_bit_operation diag (b1)
1703- end
1704-
1705- timesofar (" linalg" )
1706-
17071646@testset " findmax, findmin" begin
17081647 b1 = trues (0 )
17091648 @test_throws ArgumentError findmax (b1)
0 commit comments