test_gmath_lib.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*****************************************************************************
  2. *
  3. * MODULE: Grass gmath Library
  4. * AUTHOR(S): Soeren Gebbert, Berlin (GER) Oct 2007
  5. * soerengebbert <at> gmx <dot> de
  6. *
  7. * PURPOSE: Unit and Integration tests
  8. *
  9. * COPYRIGHT: (C) 2000 by the GRASS Development Team
  10. *
  11. * This program is free software under the GNU General Public
  12. * License (>=v2). Read the file COPYING that comes with GRASS
  13. * for details.
  14. *
  15. *****************************************************************************/
  16. #ifndef _TEST_GMATH_LIB_H_
  17. #define _TEST_GMATH_LIB_H_
  18. #include <grass/gmath.h>
  19. #include <grass/gis.h>
  20. #define TEST_NUM_ROWS 10
  21. #define TEST_NUM_COLS 9
  22. #define TEST_NUM_DEPTHS 8
  23. #define G_MATH_NORMAL_LES 0
  24. #define G_MATH_SPARSE_LES 1
  25. struct timeval;
  26. typedef struct
  27. {
  28. double *x; /*the value vector */
  29. double *b; /*the right side of Ax = b */
  30. double **A; /*the normal quadratic matrix */
  31. double *data; /*the pointer to the quadratic matrix data*/
  32. G_math_spvector **Asp; /*the sparse matrix */
  33. int rows; /*number of rows */
  34. int cols; /*number of cols */
  35. int quad; /*is the matrix quadratic (1-quadratic, 0 not)*/
  36. int type; /*the type of the les, normal == 0, sparse == 1 */
  37. int bandwidth; /*the bandwidth of the matrix (0 < bandwidth <= cols)*/
  38. int symm; /*0 if matrix unsymmetric, 1 if symmetric*/
  39. } G_math_les;
  40. typedef struct
  41. {
  42. float *x; /*the value vector */
  43. float *b; /*the right side of Ax = b */
  44. float **A; /*the normal quadratic matrix */
  45. float *data; /*the pointer to the quadratic matrix data*/
  46. int rows; /*number of rows */
  47. int cols; /*number of cols */
  48. int quad; /*is the matrix quadratic (1-quadratic, 0 not)*/
  49. int type; /*the type of the les, normal == 0, sparse == 1 */
  50. int bandwidth; /*the bandwidth of the matrix (0 < bandwidth <= cols)*/
  51. int symm; /*0 if matrix unsymmetric, 1 if symmetric*/
  52. } G_math_f_les;
  53. extern G_math_les *G_math_alloc_nquad_les(int cols, int rows, int type);
  54. extern G_math_les *G_math_alloc_nquad_les_Ax(int cols, int rows, int type);
  55. extern G_math_les *G_math_alloc_nquad_les_A(int cols, int rows, int type);
  56. extern G_math_les *G_math_alloc_nquad_les_Ax_b(int cols, int rows, int type);
  57. extern G_math_les *G_math_alloc_les(int rows, int type);
  58. extern G_math_les *G_math_alloc_les_Ax(int rows, int type);
  59. extern G_math_les *G_math_alloc_les_A(int rows, int type);
  60. extern G_math_les *G_math_alloc_les_Ax_b(int rows, int type);
  61. extern G_math_les *G_math_alloc_les_param(int cols, int rows, int type, int parts);
  62. extern int G_math_add_spvector_to_les(G_math_les * les, G_math_spvector * spvector, int row);
  63. extern void G_math_print_les(G_math_les * les);
  64. extern void G_math_free_les(G_math_les * les);
  65. extern void fill_d_vector_range_1(double *x, double a, int rows);
  66. extern void fill_f_vector_range_1(float *x, float a, int rows);
  67. extern void fill_i_vector_range_1(int *x, int a, int rows);
  68. extern void fill_d_vector_range_2(double *x, double a, int rows);
  69. extern void fill_f_vector_range_2(float *x, float a, int rows);
  70. extern void fill_i_vector_range_2(int *x, int a, int rows);
  71. extern void fill_d_vector_scalar(double *x, double a, int rows);
  72. extern void fill_f_vector_scalar(float *x, float a, int rows);
  73. extern void fill_i_vector_scalar(int *x, int a, int rows);
  74. extern G_math_les *create_normal_symmetric_les(int rows);
  75. extern G_math_les *create_symmetric_band_les(int rows);
  76. extern G_math_les *create_normal_symmetric_pivot_les(int rows);
  77. extern G_math_les *create_normal_unsymmetric_les(int rows);
  78. extern G_math_les *create_sparse_symmetric_les(int rows);
  79. extern G_math_les *create_sparse_unsymmetric_les(int rows);
  80. extern G_math_les *create_normal_unsymmetric_nquad_les_A(int rows, int cols);
  81. /*float*/
  82. extern G_math_f_les *G_math_alloc_f_les(int rows, int type);
  83. extern G_math_f_les *G_math_alloc_f_nquad_les_A(int rows, int cols, int type);
  84. extern G_math_f_les *G_math_alloc_f_les_param(int cols, int rows, int type, int parts);
  85. extern void G_math_free_f_les(G_math_f_les * les);
  86. extern G_math_f_les *create_normal_symmetric_f_les(int rows);
  87. extern G_math_f_les *create_normal_unsymmetric_f_les(int rows);
  88. extern G_math_f_les *create_normal_unsymmetric_f_nquad_les_A(int rows, int cols);
  89. /* direct and iterative solvers */
  90. extern int unit_test_solvers(void);
  91. /* Test the matrix conversion dense -> band ->sparse and vis versa */
  92. extern int unit_test_matrix_conversion(void);
  93. /* ccmath wrapper tests*/
  94. int unit_test_ccmath_wrapper(void);
  95. /* blas level 1 routines */
  96. extern int unit_test_blas_level_1(void);
  97. /* blas level 2 routines */
  98. extern int unit_test_blas_level_2(void);
  99. /* blas level 3 routines */
  100. extern int unit_test_blas_level_3(void);
  101. /* benchmarking iterative krylov solvers */
  102. extern int bench_solvers_krylov(int);
  103. /* benchmarking direct solvers */
  104. extern int bench_solvers_direct(int);
  105. /* benchmarking level 2 blas functions */
  106. int bench_blas_level_2(int rows);
  107. /* benchmarking level 3 blas functions */
  108. int bench_blas_level_3(int rows);
  109. /* Compute time difference */
  110. extern double compute_time_difference(struct timeval start, struct timeval end);
  111. #endif