Exemple #1
0
t_stree		*push_ops(char *expr, t_stree *begin, int *neg, char *ops, char *base)
{
	t_stree	*current_elem;
	t_stree *last;
	char	*expr_test;

	last = read_stree(begin);
	if (*expr == ops[2])
	{
		current_elem = push('+', NULL, neg);
		if (last->number != NULL)
		{
			current_elem->left = begin;
		}
		else
		{
			current_elem->right = begin;
		}
		begin = current_elem;
	}
	else if (*expr == ops[3])
	{
		expr_test = expr - 1;
		while (if_digits(*expr_test, base) == 0 && if_ops(*expr_test, ops) == 0)
		{
			expr_test = expr_test - 1;
		}
		if (if_ops(*expr_test, ops))
		{
			*neg = 1;
		}
		else 
		{
			current_elem = push('-', NULL, neg);
			if (last->number != NULL)
			{
				current_elem->left = begin;
			}
			else
			{
				current_elem->right = begin;
			}
			begin = current_elem;
		}
	}
	else
	{
		current_elem = push(test_ops(*expr, ops), NULL, neg);
		if (last->number != NULL)
		{
			current_elem->left = begin;
			begin = current_elem;
		}
		else
		{
			last->right = current_elem;
		}
	}
	return (begin);
}
Exemple #2
0
int main(int argc, char **argv)
{
    err_setarg0(argv[argc-argc]);

    test_set();
    test_ops();

    return 0;
}
Exemple #3
0
/*
 * Test 2: n = bitsize
 */
