Пример #1
0
Файл: math.c Проект: hankem/ISIS
static void lu_solve_intrin (void)
{
   Linear_System_Type t;
   SLang_Array_Type *sl_b = NULL;
   unsigned int *piv = NULL;

   if ((-1 == pop_linear_system (&t))
       || (NULL == (piv = (unsigned int *) ISIS_MALLOC (t.n * sizeof(unsigned int)))))
     {
        isis_throw_exception (Isis_Error);
        goto the_return;
     }

   if (-1 == isis_lu_solve (t.a, t.n, piv, t.b))
     goto the_return;

   sl_b = SLang_create_array (SLANG_DOUBLE_TYPE, 0, NULL, &t.n, 1);
   if (sl_b != NULL)
     {
        memcpy ((char *)sl_b->data, (char *)t.b, t.n * sizeof (double));
     }

the_return:
   SLang_push_array (sl_b, 1);
   free_linear_system (&t);
   ISIS_FREE(piv);
}
Пример #2
0
int main(int ac, char** av)
{
  grid_t g;
  gsl_matrix* a;
  gsl_vector* x;
  gsl_vector* b;

  gsl_permutation* p;
  int s;
  int i;

  grid_init_once(&g);

  alloc_linear_system(&g, &a, &x, &b);
  generate_a(&g, a);

  p = gsl_permutation_alloc(a->size1);
  gsl_linalg_LU_decomp(a, p, &s);

  for (i = 1; i < ac; ++i)
  {
    grid_load_string(&g, av[i]);
    generate_b(&g, b);
    gsl_linalg_LU_solve(a, p, b, x);
    print_vector(x);
    printf("---\n");
  }

  gsl_permutation_free(p);
  free_linear_system(a, x, b);

  return 0;
}
Пример #3
0
Файл: math.c Проект: hankem/ISIS
static void svd_solve_intrin (void)
{
   Linear_System_Type t;
   SLang_Array_Type *sl_b = NULL;

   if (-1 == pop_linear_system (&t))
     {
        isis_throw_exception (Isis_Error);
        goto the_return;
     }

   if (-1 == isis_svd_solve (t.a, t.n, t.b))
     goto the_return;

   sl_b = SLang_create_array (SLANG_DOUBLE_TYPE, 0, NULL, &t.n, 1);
   if (sl_b != NULL)
     {
        memcpy ((char *)sl_b->data, (char *)t.b, t.n * sizeof (double));
     }

the_return:
   SLang_push_array (sl_b, 1);
   free_linear_system (&t);
}