LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
dlange_rowmajor_inconsistent.patch
Go to the documentation of this file.
1 Description: Dlange gives inconsistent/incorrect results for RowMajor (upstream bug #137)
2 Origin: backport, commit: r1602
3 Bug: https://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=13&t=4789&p=0#p0
4 Reviewed-by: Sébastien Villemot <sebastien@debian.org>
5 Last-Update: 2015-10-31
6 ---
7 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
8 --- a/lapacke/src/lapacke_clantr.c
9 +++ b/lapacke/src/lapacke_clantr.c
10 @@ -53,7 +53,7 @@ float LAPACKE_clantr( int matrix_order,
11  /* Allocate memory for working array(s) */
12  if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
13  LAPACKE_lsame( norm, 'O' ) ) {
14 - work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
15 + work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,MAX(m,n)) );
16  if( work == NULL ) {
17  info = LAPACK_WORK_MEMORY_ERROR;
18  goto exit_level_0;
19 --- a/lapacke/src/lapacke_clantr_work.c
20 +++ b/lapacke/src/lapacke_clantr_work.c
21 @@ -47,7 +47,7 @@ float LAPACKE_clantr_work( int matrix_or
22  info = info - 1;
23  }
24  } else if( matrix_order == LAPACK_ROW_MAJOR ) {
25 - lapack_int lda_t = MAX(1,n);
26 + lapack_int lda_t = MAX(1,m);
27  lapack_complex_float* a_t = NULL;
28  /* Check leading dimension(s) */
29  if( lda < n ) {
30 @@ -57,13 +57,13 @@ float LAPACKE_clantr_work( int matrix_or
31  }
32  /* Allocate memory for temporary array(s) */
33  a_t = (lapack_complex_float*)
34 - LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) );
35 + LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,MAX(m,n)) );
36  if( a_t == NULL ) {
37  info = LAPACK_TRANSPOSE_MEMORY_ERROR;
38  goto exit_level_0;
39  }
40  /* Transpose input matrices */
41 - LAPACKE_ctr_trans( matrix_order, uplo, diag, n, a, lda, a_t, lda_t );
42 + LAPACKE_ctr_trans( matrix_order, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
43  /* Call LAPACK function and adjust info */
44  res = LAPACK_clantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
45  info = 0; /* LAPACK call is ok! */
46 --- a/lapacke/src/lapacke_dlantr.c
47 +++ b/lapacke/src/lapacke_dlantr.c
48 @@ -53,7 +53,7 @@ double LAPACKE_dlantr( int matrix_order,
49  /* Allocate memory for working array(s) */
50  if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
51  LAPACKE_lsame( norm, 'O' ) ) {
52 - work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
53 + work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,MAX(m,n)) );
54  if( work == NULL ) {
55  info = LAPACK_WORK_MEMORY_ERROR;
56  goto exit_level_0;
57 --- a/lapacke/src/lapacke_dlantr_work.c
58 +++ b/lapacke/src/lapacke_dlantr_work.c
59 @@ -46,7 +46,7 @@ double LAPACKE_dlantr_work( int matrix_o
60  info = info - 1;
61  }
62  } else if( matrix_order == LAPACK_ROW_MAJOR ) {
63 - lapack_int lda_t = MAX(1,n);
64 + lapack_int lda_t = MAX(1,m);
65  double* a_t = NULL;
66  /* Check leading dimension(s) */
67  if( lda < n ) {
68 @@ -55,13 +55,13 @@ double LAPACKE_dlantr_work( int matrix_o
69  return info;
70  }
71  /* Allocate memory for temporary array(s) */
72 - a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
73 + a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,MAX(m,n)) );
74  if( a_t == NULL ) {
75  info = LAPACK_TRANSPOSE_MEMORY_ERROR;
76  goto exit_level_0;
77  }
78  /* Transpose input matrices */
79 - LAPACKE_dtr_trans( matrix_order, uplo, diag, n, a, lda, a_t, lda_t );
80 + LAPACKE_dtr_trans( matrix_order, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
81  /* Call LAPACK function and adjust info */
82  res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
83  info = 0; /* LAPACK call is ok! */
84 --- a/lapacke/src/lapacke_slantr.c
85 +++ b/lapacke/src/lapacke_slantr.c
86 @@ -53,7 +53,7 @@ float LAPACKE_slantr( int matrix_order,
87  /* Allocate memory for working array(s) */
88  if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
89  LAPACKE_lsame( norm, 'O' ) ) {
90 - work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,m) );
91 + work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,MAX(m,n)) );
92  if( work == NULL ) {
93  info = LAPACK_WORK_MEMORY_ERROR;
94  goto exit_level_0;
95 --- a/lapacke/src/lapacke_slantr_work.c
96 +++ b/lapacke/src/lapacke_slantr_work.c
97 @@ -46,7 +46,7 @@ float LAPACKE_slantr_work( int matrix_or
98  info = info - 1;
99  }
100  } else if( matrix_order == LAPACK_ROW_MAJOR ) {
101 - lapack_int lda_t = MAX(1,n);
102 + lapack_int lda_t = MAX(1,m);
103  float* a_t = NULL;
104  /* Check leading dimension(s) */
105  if( lda < n ) {
106 @@ -55,13 +55,13 @@ float LAPACKE_slantr_work( int matrix_or
107  return info;
108  }
109  /* Allocate memory for temporary array(s) */
110 - a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
111 + a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,MAX(m,n)) );
112  if( a_t == NULL ) {
113  info = LAPACK_TRANSPOSE_MEMORY_ERROR;
114  goto exit_level_0;
115  }
116  /* Transpose input matrices */
117 - LAPACKE_str_trans( matrix_order, uplo, diag, n, a, lda, a_t, lda_t );
118 + LAPACKE_str_trans( matrix_order, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
119  /* Call LAPACK function and adjust info */
120  res = LAPACK_slantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
121  info = 0; /* LAPACK call is ok! */
122 --- a/lapacke/src/lapacke_zlantr.c
123 +++ b/lapacke/src/lapacke_zlantr.c
124 @@ -53,7 +53,7 @@ double LAPACKE_zlantr( int matrix_order,
125  /* Allocate memory for working array(s) */
126  if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
127  LAPACKE_lsame( norm, 'O' ) ) {
128 - work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
129 + work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,MAX(m,n)) );
130  if( work == NULL ) {
131  info = LAPACK_WORK_MEMORY_ERROR;
132  goto exit_level_0;
133 --- a/lapacke/src/lapacke_zlantr_work.c
134 +++ b/lapacke/src/lapacke_zlantr_work.c
135 @@ -47,7 +47,7 @@ double LAPACKE_zlantr_work( int matrix_o
136  info = info - 1;
137  }
138  } else if( matrix_order == LAPACK_ROW_MAJOR ) {
139 - lapack_int lda_t = MAX(1,n);
140 + lapack_int lda_t = MAX(1,m);
141  lapack_complex_double* a_t = NULL;
142  /* Check leading dimension(s) */
143  if( lda < n ) {
144 @@ -57,13 +57,13 @@ double LAPACKE_zlantr_work( int matrix_o
145  }
146  /* Allocate memory for temporary array(s) */
147  a_t = (lapack_complex_double*)
148 - LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
149 + LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,MAX(m,n)) );
150  if( a_t == NULL ) {
151  info = LAPACK_TRANSPOSE_MEMORY_ERROR;
152  goto exit_level_0;
153  }
154  /* Transpose input matrices */
155 - LAPACKE_ztr_trans( matrix_order, uplo, diag, n, a, lda, a_t, lda_t );
156 + LAPACKE_ztr_trans( matrix_order, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
157  /* Call LAPACK function and adjust info */
158  res = LAPACK_zlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
159  info = 0; /* LAPACK call is ok! */