Exemple #1
0
static void free_linear_system (Linear_System_Type *t)
{
   if (t == NULL)
     return;
   JDMfree_double_matrix (t->a, t->n);
   t->a = NULL;
   ISIS_FREE(t->b);
   t->n = 0;
}
Exemple #2
0
static int test_inverse (unsigned int n, double tol,
                         int (*fun) (double **, double **, unsigned int))
{
    Special_Matrix_Type *s;
    double **a, **b;

    if (NULL == (a = JDMdouble_matrix (n, n)))
        return -1;

    if (NULL == (b = JDMdouble_matrix (n, n)))
    {
        JDMfree_double_matrix (a, n);
        return -1;
    }

    s = Special_Matrices;
    while (s->f != NULL)
    {
        int status;
        double val;

        init_matrix (a, n, s->f);
        status = test_this_inverse (a, b, n, fun, &val);
        if (status == -1)
            return -1;

        if (status == s->is_singular)
        {
            fprintf (stderr, "%s: failed singularity test\n", s->name);
            s++;
            continue;
        }

        if (s->is_singular)
        {
            s++;
            continue;
        }

        if (val > tol)
            fprintf (stderr, "%s failed: tolerance exceeded (%e)\n", s->name, val);

        s++;
    }

    return 0;
}