Blame matrix/test.c

Packit 67cb25
/* matrix/test.c
Packit 67cb25
 * 
Packit 67cb25
 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
Packit 67cb25
 * 
Packit 67cb25
 * This program is free software; you can redistribute it and/or modify
Packit 67cb25
 * it under the terms of the GNU General Public License as published by
Packit 67cb25
 * the Free Software Foundation; either version 3 of the License, or (at
Packit 67cb25
 * your option) any later version.
Packit 67cb25
 * 
Packit 67cb25
 * This program is distributed in the hope that it will be useful, but
Packit 67cb25
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 67cb25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 67cb25
 * General Public License for more details.
Packit 67cb25
 * 
Packit 67cb25
 * You should have received a copy of the GNU General Public License
Packit 67cb25
 * along with this program; if not, write to the Free Software
Packit 67cb25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 67cb25
 */
Packit 67cb25
Packit 67cb25
#include <config.h>
Packit 67cb25
Packit 67cb25
#if defined( _MSC_VER ) && defined( GSL_DLL )
Packit 67cb25
#undef inline
Packit 67cb25
#define inline __forceinline 
Packit 67cb25
#endif
Packit 67cb25
#if (!GSL_RANGE_CHECK) && defined(HAVE_INLINE)
Packit 67cb25
#undef GSL_RANGE_CHECK
Packit 67cb25
#define GSL_RANGE_CHECK 1
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
#include <stdlib.h>
Packit 67cb25
#include <stdio.h>
Packit 67cb25
#include <unistd.h>
Packit 67cb25
#include <math.h>
Packit 67cb25
#include <gsl/gsl_math.h>
Packit 67cb25
#include <gsl/gsl_matrix.h>
Packit 67cb25
#include <gsl/gsl_test.h>
Packit 67cb25
#include <gsl/gsl_ieee_utils.h>
Packit 67cb25
Packit 67cb25
int status = 0;
Packit 67cb25
Packit 67cb25
#ifndef DESC
Packit 67cb25
#define DESC ""
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
#define BASE_GSL_COMPLEX_LONG
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_complex_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_GSL_COMPLEX_LONG
Packit 67cb25
Packit 67cb25
#define BASE_GSL_COMPLEX
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_complex_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_GSL_COMPLEX
Packit 67cb25
Packit 67cb25
#define BASE_GSL_COMPLEX_FLOAT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_complex_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_GSL_COMPLEX_FLOAT
Packit 67cb25
Packit 67cb25
#define BASE_LONG_DOUBLE
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_LONG_DOUBLE
Packit 67cb25
Packit 67cb25
#define BASE_DOUBLE
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_DOUBLE
Packit 67cb25
Packit 67cb25
#define BASE_FLOAT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_FLOAT
Packit 67cb25
Packit 67cb25
#define BASE_ULONG
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_ULONG
Packit 67cb25
Packit 67cb25
#define BASE_LONG
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_LONG
Packit 67cb25
Packit 67cb25
#define BASE_UINT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_UINT
Packit 67cb25
Packit 67cb25
#define BASE_INT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_INT
Packit 67cb25
Packit 67cb25
#define BASE_USHORT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_USHORT
Packit 67cb25
Packit 67cb25
#define BASE_SHORT
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_SHORT
Packit 67cb25
Packit 67cb25
#define BASE_UCHAR
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_UCHAR
Packit 67cb25
Packit 67cb25
#define BASE_CHAR
Packit 67cb25
#include "templates_on.h"
Packit 67cb25
#include "test_source.c"
Packit 67cb25
#include "templates_off.h"
Packit 67cb25
#undef  BASE_CHAR
Packit 67cb25
Packit 67cb25
void my_error_handler (const char *reason, const char *file,
Packit 67cb25
                       int line, int err);
