Skip to content

Commit 4f10899

Browse files
authored
Add interfaces for [cz]unhr_col and [sd]orhr_col (Reference-LAPACK PR 827)
1 parent bc967e7 commit 4f10899

File tree

8 files changed

+372
-0
lines changed

8 files changed

+372
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_cunhr_col( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, lapack_complex_float* a,
5+
lapack_int lda, lapack_complex_float* t,
6+
lapack_int ldt, lapack_complex_float* d)
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
10+
LAPACKE_xerbla( "LAPACKE_cunhr_col", -1 );
11+
return -1;
12+
}
13+
#ifndef LAPACK_DISABLE_NAN_CHECK
14+
if( LAPACKE_get_nancheck() ) {
15+
/* Optionally check input matrices for NaNs */
16+
if( LAPACKE_cge_nancheck( matrix_layout, m, n, a, lda ) ) {
17+
return -5;
18+
}
19+
}
20+
#endif
21+
/* Call middle-level interface */
22+
info = LAPACKE_cunhr_col_work( matrix_layout, m, n, nb, a, lda, t, ldt, d );
23+
return info;
24+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_cunhr_col_work( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, lapack_complex_float* a,
5+
lapack_int lda, lapack_complex_float* t,
6+
lapack_int ldt, lapack_complex_float* d )
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout == LAPACK_COL_MAJOR ) {
10+
/* Call LAPACK function and adjust info */
11+
LAPACK_cunhr_col( &m, &n, &nb, a, &lda, t, &ldt, d, &info );
12+
if( info < 0 ) {
13+
info = info - 1;
14+
}
15+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
16+
lapack_int lda_t = MAX(1,m);
17+
lapack_int ldt_t = MAX(1,MIN(nb,n));
18+
lapack_complex_float* a_t = NULL;
19+
lapack_complex_float* t_t = NULL;
20+
/* Check leading dimension(s) */
21+
if( lda < n ) {
22+
info = -6;
23+
LAPACKE_xerbla( "LAPACKE_cunhr_col_work", info );
24+
return info;
25+
}
26+
if( ldt < n ) {
27+
info = -8;
28+
LAPACKE_xerbla( "LAPACKE_cunhr_col_work", info );
29+
return info;
30+
}
31+
/* Allocate memory for temporary array(s) */
32+
a_t = (lapack_complex_float*)
33+
LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) );
34+
if( a_t == NULL ) {
35+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
36+
goto exit_level_0;
37+
}
38+
t_t = (lapack_complex_float*)
39+
LAPACKE_malloc( sizeof(lapack_complex_float) *
40+
ldt_t * MAX(1,n) );
41+
if( t_t == NULL ) {
42+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
43+
goto exit_level_1;
44+
}
45+
/* Transpose input matrices */
46+
LAPACKE_cge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
47+
/* Call LAPACK function and adjust info */
48+
LAPACK_cunhr_col( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, d, &info );
49+
if( info < 0 ) {
50+
info = info - 1;
51+
}
52+
/* Transpose output matrices */
53+
LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
54+
LAPACKE_cge_trans( LAPACK_COL_MAJOR, ldt, n, t_t, ldt_t, t,
55+
ldt );
56+
/* Release memory and exit */
57+
LAPACKE_free( t_t );
58+
exit_level_1:
59+
LAPACKE_free( a_t );
60+
exit_level_0:
61+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
62+
LAPACKE_xerbla( "LAPACKE_cunhr_col_work", info );
63+
}
64+
} else {
65+
info = -1;
66+
LAPACKE_xerbla( "LAPACKE_cunhr_col_work", info );
67+
}
68+
return info;
69+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_dorhr_col( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, double* a,
5+
lapack_int lda, double* t,
6+
lapack_int ldt, double* d)
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
10+
LAPACKE_xerbla( "LAPACKE_dorhr_col", -1 );
11+
return -1;
12+
}
13+
#ifndef LAPACK_DISABLE_NAN_CHECK
14+
if( LAPACKE_get_nancheck() ) {
15+
/* Optionally check input matrices for NaNs */
16+
if( LAPACKE_dge_nancheck( matrix_layout, m, n, a, lda ) ) {
17+
return -5;
18+
}
19+
}
20+
#endif
21+
/* Call middle-level interface */
22+
info = LAPACKE_dorhr_col_work( matrix_layout, m, n, nb, a, lda, t, ldt, d );
23+
return info;
24+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_dorhr_col_work( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, double* a,
5+
lapack_int lda, double* t,
6+
lapack_int ldt, double* d )
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout == LAPACK_COL_MAJOR ) {
10+
/* Call LAPACK function and adjust info */
11+
LAPACK_dorhr_col( &m, &n, &nb, a, &lda, t, &ldt, d, &info );
12+
if( info < 0 ) {
13+
info = info - 1;
14+
}
15+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
16+
lapack_int lda_t = MAX(1,m);
17+
lapack_int ldt_t = MAX(1,MIN(nb,n));
18+
double* a_t = NULL;
19+
double* t_t = NULL;
20+
/* Check leading dimension(s) */
21+
if( lda < n ) {
22+
info = -6;
23+
LAPACKE_xerbla( "LAPACKE_dorhr_col_work", info );
24+
return info;
25+
}
26+
if( ldt < n ) {
27+
info = -8;
28+
LAPACKE_xerbla( "LAPACKE_dorhr_col_work", info );
29+
return info;
30+
}
31+
/* Allocate memory for temporary array(s) */
32+
a_t = (double*)
33+
LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
34+
if( a_t == NULL ) {
35+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
36+
goto exit_level_0;
37+
}
38+
t_t = (double*)
39+
LAPACKE_malloc( sizeof(double) *
40+
ldt_t * MAX(1,n) );
41+
if( t_t == NULL ) {
42+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
43+
goto exit_level_1;
44+
}
45+
/* Transpose input matrices */
46+
LAPACKE_dge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
47+
/* Call LAPACK function and adjust info */
48+
LAPACK_dorhr_col( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, d, &info );
49+
if( info < 0 ) {
50+
info = info - 1;
51+
}
52+
/* Transpose output matrices */
53+
LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
54+
LAPACKE_dge_trans( LAPACK_COL_MAJOR, ldt, n, t_t, ldt_t, t,
55+
ldt );
56+
/* Release memory and exit */
57+
LAPACKE_free( t_t );
58+
exit_level_1:
59+
LAPACKE_free( a_t );
60+
exit_level_0:
61+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
62+
LAPACKE_xerbla( "LAPACKE_dorhr_col_work", info );
63+
}
64+
} else {
65+
info = -1;
66+
LAPACKE_xerbla( "LAPACKE_dorhr_col_work", info );
67+
}
68+
return info;
69+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_sorhr_col( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, float* a,
5+
lapack_int lda, float* t,
6+
lapack_int ldt, float* d)
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
10+
LAPACKE_xerbla( "LAPACKE_sorhr_col", -1 );
11+
return -1;
12+
}
13+
#ifndef LAPACK_DISABLE_NAN_CHECK
14+
if( LAPACKE_get_nancheck() ) {
15+
/* Optionally check input matrices for NaNs */
16+
if( LAPACKE_sge_nancheck( matrix_layout, m, n, a, lda ) ) {
17+
return -5;
18+
}
19+
}
20+
#endif
21+
/* Call middle-level interface */
22+
info = LAPACKE_sorhr_col_work( matrix_layout, m, n, nb, a, lda, t, ldt, d );
23+
return info;
24+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_sorhr_col_work( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, float* a,
5+
lapack_int lda, float* t,
6+
lapack_int ldt, float* d )
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout == LAPACK_COL_MAJOR ) {
10+
/* Call LAPACK function and adjust info */
11+
LAPACK_sorhr_col( &m, &n, &nb, a, &lda, t, &ldt, d, &info );
12+
if( info < 0 ) {
13+
info = info - 1;
14+
}
15+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
16+
lapack_int lda_t = MAX(1,m);
17+
lapack_int ldt_t = MAX(1,MIN(nb,n));
18+
float* a_t = NULL;
19+
float* t_t = NULL;
20+
/* Check leading dimension(s) */
21+
if( lda < n ) {
22+
info = -6;
23+
LAPACKE_xerbla( "LAPACKE_sorhr_col_work", info );
24+
return info;
25+
}
26+
if( ldt < n ) {
27+
info = -8;
28+
LAPACKE_xerbla( "LAPACKE_sorhr_col_work", info );
29+
return info;
30+
}
31+
/* Allocate memory for temporary array(s) */
32+
a_t = (float*)
33+
LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,n) );
34+
if( a_t == NULL ) {
35+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
36+
goto exit_level_0;
37+
}
38+
t_t = (float*)
39+
LAPACKE_malloc( sizeof(float) *
40+
ldt_t * MAX(1,n) );
41+
if( t_t == NULL ) {
42+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
43+
goto exit_level_1;
44+
}
45+
/* Transpose input matrices */
46+
LAPACKE_sge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
47+
/* Call LAPACK function and adjust info */
48+
LAPACK_sorhr_col( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, d, &info );
49+
if( info < 0 ) {
50+
info = info - 1;
51+
}
52+
/* Transpose output matrices */
53+
LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
54+
LAPACKE_sge_trans( LAPACK_COL_MAJOR, ldt, n, t_t, ldt_t, t,
55+
ldt );
56+
/* Release memory and exit */
57+
LAPACKE_free( t_t );
58+
exit_level_1:
59+
LAPACKE_free( a_t );
60+
exit_level_0:
61+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
62+
LAPACKE_xerbla( "LAPACKE_sorhr_col_work", info );
63+
}
64+
} else {
65+
info = -1;
66+
LAPACKE_xerbla( "LAPACKE_sorhr_col_work", info );
67+
}
68+
return info;
69+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_zunhr_col( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, lapack_complex_double* a,
5+
lapack_int lda, lapack_complex_double* t,
6+
lapack_int ldt, lapack_complex_double* d)
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
10+
LAPACKE_xerbla( "LAPACKE_zunhr_col", -1 );
11+
return -1;
12+
}
13+
#ifndef LAPACK_DISABLE_NAN_CHECK
14+
if( LAPACKE_get_nancheck() ) {
15+
/* Optionally check input matrices for NaNs */
16+
if( LAPACKE_zge_nancheck( matrix_layout, m, n, a, lda ) ) {
17+
return -5;
18+
}
19+
}
20+
#endif
21+
/* Call middle-level interface */
22+
info = LAPACKE_zunhr_col_work( matrix_layout, m, n, nb, a, lda, t, ldt, d );
23+
return info;
24+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_zunhr_col_work( int matrix_layout, lapack_int m, lapack_int n,
4+
lapack_int nb, lapack_complex_double* a,
5+
lapack_int lda, lapack_complex_double* t,
6+
lapack_int ldt, lapack_complex_double* d )
7+
{
8+
lapack_int info = 0;
9+
if( matrix_layout == LAPACK_COL_MAJOR ) {
10+
/* Call LAPACK function and adjust info */
11+
LAPACK_zunhr_col( &m, &n, &nb, a, &lda, t, &ldt, d, &info );
12+
if( info < 0 ) {
13+
info = info - 1;
14+
}
15+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
16+
lapack_int lda_t = MAX(1,m);
17+
lapack_int ldt_t = MAX(1,MIN(nb,n));
18+
lapack_complex_double* a_t = NULL;
19+
lapack_complex_double* t_t = NULL;
20+
/* Check leading dimension(s) */
21+
if( lda < n ) {
22+
info = -6;
23+
LAPACKE_xerbla( "LAPACKE_zunhr_col_work", info );
24+
return info;
25+
}
26+
if( ldt < n ) {
27+
info = -8;
28+
LAPACKE_xerbla( "LAPACKE_zunhr_col_work", info );
29+
return info;
30+
}
31+
/* Allocate memory for temporary array(s) */
32+
a_t = (lapack_complex_double*)
33+
LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
34+
if( a_t == NULL ) {
35+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
36+
goto exit_level_0;
37+
}
38+
t_t = (lapack_complex_double*)
39+
LAPACKE_malloc( sizeof(lapack_complex_double) *
40+
ldt_t * MAX(1,n) );
41+
if( t_t == NULL ) {
42+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
43+
goto exit_level_1;
44+
}
45+
/* Transpose input matrices */
46+
LAPACKE_zge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
47+
/* Call LAPACK function and adjust info */
48+
LAPACK_zunhr_col( &m, &n, &nb, a_t, &lda_t, t_t, &ldt_t, d, &info );
49+
if( info < 0 ) {
50+
info = info - 1;
51+
}
52+
/* Transpose output matrices */
53+
LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
54+
LAPACKE_zge_trans( LAPACK_COL_MAJOR, ldt, n, t_t, ldt_t, t,
55+
ldt );
56+
/* Release memory and exit */
57+
LAPACKE_free( t_t );
58+
exit_level_1:
59+
LAPACKE_free( a_t );
60+
exit_level_0:
61+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
62+
LAPACKE_xerbla( "LAPACKE_zunhr_col_work", info );
63+
}
64+
} else {
65+
info = -1;
66+
LAPACKE_xerbla( "LAPACKE_zunhr_col_work", info );
67+
}
68+
return info;
69+
}

0 commit comments

Comments
 (0)