File: hessenberg.jl

package info (click to toggle)
julia 1.0.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,452 kB
  • sloc: lisp: 236,453; ansic: 55,579; cpp: 25,603; makefile: 1,685; pascal: 1,130; sh: 956; asm: 86; xml: 76
file content (35 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This file is a part of Julia. License is MIT: https://julialang.org/license

module TestHessenberg

using Test, LinearAlgebra, Random

let n = 10
    Random.seed!(1234321)

    Areal  = randn(n,n)/2
    Aimg   = randn(n,n)/2

    @testset for eltya in (Float32, Float64, ComplexF32, ComplexF64, BigFloat, Int)
        A = eltya == Int ?
                rand(1:7, n, n) :
                convert(Matrix{eltya}, eltya <: Complex ?
                    complex.(Areal, Aimg) :
                    Areal)

        if eltya != BigFloat
            H = hessenberg(A)
            @test size(H.Q, 1) == size(A, 1)
            @test size(H.Q, 2) == size(A, 2)
            @test size(H.Q) == size(A)
            @test_throws ErrorException H.Z
            @test convert(Array, H) ≈ A
            @test (H.Q * H.H) * H.Q' ≈ A
            @test (H.Q' *A) * H.Q ≈ H.H
            #getindex for HessenbergQ
            @test H.Q[1,1] ≈ Array(H.Q)[1,1]
        end
    end
end

end # module TestHessenberg