Statistiques
| Révision :

root / testing / matgen / HPL_dmatgen.c

Historique | Voir | Annoter | Télécharger (5,64 ko)

1
/* 
2
 * -- High Performance Computing Linpack Benchmark (HPL)                
3
 *    HPL - 2.0 - September 10, 2008                          
4
 *    Antoine P. Petitet                                                
5
 *    University of Tennessee, Knoxville                                
6
 *    Innovative Computing Laboratory                                 
7
 *    (C) Copyright 2000-2008 All Rights Reserved                       
8
 *                                                                      
9
 * -- Copyright notice and Licensing terms:                             
10
 *                                                                      
11
 * Redistribution  and  use in  source and binary forms, with or without
12
 * modification, are  permitted provided  that the following  conditions
13
 * are met:                                                             
14
 *                                                                      
15
 * 1. Redistributions  of  source  code  must retain the above copyright
16
 * notice, this list of conditions and the following disclaimer.        
17
 *                                                                      
18
 * 2. Redistributions in binary form must reproduce  the above copyright
19
 * notice, this list of conditions,  and the following disclaimer in the
20
 * documentation and/or other materials provided with the distribution. 
21
 *                                                                      
22
 * 3. All  advertising  materials  mentioning  features  or  use of this
23
 * software must display the following acknowledgement:                 
24
 * This  product  includes  software  developed  at  the  University  of
25
 * Tennessee, Knoxville, Innovative Computing Laboratory.             
26
 *                                                                      
27
 * 4. The name of the  University,  the name of the  Laboratory,  or the
28
 * names  of  its  contributors  may  not  be used to endorse or promote
29
 * products  derived   from   this  software  without  specific  written
30
 * permission.                                                          
31
 *                                                                      
32
 * -- Disclaimer:                                                       
33
 *                                                                      
34
 * THIS  SOFTWARE  IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT
36
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
38
 * OR  CONTRIBUTORS  BE  LIABLE FOR ANY  DIRECT,  INDIRECT,  INCIDENTAL,
39
 * SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES  (INCLUDING,  BUT NOT
40
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41
 * DATA OR PROFITS; OR BUSINESS INTERRUPTION)  HOWEVER CAUSED AND ON ANY
42
 * THEORY OF LIABILITY, WHETHER IN CONTRACT,  STRICT LIABILITY,  OR TORT
43
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
45
 * ---------------------------------------------------------------------
46
 */ 
47
/*
48
 * Include files
49
 */
50
#include "hpl.h"
51

    
52
#ifdef STDC_HEADERS
53
void HPL_dmatgen
54
(
55
   const int                        M,
56
   const int                        N,
57
   double *                         A,
58
   const int                        LDA,
59
   const int                        ISEED
60
)
61
#else
62
void HPL_dmatgen
63
( M, N, A, LDA, ISEED )
64
   const int                        M;
65
   const int                        N;
66
   double *                         A;
67
   const int                        LDA;
68
   const int                        ISEED;
69
#endif
70
{
71
/* 
72
 * Purpose
73
 * =======
74
 *
75
 * HPL_dmatgen generates (or regenerates) a random matrix A.
76
 *  
77
 * The  pseudo-random  generator uses the linear congruential algorithm:
78
 * X(n+1) = (a * X(n) + c) mod m  as  described  in the  Art of Computer
79
 * Programming, Knuth 1973, Vol. 2.
80
 *
81
 * Arguments
82
 * =========
83
 *
84
 * M       (input)                       const int
85
 *         On entry,  M  specifies  the number  of rows of the matrix A.
86
 *         M must be at least zero.
87
 *
88
 * N       (input)                       const int
89
 *         On entry,  N specifies the number of columns of the matrix A.
90
 *         N must be at least zero.
91
 *
92
 * A       (output)                      double *
93
 *         On entry, A points to an array of dimension (LDA,N). On exit,
94
 *         this  array  contains   the   coefficients  of  the  randomly
95
 *         generated matrix.
96
 *
97
 * LDA     (input)                       const int
98
 *         On entry, LDA specifies the leading dimension of the array A.
99
 *         LDA must be at least max(1,M).
100
 *
101
 * ISEED   (input)                       const int
102
 *         On entry, ISEED  specifies  the  seed  number to generate the
103
 *         matrix A. ISEED must be at least zero.
104
 *
105
 * ---------------------------------------------------------------------
106
 */ 
107
/*
108
 * .. Local Variables ..
109
 */
110
   int                        iadd[2], ia1[2], ic1[2], iran1[2],
111
                              jseed[2], mult[2];
112
   int                        i, incA = LDA - M, j;
113
/* ..
114
 * .. Executable Statements ..
115
 */
116
   if( ( M <= 0 ) || ( N <= 0 ) ) return;
117
/*
118
 * Initialize the random sequence
119
 */
120
   mult [0] = HPL_MULT0; mult [1] = HPL_MULT1;
121
   iadd [0] = HPL_IADD0; iadd [1] = HPL_IADD1;
122
   jseed[0] = ISEED;     jseed[1] = 0;
123

    
124
   HPL_xjumpm( 1, mult, iadd, jseed, iran1, ia1, ic1 );
125
   HPL_setran( 0, iran1 ); HPL_setran( 1, ia1 ); HPL_setran( 2, ic1 );
126
/*
127
 * Generate an M by N matrix
128
 */
129
   for( j = 0; j < N; A += incA, j++ )
130
      for( i = 0; i < M; A++, i++ ) *A = HPL_rand();
131
/*
132
 * End of HPL_dmatgen
133
 */
134
}