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