static void test2(uint32_t n) {
  uint32_t i, j;

  init_test2(n);
  for (i=0; i<8; i++) {
    for (j=0; j<8; j++) {
      test_ops(aux + i, aux + j);
    }
  }
  delete_test2();
}
Exemple #4
0
int
main()
{
  gsl_rng *r = gsl_rng_alloc(gsl_rng_default);

  test_memcpy(10, 10, 0.2, r);
  test_memcpy(10, 15, 0.3, r);
  test_memcpy(53, 213, 0.4, r);
  test_memcpy(920, 2, 0.2, r);
  test_memcpy(2, 920, 0.3, r);

  test_getset(20, 20, 0.3, r);
  test_getset(30, 20, 0.3, r);
  test_getset(15, 210, 0.3, r);

  test_transpose(50, 50, 0.5, r);
  test_transpose(10, 40, 0.3, r);
  test_transpose(40, 10, 0.3, r);
  test_transpose(57, 13, 0.2, r);

  test_ops(20, 20, 0.2, r);
  test_ops(50, 20, 0.3, r);
  test_ops(20, 50, 0.3, r);
  test_ops(76, 43, 0.4, r);

  test_io_ascii(30, 30, 0.3, r);
  test_io_ascii(20, 10, 0.2, r);
  test_io_ascii(10, 20, 0.2, r);
  test_io_ascii(34, 78, 0.3, r);

  test_io_binary(50, 50, 0.3, r);
  test_io_binary(25, 10, 0.2, r);
  test_io_binary(10, 25, 0.2, r);
  test_io_binary(101, 253, 0.3, r);

  gsl_rng_free(r);

  exit (gsl_test_summary());
} /* main() */
Exemple #5
0
int
main()
{
  gsl_rng *r = gsl_rng_alloc(gsl_rng_default);
  
  test_memcpy(10, 10, r);
  test_memcpy(10, 15, r);
  test_memcpy(53, 213, r);
  test_memcpy(920, 2, r);
  test_memcpy(2, 920, r);

  test_getset(20, 20, r);
  test_getset(30, 20, r);
  test_getset(15, 210, r);

  test_ops(20, 20, r);
  test_ops(50, 20, r);
  test_ops(20, 50, r);
  test_ops(76, 43, r);

  /** Test compresion (spcompress.c) with duplicates and transposition (spswap.c) */
  test_compress(15, 5, 0.2, r);

  /** Test manipulation (spmanip.c)*/
  test_manip(5, 8, 0.2, r);
  
  /** Test tests (spprop.c) */
  test_prop(5, 5, 0.5, 0.5, r);

  /** Test Input/Output */
  //fprintf(stdout, "Testing Input/Output:\nInput matrix (summing duplicate):\n");
  //test_io(stdin, stdout);

  gsl_rng_free(r);

  exit (gsl_test_summary());
} /* main() */
Exemple #6
0
Fichier : test.c Projet : FMX/gsl
int
main()
{
  gsl_rng *r = gsl_rng_alloc(gsl_rng_default);

  test_memcpy(10, 10, r);
  test_memcpy(10, 15, r);
  test_memcpy(53, 213, r);
  test_memcpy(920, 2, r);
  test_memcpy(2, 920, r);

  test_getset(20, 20, r);
  test_getset(30, 20, r);
  test_getset(15, 210, r);

  test_ops(20, 20, r);
  test_ops(50, 20, r);
  test_ops(20, 50, r);
  test_ops(76, 43, r);

  gsl_rng_free(r);

  exit (gsl_test_summary());
} /* main() */
Exemple #7
0
void do_test (TestId      id,
              const char *tname,
              const char *tfmt,
              const char *cname,
              const char *trname,
              const char *dname)
{
    const ParamNames names = { tname, tfmt, cname, trname, dname };
    const TempParams<T, CharT, Traits, Dist> params = { names };

    if (TestCtors == id) {
        test_ctors (params);
    }
    else if (TestOps == id) {
        test_ops (params);
    }
}
Exemple #8
0
Fichier : test.c Projet : CNMAT/gsl
int
main (void)
{
  size_t M = 53;
  size_t N = 107;

  gsl_ieee_env_setup ();

  test_func (M, N);
  test_float_func (M, N);
  test_long_double_func (M, N);
  test_ulong_func (M, N);
  test_long_func (M, N);
  test_uint_func (M, N);
  test_int_func (M, N);
  test_ushort_func (M, N);
  test_short_func (M, N);
  test_uchar_func (M, N);
  test_char_func (M, N);
  test_complex_func (M, N);
  test_complex_float_func (M, N);
  test_complex_long_double_func (M, N);

  test_ops (M, N);
  test_float_ops (M, N);
  test_long_double_ops (M, N);
  test_ulong_ops (M, N);
  test_long_ops (M, N);
  test_uint_ops (M, N);
  test_int_ops (M, N);
  test_ushort_ops (M, N);
  test_short_ops (M, N);
  test_uchar_ops (M, N);
  test_char_ops (M, N);

  /* Must use smaller dimensions to prevent approximation of floats in
     float_mul_elements test*/
  
  {
    const size_t P = 8;
    const size_t Q = 12;

    test_complex_ops (P, Q);
    test_complex_float_ops (P, Q);
    test_complex_long_double_ops (P, Q);
  }

  test_text (M, N);
  test_float_text (M, N);
#if HAVE_PRINTF_LONGDOUBLE
  test_long_double_text (M, N);
#endif
  test_ulong_text (M, N);
  test_long_text (M, N);
  test_uint_text (M, N);
  test_int_text (M, N);
  test_ushort_text (M, N);
  test_short_text (M, N);
  test_uchar_text (M, N);
  test_char_text (M, N);
  test_complex_text (M, N);
  test_complex_float_text (M, N);
#if HAVE_PRINTF_LONGDOUBLE
  test_complex_long_double_text (M, N);
#endif

  test_binary (M, N);
  test_float_binary (M, N);
  test_long_double_binary (M, N);
  test_ulong_binary (M, N);
  test_long_binary (M, N);
  test_uint_binary (M, N);
  test_int_binary (M, N);
  test_ushort_binary (M, N);
  test_short_binary (M, N);
  test_uchar_binary (M, N);
  test_char_binary (M, N);
  test_complex_binary (M, N);
  test_complex_float_binary (M, N);
  test_complex_long_double_binary (M, N);

#if GSL_RANGE_CHECK
  gsl_set_error_handler (&my_error_handler);

  test_trap (M, N);
  test_float_trap (M, N);
  test_long_double_trap (M, N);
  test_ulong_trap (M, N);
  test_long_trap (M, N);
  test_uint_trap (M, N);
  test_int_trap (M, N);
  test_ushort_trap (M, N);
  test_short_trap (M, N);
  test_uchar_trap (M, N);
  test_char_trap (M, N);
  test_complex_trap (M, N);
  test_complex_float_trap (M, N);
  test_complex_long_double_trap (M, N);
#endif

  exit (gsl_test_summary ());
}
Exemple #9
0
Fichier : test.c Projet : ampl/gsl
int
main (void)
{
  size_t stride, ostride, N;

  gsl_ieee_env_setup ();

  for (N = 10; N < 1024; N = 2*N + 1) 
    {
      for (stride = 1; stride < 5 ; stride++)
        {
          test_func (stride, N);
          test_float_func (stride, N);
          test_long_double_func (stride, N);
          test_ulong_func (stride, N);
          test_long_func (stride, N);
          test_uint_func (stride, N);
          test_int_func (stride, N);
          test_ushort_func (stride, N);
          test_short_func (stride, N);
          test_uchar_func (stride, N);
          test_char_func (stride, N);

          test_complex_func (stride, N);
          test_complex_float_func (stride, N);
          test_complex_long_double_func (stride, N);

          for (ostride = 1; ostride < 5 ; ostride++)
            {
              test_ops (stride, ostride, N);
              test_float_ops (stride, ostride, N);
              test_long_double_ops (stride, ostride, N);
              test_ulong_ops (stride, ostride, N);
              test_long_ops (stride, ostride, N);
              test_uint_ops (stride, ostride, N);
              test_int_ops (stride, ostride, N);
              test_ushort_ops (stride, ostride, N);
              test_short_ops (stride, ostride, N);
              test_uchar_ops (stride, ostride, N);
              test_char_ops (stride, ostride, N);
              test_complex_ops (stride, ostride, N);
              test_complex_float_ops (stride, ostride, N);
              test_complex_long_double_ops (stride, ostride, N);
            }              

          test_text (stride, N);
          test_float_text (stride, N);
#if HAVE_PRINTF_LONGDOUBLE
          test_long_double_text (stride, N);
#endif
          test_ulong_text (stride, N);
          test_long_text (stride, N);
          test_uint_text (stride, N);
          test_int_text (stride, N);
          test_ushort_text (stride, N);
          test_short_text (stride, N);
          test_uchar_text (stride, N);
          test_char_text (stride, N);

          test_complex_text (stride, N);
          test_complex_float_text (stride, N);
#if HAVE_PRINTF_LONGDOUBLE
          test_complex_long_double_text (stride, N);
#endif

          test_file (stride, N);
          test_float_file (stride, N);
          test_long_double_file (stride, N);
          test_ulong_file (stride, N);
          test_long_file (stride, N);
          test_uint_file (stride, N);
          test_int_file (stride, N);
          test_ushort_file (stride, N);
          test_short_file (stride, N);
          test_uchar_file (stride, N);
          test_char_file (stride, N);
          test_complex_file (stride, N);
          test_complex_float_file (stride, N);
          test_complex_long_double_file (stride, N);
        }
    }

    test_alloc_zero_length ();
    test_float_alloc_zero_length ();
    test_long_double_alloc_zero_length ();
    test_ulong_alloc_zero_length ();
    test_long_alloc_zero_length ();
    test_uint_alloc_zero_length ();
    test_int_alloc_zero_length ();
    test_ushort_alloc_zero_length ();
    test_short_alloc_zero_length ();
    test_uchar_alloc_zero_length ();
    test_char_alloc_zero_length ();

    test_complex_alloc_zero_length ();
    test_complex_float_alloc_zero_length ();
    test_complex_long_double_alloc_zero_length ();

    test_calloc_zero_length ();
    test_float_calloc_zero_length ();
    test_long_double_calloc_zero_length ();
    test_ulong_calloc_zero_length ();
    test_long_calloc_zero_length ();
    test_uint_calloc_zero_length ();
    test_int_calloc_zero_length ();
    test_ushort_calloc_zero_length ();
    test_short_calloc_zero_length ();
    test_uchar_calloc_zero_length ();
    test_char_calloc_zero_length ();

    test_complex_calloc_zero_length ();
    test_complex_float_calloc_zero_length ();
    test_complex_long_double_calloc_zero_length ();

#if GSL_RANGE_CHECK
  gsl_set_error_handler (&my_error_handler);

  for (N = 1; N < 1024; N *=2) 
    {
      for (stride = 1; stride < 5 ; stride++)
        {
          test_trap (stride, N);
          test_float_trap (stride, N);
          test_long_double_trap (stride, N);
          test_ulong_trap (stride, N);
          test_long_trap (stride, N);
          test_uint_trap (stride, N);
          test_int_trap (stride, N);
          test_ushort_trap (stride, N);
          test_short_trap (stride, N);
          test_uchar_trap (stride, N);
          test_char_trap (stride, N);
          test_complex_trap (stride, N);
          test_complex_float_trap (stride, N);
          test_complex_long_double_trap (stride, N);
        }
    }
#endif

  exit (gsl_test_summary ());
}
void test_vector() {
    test_ops();
}
Exemple #11
0
void memory_tests (cholmod_triplet *T)
{
    double err ;
    cholmod_sparse *A ;
    Int trial ;
    size_t count, inuse ;

    test_memory_handler ( ) ;
    inuse = cm->memory_inuse ;

    cm->nmethods = 8 ;
    cm->print = 0 ;
    cm->final_resymbol = TRUE ;

    cm->final_asis = FALSE ;
    cm->final_super = FALSE ;
    cm->final_ll = FALSE ;
    cm->final_pack = FALSE ;
    cm->final_monotonic = FALSE ;

    /* ---------------------------------------------------------------------- */
    /* test raw factorizations */
    /* ---------------------------------------------------------------------- */

    printf ("==================================== fac memory test\n") ;
    count = cm->malloc_count ;
    my_tries = -1 ;
    for (trial = 0 ; my_tries <= 0 ; trial++)
    {
	cm->print = 0 ;
	fflush (stdout) ;
	my_tries = trial ;
	A = CHOLMOD(triplet_to_sparse) (T, 0, cm) ;
	my_srand (trial+1) ;					/* RAND reset */
	err = raw_factor (A, FALSE) ;				/* RAND */
	CHOLMOD(free_sparse) (&A, cm) ;
	OK (CHOLMOD(print_common) ("cm", cm)) ;
	CHOLMOD(free_work) (cm) ;
	OK (count == cm->malloc_count) ;
	OK (inuse == cm->memory_inuse) ;
    }
    CHOLMOD(free_work) (cm) ;
    printf ("memory test: fac error %.1g trials "ID"\n", err, trial) ;
    printf ("initial count: "ID" final count "ID"\n",
	    (Int) count, (Int) cm->malloc_count) ;
    printf ("initial inuse: "ID" final inuse "ID"\n",
	    (Int) inuse, (Int) cm->memory_inuse) ;
    OK (count == cm->malloc_count) ;
    OK (inuse == cm->memory_inuse) ;

    /* ---------------------------------------------------------------------- */
    /* test raw factorizations (rowfac_mask) */
    /* ---------------------------------------------------------------------- */

    printf ("==================================== fac memory test2\n") ;
    count = cm->malloc_count ;
    my_tries = -1 ;
    for (trial = 0 ; my_tries <= 0 ; trial++)
    {
	cm->print = 0 ;
	fflush (stdout) ;
	my_tries = trial ;
	A = CHOLMOD(triplet_to_sparse) (T, 0, cm) ;
	my_srand (trial+1) ;					/* RAND reset */
	err = raw_factor2 (A, 0., 0) ;				/* RAND */
	CHOLMOD(free_sparse) (&A, cm) ;
	OK (CHOLMOD(print_common) ("cm", cm)) ;
	CHOLMOD(free_work) (cm) ;
	OK (count == cm->malloc_count) ;
	OK (inuse == cm->memory_inuse) ;
    }
    CHOLMOD(free_work) (cm) ;
    printf ("memory test: fac error %.1g trials "ID"\n", err, trial) ;
    printf ("initial count: "ID" final count "ID"\n",
	    (Int) count, (Int) cm->malloc_count) ;
    printf ("initial inuse: "ID" final inuse "ID"\n",
	    (Int) inuse, (Int) cm->memory_inuse) ;
    OK (count == cm->malloc_count) ;
    OK (inuse == cm->memory_inuse) ;

    /* ---------------------------------------------------------------------- */
    /* test augmented system solver */
    /* ---------------------------------------------------------------------- */

    printf ("==================================== aug memory test\n") ;
    count = cm->malloc_count ;
    my_tries = -1 ;
    for (trial = 0 ; my_tries <= 0 ; trial++)
    {
	cm->print = 0 ;
	fflush (stdout) ;
	my_tries = trial ;
	A = CHOLMOD(triplet_to_sparse) (T, 0, cm) ;
	err = aug (A) ;				/* no random number use */
	CHOLMOD(free_sparse) (&A, cm) ;
	OK (CHOLMOD(print_common) ("cm", cm)) ;
	CHOLMOD(free_work) (cm) ;
	OK (count == cm->malloc_count) ;
	OK (inuse == cm->memory_inuse) ;
    }
    CHOLMOD(free_work) (cm) ;
    printf ("memory test: aug error %.1g trials "ID"\n", err, trial) ;
    printf ("initial count: "ID" final count "ID"\n",
	    (Int) count, (Int) cm->malloc_count) ;
    printf ("initial inuse: "ID" final inuse "ID"\n",
	    (Int) inuse, (Int) cm->memory_inuse) ;
    OK (count == cm->malloc_count) ;
    OK (inuse == cm->memory_inuse) ;

    /* ---------------------------------------------------------------------- */
    /* test ops */
    /* ---------------------------------------------------------------------- */

    printf ("==================================== test_ops memory test\n") ;
    count = cm->malloc_count ;
    my_tries = -1 ;
    for (trial = 0 ; my_tries <= 0 ; trial++)
    {
	cm->print = 0 ;
	fflush (stdout) ;
	my_tries = trial ;
	A = CHOLMOD(triplet_to_sparse) (T, 0, cm) ;
	my_srand (trial+1) ;					/* RAND reset */
	err = test_ops (A) ;					/* RAND */
	CHOLMOD(free_sparse) (&A, cm) ;
	OK (CHOLMOD(print_common) ("cm", cm)) ;
	CHOLMOD(free_work) (cm) ;
	printf ("inuse "ID" "ID"\n", inuse, cm->memory_inuse) ;
	OK (count == cm->malloc_count) ;
	OK (inuse == cm->memory_inuse) ;
    }
    printf ("memory test: testops error %.1g trials "ID"\n", err, trial) ;
    printf ("initial count: "ID" final count "ID"\n",
	    (Int) count, (Int) cm->malloc_count) ;
    printf ("initial inuse: "ID" final inuse "ID"\n",
	    (Int) inuse, (Int) cm->memory_inuse) ;
    OK (count == cm->malloc_count) ;
    OK (inuse == cm->memory_inuse) ;

    /* ---------------------------------------------------------------------- */
    /* test lpdemo */
    /* ---------------------------------------------------------------------- */

    if (T == NULL || T->nrow != T->ncol)
    {
	printf ("==================================== lpdemo memory test\n") ;
	count = cm->malloc_count ;
	my_tries = -1 ;
	for (trial = 0 ; my_tries <= 0 ; trial++)
	{
	    cm->print = 0 ;
	    fflush (stdout) ;
	    my_tries = trial ;
	    my_srand (trial+1) ;				/* RAND reset */
	    err = lpdemo (T) ;					/* RAND */
	    OK (CHOLMOD(print_common) ("cm", cm)) ;
	    CHOLMOD(free_work) (cm) ;
	    OK (count == cm->malloc_count) ;
	    OK (inuse == cm->memory_inuse) ;
	}
	CHOLMOD(free_work) (cm) ;
	printf ("memory test: lpdemo error %.1g trials "ID"\n", err, trial) ;
	printf ("initial count: "ID" final count "ID"\n",
	    (Int) count, (Int) cm->malloc_count) ;
	printf ("initial inuse: "ID" final inuse "ID"\n",
	    (Int) inuse, (Int) cm->memory_inuse) ;
	OK (count == cm->malloc_count) ;
	OK (inuse == cm->memory_inuse) ;
    }

    /* ---------------------------------------------------------------------- */
    /* test solver */
    /* ---------------------------------------------------------------------- */

    printf ("==================================== solve memory test\n") ;
    count = cm->malloc_count ;
    my_tries = -1 ;
    for (trial = 0 ; my_tries <= 0 ; trial++)
    {
	CHOLMOD(defaults) (cm) ;
	cm->supernodal = CHOLMOD_SUPERNODAL ;
	cm->metis_memory = 2.0 ;
	cm->nmethods = 4 ;
	cm->print = 0 ;
	fflush (stdout) ;
	my_tries = trial ;
	A = CHOLMOD(triplet_to_sparse) (T, 0, cm) ;
	my_srand (trial+1) ;					/* RAND reset */
	err = solve (A) ;					/* RAND */
	CHOLMOD(free_sparse) (&A, cm) ;
	OK (CHOLMOD(print_common) ("cm", cm)) ;
	CHOLMOD(free_work) (cm) ;
	OK (count == cm->malloc_count) ;
	OK (inuse == cm->memory_inuse) ;
    }
    CHOLMOD(free_work) (cm) ;
    printf ("memory test: solve error %.1g trials "ID"\n", err, trial) ;
    printf ("initial count: "ID" final count "ID"\n",
	    (Int) count, (Int) cm->malloc_count) ;
    printf ("initial inuse: "ID" final inuse "ID"\n",
	    (Int) inuse, (Int) cm->memory_inuse) ;
    OK (count == cm->malloc_count) ;
    OK (inuse == cm->memory_inuse) ;
    cm->supernodal = CHOLMOD_AUTO ;
    progress (1, '|') ;

    /* ---------------------------------------------------------------------- */
    /* restore original memory handler */
    /* ---------------------------------------------------------------------- */

    normal_memory_handler ( ) ;
    cm->print = 1 ;

    printf ("All memory tests OK, no error\n") ;
}
void second_refresh_cache_prefetch(void)
{
	setup_ops();
	test_ops();
	m_ops->cache_prefetch();
}