File: eig_simple_rump.c

package info (click to toggle)
flint-arb 1%3A2.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,028 kB
  • sloc: ansic: 177,109; sh: 553; makefile: 288; python: 268
file content (81 lines) | stat: -rw-r--r-- 1,866 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
    Copyright (C) 2018 Fredrik Johansson

    This file is part of Arb.

    Arb is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.  See <http://www.gnu.org/licenses/>.
*/

#include "acb_mat.h"

int
acb_mat_eig_simple_rump(acb_ptr E, acb_mat_t L, acb_mat_t R,
    const acb_mat_t A, acb_srcptr E_approx, const acb_mat_t R_approx, slong prec)
{
    slong i, j, n;
    acb_mat_t X, R2;
    int result;

    n = acb_mat_nrows(A);

    if (n == 0)
        return 1;

    if (n == 1)
    {
        acb_set_round(E, acb_mat_entry(A, 0, 0), prec);
        if (L != NULL)
            acb_one(acb_mat_entry(L, 0, 0));
        if (R != NULL)
            acb_one(acb_mat_entry(R, 0, 0));
        return 1;
    }

    acb_mat_init(X, n, 1);
    acb_mat_init(R2, n, n);

    result = 1;

    for (i = 0; i < n && result; i++)
    {
        for (j = 0; j < n; j++)
            acb_set(acb_mat_entry(X, j, 0), acb_mat_entry(R_approx, j, i));

        acb_mat_eig_enclosure_rump(E + i, NULL, X, A, E_approx + i, X, prec);

        if (!acb_is_finite(E + i))
            result = 0;

        for (j = 0; j < i; j++)
            if (acb_overlaps(E + i, E + j))
                result = 0;

        for (j = 0; j < n; j++)
            acb_set(acb_mat_entry(R2, j, i), acb_mat_entry(X, j, 0));
    }

    if (R != NULL)
    {
        if (result)
            acb_mat_set(R, R2);
        else
            acb_mat_indeterminate(R);
    }

    if (L != NULL)
    {
        if (!result || !acb_mat_inv(L, R2, prec))
            acb_mat_indeterminate(L);
    }

    if (!result)
        _acb_vec_indeterminate(E, n);

    acb_mat_clear(X);
    acb_mat_clear(R2);

    return result;
}