Skip to content

Commit 46275f0

Browse files
committed
LAPACKE interface of [sd]trsyl3
1 parent 833cd58 commit 46275f0

12 files changed

+379
-5
lines changed

LAPACKE/include/lapack.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22002,6 +22002,46 @@ void LAPACK_ztrsyl_base(
2200222002
#define LAPACK_ztrsyl(...) LAPACK_ztrsyl_base(__VA_ARGS__)
2200322003
#endif
2200422004

22005+
#define LAPACK_dtrsyl3_base LAPACK_GLOBAL(dtrsyl3,DTRSYL3)
22006+
void LAPACK_dtrsyl3_base(
22007+
char const* trana, char const* tranb,
22008+
lapack_int const* isgn, lapack_int const* m, lapack_int const* n,
22009+
double const* A, lapack_int const* lda,
22010+
double const* B, lapack_int const* ldb,
22011+
double* C, lapack_int const* ldc, double* scale,
22012+
lapack_int* iwork, lapack_int const* liwork,
22013+
double* swork, lapack_int const *ldswork,
22014+
lapack_int* info
22015+
#ifdef LAPACK_FORTRAN_STRLEN_END
22016+
, size_t, size_t
22017+
#endif
22018+
);
22019+
#ifdef LAPACK_FORTRAN_STRLEN_END
22020+
#define LAPACK_dtrsyl3(...) LAPACK_dtrsyl3_base(__VA_ARGS__, 1, 1)
22021+
#else
22022+
#define LAPACK_dtrsyl3(...) LAPACK_dtrsyl3_base(__VA_ARGS__)
22023+
#endif
22024+
22025+
#define LAPACK_strsyl3_base LAPACK_GLOBAL(strsyl3,STRSYL3)
22026+
void LAPACK_strsyl3_base(
22027+
char const* trana, char const* tranb,
22028+
lapack_int const* isgn, lapack_int const* m, lapack_int const* n,
22029+
float const* A, lapack_int const* lda,
22030+
float const* B, lapack_int const* ldb,
22031+
float* C, lapack_int const* ldc, float* scale,
22032+
lapack_int* iwork, lapack_int const* liwork,
22033+
float* swork, lapack_int const *ldswork,
22034+
lapack_int* info
22035+
#ifdef LAPACK_FORTRAN_STRLEN_END
22036+
, size_t, size_t
22037+
#endif
22038+
);
22039+
#ifdef LAPACK_FORTRAN_STRLEN_END
22040+
#define LAPACK_strsyl3(...) LAPACK_strsyl3_base(__VA_ARGS__, 1, 1)
22041+
#else
22042+
#define LAPACK_strsyl3(...) LAPACK_strsyl3_base(__VA_ARGS__)
22043+
#endif
22044+
2200522045
#define LAPACK_ctrtri_base LAPACK_GLOBAL(ctrtri,CTRTRI)
2200622046
void LAPACK_ctrtri_base(
2200722047
char const* uplo, char const* diag,

LAPACKE/include/lapacke.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4477,6 +4477,17 @@ lapack_int LAPACKE_ztrsyl( int matrix_layout, char trana, char tranb,
44774477
lapack_complex_double* c, lapack_int ldc,
44784478
double* scale );
44794479

4480+
lapack_int LAPACKE_strsyl3( int matrix_layout, char trana, char tranb,
4481+
lapack_int isgn, lapack_int m, lapack_int n,
4482+
const float* a, lapack_int lda, const float* b,
4483+
lapack_int ldb, float* c, lapack_int ldc,
4484+
float* scale );
4485+
lapack_int LAPACKE_dtrsyl3( int matrix_layout, char trana, char tranb,
4486+
lapack_int isgn, lapack_int m, lapack_int n,
4487+
const double* a, lapack_int lda, const double* b,
4488+
lapack_int ldb, double* c, lapack_int ldc,
4489+
double* scale );
4490+
44804491
lapack_int LAPACKE_strtri( int matrix_layout, char uplo, char diag, lapack_int n,
44814492
float* a, lapack_int lda );
44824493
lapack_int LAPACKE_dtrtri( int matrix_layout, char uplo, char diag, lapack_int n,
@@ -10174,6 +10185,21 @@ lapack_int LAPACKE_ztrsyl_work( int matrix_layout, char trana, char tranb,
1017410185
lapack_complex_double* c, lapack_int ldc,
1017510186
double* scale );
1017610187

10188+
lapack_int LAPACKE_strsyl3_work( int matrix_layout, char trana, char tranb,
10189+
lapack_int isgn, lapack_int m, lapack_int n,
10190+
const float* a, lapack_int lda,
10191+
const float* b, lapack_int ldb,
10192+
float* c, lapack_int ldc, float* scale,
10193+
lapack_int* iwork, lapack_int liwork,
10194+
float* swork, lapack_int ldswork );
10195+
lapack_int LAPACKE_dtrsyl3_work( int matrix_layout, char trana, char tranb,
10196+
lapack_int isgn, lapack_int m, lapack_int n,
10197+
const double* a, lapack_int lda,
10198+
const double* b, lapack_int ldb,
10199+
double* c, lapack_int ldc, double* scale,
10200+
lapack_int* iwork, lapack_int liwork,
10201+
double* swork, lapack_int ldswork );
10202+
1017710203
lapack_int LAPACKE_strtri_work( int matrix_layout, char uplo, char diag,
1017810204
lapack_int n, float* a, lapack_int lda );
1017910205
lapack_int LAPACKE_dtrtri_work( int matrix_layout, char uplo, char diag,

LAPACKE/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,8 @@ lapacke_dtrsna.c
11691169
lapacke_dtrsna_work.c
11701170
lapacke_dtrsyl.c
11711171
lapacke_dtrsyl_work.c
1172+
lapacke_dtrsyl3.c
1173+
lapacke_dtrsyl3_work.c
11721174
lapacke_dtrtri.c
11731175
lapacke_dtrtri_work.c
11741176
lapacke_dtrtrs.c
@@ -1740,6 +1742,8 @@ lapacke_strsna.c
17401742
lapacke_strsna_work.c
17411743
lapacke_strsyl.c
17421744
lapacke_strsyl_work.c
1745+
lapacke_strsyl3.c
1746+
lapacke_strsyl3_work.c
17431747
lapacke_strtri.c
17441748
lapacke_strtri_work.c
17451749
lapacke_strtrs.c

LAPACKE/src/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ include $(TOPSRCDIR)/make.inc
3939

4040
.SUFFIXES: .c .o
4141
.c.o:
42-
$(CC) $(CFLAGS) -I../include -c -o $@ $<
42+
$(CC) $(CFLAGS) -Wall -I../include -c -o $@ $<
4343

4444
OBJ = \
4545
lapacke_ilaver.o \
@@ -1216,6 +1216,8 @@ lapacke_dtrsna.o \
12161216
lapacke_dtrsna_work.o \
12171217
lapacke_dtrsyl.o \
12181218
lapacke_dtrsyl_work.o \
1219+
lapacke_dtrsyl3.o \
1220+
lapacke_dtrsyl3_work.o \
12191221
lapacke_dtrtri.o \
12201222
lapacke_dtrtri_work.o \
12211223
lapacke_dtrtrs.o \
@@ -1782,6 +1784,8 @@ lapacke_strsna.o \
17821784
lapacke_strsna_work.o \
17831785
lapacke_strsyl.o \
17841786
lapacke_strsyl_work.o \
1787+
lapacke_strsyl3.o \
1788+
lapacke_strsyl3_work.o \
17851789
lapacke_strtri.o \
17861790
lapacke_strtri_work.o \
17871791
lapacke_strtrs.o \

LAPACKE/src/lapacke_cgesvdq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ lapack_int LAPACKE_cgesvdq( int matrix_layout, char joba, char jobp,
4848
lapack_int lrwork = -1;
4949
float* rwork = NULL;
5050
float rwork_query;
51-
lapack_int i;
5251
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
5352
LAPACKE_xerbla( "LAPACKE_cgesvdq", -1 );
5453
return -1;

LAPACKE/src/lapacke_dgesvdq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ lapack_int LAPACKE_dgesvdq( int matrix_layout, char joba, char jobp,
4848
lapack_int lrwork = -1;
4949
double* rwork = NULL;
5050
double rwork_query;
51-
lapack_int i;
5251
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
5352
LAPACKE_xerbla( "LAPACKE_dgesvdq", -1 );
5453
return -1;

LAPACKE/src/lapacke_dtrsyl3.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_dtrsyl3( int matrix_layout, char trana, char tranb,
4+
lapack_int isgn, lapack_int m, lapack_int n,
5+
const double* a, lapack_int lda, const double* b,
6+
lapack_int ldb, double* c, lapack_int ldc,
7+
double* scale )
8+
{
9+
lapack_int info = 0;
10+
double swork_query[2];
11+
double* swork = NULL;
12+
lapack_int ldswork = -1;
13+
lapack_int swork_size = -1;
14+
lapack_int* iwork = NULL;
15+
lapack_int liwork = -1;
16+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
17+
LAPACKE_xerbla( "LAPACKE_dtrsyl3", -1 );
18+
return -1;
19+
}
20+
#ifndef LAPACK_DISABLE_NAN_CHECK
21+
if( LAPACKE_get_nancheck() ) {
22+
/* Optionally check input matrices for NaNs */
23+
if( LAPACKE_dge_nancheck( matrix_layout, m, m, a, lda ) ) {
24+
return -7;
25+
}
26+
if( LAPACKE_dge_nancheck( matrix_layout, n, n, b, ldb ) ) {
27+
return -9;
28+
}
29+
if( LAPACKE_dge_nancheck( matrix_layout, m, n, c, ldc ) ) {
30+
return -11;
31+
}
32+
}
33+
#endif
34+
/* Query optimal working array sizes */
35+
info = LAPACKE_dtrsyl3_work( matrix_layout, trana, tranb, isgn, m, n, a, lda,
36+
b, ldb, c, ldc, scale, iwork, liwork,
37+
swork_query, ldswork );
38+
if( info != 0 ) {
39+
goto exit_level_0;
40+
}
41+
ldswork = swork_query[0];
42+
swork_size = ldswork * swork_query[1];
43+
swork = (double*)LAPACKE_malloc( sizeof(double) * swork_size);
44+
if( swork == NULL ) {
45+
info = LAPACK_WORK_MEMORY_ERROR;
46+
goto exit_level_0;
47+
}
48+
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
49+
if (iwork == NULL ) {
50+
info = LAPACK_WORK_MEMORY_ERROR;
51+
goto exit_level_1;
52+
}
53+
/* Call middle-level interface */
54+
info = LAPACKE_dtrsyl3_work( matrix_layout, trana, tranb, isgn, m, n, a,
55+
lda, b, ldb, c, ldc, scale, iwork, liwork,
56+
swork, ldswork );
57+
/* Release memory and exit */
58+
LAPACKE_free( iwork );
59+
exit_level_1:
60+
LAPACKE_free( swork );
61+
exit_level_0:
62+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
63+
LAPACKE_xerbla( "LAPACKE_dtrsyl3", info );
64+
}
65+
return info;
66+
}

LAPACKE/src/lapacke_dtrsyl3_work.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_dtrsyl3_work( int matrix_layout, char trana, char tranb,
4+
lapack_int isgn, lapack_int m, lapack_int n,
5+
const double* a, lapack_int lda,
6+
const double* b, lapack_int ldb, double* c,
7+
lapack_int ldc, double* scale,
8+
lapack_int* iwork, lapack_int liwork,
9+
double* swork, lapack_int ldswork )
10+
{
11+
lapack_int info = 0;
12+
if( matrix_layout == LAPACK_COL_MAJOR ) {
13+
/* Call LAPACK function and adjust info */
14+
LAPACK_dtrsyl3( &trana, &tranb, &isgn, &m, &n, a, &lda, b, &ldb, c, &ldc,
15+
scale, iwork, &liwork, swork, &ldswork, &info );
16+
if( info < 0 ) {
17+
info = info - 1;
18+
}
19+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
20+
lapack_int lda_t = MAX(1,m);
21+
lapack_int ldb_t = MAX(1,n);
22+
lapack_int ldc_t = MAX(1,m);
23+
double* a_t = NULL;
24+
double* b_t = NULL;
25+
double* c_t = NULL;
26+
/* Check leading dimension(s) */
27+
if( lda < m ) {
28+
info = -8;
29+
LAPACKE_xerbla( "LAPACKE_dtrsyl3_work", info );
30+
return info;
31+
}
32+
if( ldb < n ) {
33+
info = -10;
34+
LAPACKE_xerbla( "LAPACKE_dtrsyl3_work", info );
35+
return info;
36+
}
37+
if( ldc < n ) {
38+
info = -12;
39+
LAPACKE_xerbla( "LAPACKE_dtrsyl3_work", info );
40+
return info;
41+
}
42+
/* Allocate memory for temporary array(s) */
43+
a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,m) );
44+
if( a_t == NULL ) {
45+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
46+
goto exit_level_0;
47+
}
48+
b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,n) );
49+
if( b_t == NULL ) {
50+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
51+
goto exit_level_1;
52+
}
53+
c_t = (double*)LAPACKE_malloc( sizeof(double) * ldc_t * MAX(1,n) );
54+
if( c_t == NULL ) {
55+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
56+
goto exit_level_2;
57+
}
58+
/* Transpose input matrices */
59+
LAPACKE_dge_trans( matrix_layout, m, m, a, lda, a_t, lda_t );
60+
LAPACKE_dge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t );
61+
LAPACKE_dge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t );
62+
/* Call LAPACK function and adjust info */
63+
LAPACK_dtrsyl3( &trana, &tranb, &isgn, &m, &n, a_t, &lda_t, b_t, &ldb_t,
64+
c_t, &ldc_t, scale, iwork, &liwork, swork, &ldswork,
65+
&info );
66+
if( info < 0 ) {
67+
info = info - 1;
68+
}
69+
/* Transpose output matrices */
70+
LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
71+
/* Release memory and exit */
72+
LAPACKE_free( c_t );
73+
exit_level_2:
74+
LAPACKE_free( b_t );
75+
exit_level_1:
76+
LAPACKE_free( a_t );
77+
exit_level_0:
78+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
79+
LAPACKE_xerbla( "LAPACKE_dtrsyl3_work", info );
80+
}
81+
} else {
82+
info = -1;
83+
LAPACKE_xerbla( "LAPACKE_dtrsyl3_work", info );
84+
}
85+
return info;
86+
}