Packit 67cb25
Packit 67cb25
int
Packit 67cb25
main (void)
Packit 67cb25
{
Packit 67cb25
  size_t M = 53;
Packit 67cb25
  size_t N = 107;
Packit 67cb25
Packit 67cb25
  gsl_ieee_env_setup ();
Packit 67cb25
Packit 67cb25
  test_func (M, N);
Packit 67cb25
  test_float_func (M, N);
Packit 67cb25
  test_long_double_func (M, N);
Packit 67cb25
  test_ulong_func (M, N);
Packit 67cb25
  test_long_func (M, N);
Packit 67cb25
  test_uint_func (M, N);
Packit 67cb25
  test_int_func (M, N);
Packit 67cb25
  test_ushort_func (M, N);
Packit 67cb25
  test_short_func (M, N);
Packit 67cb25
  test_uchar_func (M, N);
Packit 67cb25
  test_char_func (M, N);
Packit 67cb25
  test_complex_func (M, N);
Packit 67cb25
  test_complex_float_func (M, N);
Packit 67cb25
  test_complex_long_double_func (M, N);
Packit 67cb25
Packit 67cb25
  test_ops (M, N);
Packit 67cb25
  test_float_ops (M, N);
Packit 67cb25
  test_long_double_ops (M, N);
Packit 67cb25
  test_ulong_ops (M, N);
Packit 67cb25
  test_long_ops (M, N);
Packit 67cb25
  test_uint_ops (M, N);
Packit 67cb25
  test_int_ops (M, N);
Packit 67cb25
  test_ushort_ops (M, N);
Packit 67cb25
  test_short_ops (M, N);
Packit 67cb25
  test_uchar_ops (M, N);
Packit 67cb25
  test_char_ops (M, N);
Packit 67cb25
Packit 67cb25
  /* Must use smaller dimensions to prevent approximation of floats in
Packit 67cb25
     float_mul_elements test*/
Packit 67cb25
  
Packit 67cb25
  {
Packit 67cb25
    const size_t P = 8;
Packit 67cb25
    const size_t Q = 12;
Packit 67cb25
Packit 67cb25
    test_complex_ops (P, Q);
Packit 67cb25
    test_complex_float_ops (P, Q);
Packit 67cb25
    test_complex_long_double_ops (P, Q);
Packit 67cb25
  }
Packit 67cb25
Packit 67cb25
  test_text (M, N);
Packit 67cb25
  test_float_text (M, N);
Packit 67cb25
#if HAVE_PRINTF_LONGDOUBLE
Packit 67cb25
  test_long_double_text (M, N);
Packit 67cb25
#endif
Packit 67cb25
  test_ulong_text (M, N);
Packit 67cb25
  test_long_text (M, N);
Packit 67cb25
  test_uint_text (M, N);
Packit 67cb25
  test_int_text (M, N);
Packit 67cb25
  test_ushort_text (M, N);
Packit 67cb25
  test_short_text (M, N);
Packit 67cb25
  test_uchar_text (M, N);
Packit 67cb25
  test_char_text (M, N);
Packit 67cb25
  test_complex_text (M, N);
Packit 67cb25
  test_complex_float_text (M, N);
Packit 67cb25
#if HAVE_PRINTF_LONGDOUBLE
Packit 67cb25
  test_complex_long_double_text (M, N);
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
  test_binary (M, N);
Packit 67cb25
  test_float_binary (M, N);
Packit 67cb25
  test_long_double_binary (M, N);
Packit 67cb25
  test_ulong_binary (M, N);
Packit 67cb25
  test_long_binary (M, N);
Packit 67cb25
  test_uint_binary (M, N);
Packit 67cb25
  test_int_binary (M, N);
Packit 67cb25
  test_ushort_binary (M, N);
Packit 67cb25
  test_short_binary (M, N);
Packit 67cb25
  test_uchar_binary (M, N);
Packit 67cb25
  test_char_binary (M, N);
Packit 67cb25
  test_complex_binary (M, N);
Packit 67cb25
  test_complex_float_binary (M, N);
Packit 67cb25
  test_complex_long_double_binary (M, N);
Packit 67cb25
Packit 67cb25
  test_binary_noncontiguous (M, N);
Packit 67cb25
  test_float_binary_noncontiguous (M, N);
Packit 67cb25
  test_long_double_binary_noncontiguous (M, N);
Packit 67cb25
  test_ulong_binary_noncontiguous (M, N);
Packit 67cb25
  test_long_binary_noncontiguous (M, N);
Packit 67cb25
  test_uint_binary_noncontiguous (M, N);
Packit 67cb25
  test_int_binary_noncontiguous (M, N);
Packit 67cb25
  test_ushort_binary_noncontiguous (M, N);
Packit 67cb25
  test_short_binary_noncontiguous (M, N);
Packit 67cb25
  test_uchar_binary_noncontiguous (M, N);
Packit 67cb25
  test_char_binary_noncontiguous (M, N);
Packit 67cb25
  test_complex_binary_noncontiguous (M, N);
Packit 67cb25
  test_complex_float_binary_noncontiguous (M, N);
Packit 67cb25
  test_complex_long_double_binary_noncontiguous (M, N);
Packit 67cb25
Packit 67cb25
#if GSL_RANGE_CHECK
Packit 67cb25
  gsl_set_error_handler (&my_error_handler);
Packit 67cb25
Packit 67cb25
  test_trap (M, N);
Packit 67cb25
  test_float_trap (M, N);
Packit 67cb25
  test_long_double_trap (M, N);
Packit 67cb25
  test_ulong_trap (M, N);
Packit 67cb25
  test_long_trap (M, N);
Packit 67cb25
  test_uint_trap (M, N);
Packit 67cb25
  test_int_trap (M, N);
Packit 67cb25
  test_ushort_trap (M, N);
Packit 67cb25
  test_short_trap (M, N);
Packit 67cb25
  test_uchar_trap (M, N);
Packit 67cb25
  test_char_trap (M, N);
Packit 67cb25
  test_complex_trap (M, N);
Packit 67cb25
  test_complex_float_trap (M, N);
Packit 67cb25
  test_complex_long_double_trap (M, N);
Packit 67cb25
#endif
Packit 67cb25
Packit 67cb25
  exit (gsl_test_summary ());
Packit 67cb25
}
Packit 67cb25
Packit 67cb25
void
Packit 67cb25
my_error_handler (const char *reason, const char *file, int line, int err)
Packit 67cb25
{
Packit 67cb25
  if (0)
Packit 67cb25
    printf ("(caught [%s:%d: %s (%d)])\n", file, line, reason, err);
Packit 67cb25
  status = 1;
Packit 67cb25
}