LAPACKE/src/lapacke_sgesvdq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ lapack_int LAPACKE_sgesvdq( int matrix_layout, char joba, char jobp,
4848
lapack_int lrwork = -1;
4949
float* rwork = NULL;
5050
float rwork_query;
51-
lapack_int i;
5251
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
5352
LAPACKE_xerbla( "LAPACKE_sgesvdq", -1 );
5453
return -1;

LAPACKE/src/lapacke_strsyl3.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include "lapacke_utils.h"
2+
3+
lapack_int LAPACKE_strsyl3( int matrix_layout, char trana, char tranb,
4+
lapack_int isgn, lapack_int m, lapack_int n,
5+
const float* a, lapack_int lda, const float* b,
6+
lapack_int ldb, float* c, lapack_int ldc,
7+
float* scale )
8+
{
9+
lapack_int info = 0;
10+
float swork_query[2];
11+
float* swork = NULL;
12+
lapack_int ldswork = -1;
13+
lapack_int swork_size = -1;
14+
lapack_int* iwork = NULL;
15+
lapack_int liwork = -1;
16+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
17+
LAPACKE_xerbla( "LAPACKE_strsyl3", -1 );
18+
return -1;
19+
}
20+
#ifndef LAPACK_DISABLE_NAN_CHECK
21+
if( LAPACKE_get_nancheck() ) {
22+
/* Optionally check input matrices for NaNs */
23+
if( LAPACKE_sge_nancheck( matrix_layout, m, m, a, lda ) ) {
24+
return -7;
25+
}
26+
if( LAPACKE_sge_nancheck( matrix_layout, n, n, b, ldb ) ) {
27+
return -9;
28+
}
29+
if( LAPACKE_sge_nancheck( matrix_layout, m, n, c, ldc ) ) {
30+
return -11;
31+
}
32+
}
33+
#endif
34+
/* Query optimal working array sizes */
35+
info = LAPACKE_strsyl3_work( matrix_layout, trana, tranb, isgn, m, n, a, lda,
36+
b, ldb, c, ldc, scale, iwork, liwork,
37+
swork_query, ldswork );
38+
if( info != 0 ) {
39+
goto exit_level_0;
40+
}
41+
ldswork = swork_query[0];
42+
swork_size = ldswork * swork_query[1];
43+
swork = (float*)LAPACKE_malloc( sizeof(float) * swork_size);
44+
if( swork == NULL ) {
45+
info = LAPACK_WORK_MEMORY_ERROR;
46+
goto exit_level_0;
47+
}
48+
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
49+
if (iwork == NULL ) {
50+
info = LAPACK_WORK_MEMORY_ERROR;
51+
goto exit_level_1;
52+
}
53+
/* Call middle-level interface */
54+
info = LAPACKE_strsyl3_work( matrix_layout, trana, tranb, isgn, m, n, a,
55+
lda, b, ldb, c, ldc, scale, iwork, liwork,
56+
swork, ldswork );
57+
/* Release memory and exit */
58+
LAPACKE_free( iwork );
59+
exit_level_1:
60+
LAPACKE_free( swork );
61+
exit_level_0:
62+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
63+
LAPACKE_xerbla( "LAPACKE_strsyl3", info );
64+
}
65+
return info;
66+
}

0 commit comments

Comments
 (0)