Skip to content

Commit e774b43

Browse files
authored
Merge pull request #168 from kbergstr/larcm
Added LAPACKE interfaces for [c/z]larcm and [c/z]lacrm
2 parents 9f7abc2 + 3fdffeb commit e774b43

11 files changed

Lines changed: 816 additions & 0 deletions

LAPACKE/include/lapacke.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,28 @@ float LAPACKE_clanhe( int matrix_layout, char norm, char uplo, lapack_int n,
23982398
double LAPACKE_zlanhe( int matrix_layout, char norm, char uplo, lapack_int n,
23992399
const lapack_complex_double* a, lapack_int lda );
24002400

2401+
lapack_int LAPACKE_clacrm( int matrix_layout, lapack_int m, lapack_int n,
2402+
const lapack_complex_float* a,
2403+
lapack_int lda, const float* b,
2404+
lapack_int ldb, lapack_complex_float* c,
2405+
lapack_int ldc );
2406+
lapack_int LAPACKE_zlacrm( int matrix_layout, lapack_int m, lapack_int n,
2407+
const lapack_complex_double* a,
2408+
lapack_int lda, const double* b,
2409+
lapack_int ldb, lapack_complex_double* c,
2410+
lapack_int ldc );
2411+
2412+
lapack_int LAPACKE_clarcm( int matrix_layout, lapack_int m, lapack_int n,
2413+
const float* a, lapack_int lda,
2414+
const lapack_complex_float* b,
2415+
lapack_int ldb, lapack_complex_float* c,
2416+
lapack_int ldc );
2417+
lapack_int LAPACKE_zlarcm( int matrix_layout, lapack_int m, lapack_int n,
2418+
const double* a, lapack_int lda,
2419+
const lapack_complex_double* b,
2420+
lapack_int ldb, lapack_complex_double* c,
2421+
lapack_int ldc );
2422+
24012423
float LAPACKE_slansy( int matrix_layout, char norm, char uplo, lapack_int n,
24022424
const float* a, lapack_int lda );
24032425
double LAPACKE_dlansy( int matrix_layout, char norm, char uplo, lapack_int n,
@@ -7586,6 +7608,28 @@ double LAPACKE_zlanhe_work( int matrix_layout, char norm, char uplo,
75867608
lapack_int n, const lapack_complex_double* a,
75877609
lapack_int lda, double* work );
75887610

7611+
lapack_int LAPACKE_clacrm_work( int matrix_layout, lapack_int m, lapack_int n,
7612+
const lapack_complex_float* a,
7613+
lapack_int lda, const float* b,
7614+
lapack_int ldb, lapack_complex_float* c,
7615+
lapack_int ldc, float* work );
7616+
lapack_int LAPACKE_zlacrm_work( int matrix_layout, lapack_int m, lapack_int n,
7617+
const lapack_complex_double* a,
7618+
lapack_int lda, const double* b,
7619+
lapack_int ldb, lapack_complex_double* c,
7620+
lapack_int ldc, double* work );
7621+
7622+
lapack_int LAPACKE_clarcm_work( int matrix_layout, lapack_int m, lapack_int n,
7623+
const float* a, lapack_int lda,
7624+
const lapack_complex_float* b,
7625+
lapack_int ldb, lapack_complex_float* c,
7626+
lapack_int ldc, float* work );
7627+
lapack_int LAPACKE_zlarcm_work( int matrix_layout, lapack_int m, lapack_int n,
7628+
const double* a, lapack_int lda,
7629+
const lapack_complex_double* b,
7630+
lapack_int ldb, lapack_complex_double* c,
7631+
lapack_int ldc, double* work );
7632+
75897633
float LAPACKE_slansy_work( int matrix_layout, char norm, char uplo,
75907634
lapack_int n, const float* a, lapack_int lda,
75917635
float* work );
@@ -13347,6 +13391,10 @@ lapack_int LAPACKE_zhegv_2stage_work( int matrix_layout, lapack_int itype, char
1334713391
#define LAPACK_zlange LAPACK_GLOBAL(zlange,ZLANGE)
1334813392
#define LAPACK_clanhe LAPACK_GLOBAL(clanhe,CLANHE)
1334913393
#define LAPACK_zlanhe LAPACK_GLOBAL(zlanhe,ZLANHE)
13394+
#define LAPACK_clarcm LAPACK_GLOBAL(clarcm,CLARCM)
13395+
#define LAPACK_zlarcm LAPACK_GLOBAL(zlarcm,ZLARCM)
13396+
#define LAPACK_clacrm LAPACK_GLOBAL(clacrm,CLACRM)
13397+
#define LAPACK_zlacrm LAPACK_GLOBAL(zlacrm,ZLACRM)
1335013398
#define LAPACK_slansy LAPACK_GLOBAL(slansy,SLANSY)
1335113399
#define LAPACK_dlansy LAPACK_GLOBAL(dlansy,DLANSY)
1335213400
#define LAPACK_clansy LAPACK_GLOBAL(clansy,CLANSY)
@@ -17896,6 +17944,22 @@ float LAPACK_clanhe( char* norm, char* uplo, lapack_int* n,
1789617944
const lapack_complex_float* a, lapack_int* lda, float* work );
1789717945
double LAPACK_zlanhe( char* norm, char* uplo, lapack_int* n,
1789817946
const lapack_complex_double* a, lapack_int* lda, double* work );
17947+
void LAPACK_clarcm( lapack_int* m, lapack_int* n, const float* a,
17948+
lapack_int* lda, const lapack_complex_float* b,
17949+
lapack_int* ldb, lapack_complex_float* c,
17950+
lapack_int* ldc, float* work );
17951+
void LAPACK_zlarcm( lapack_int* m, lapack_int* n, const double* a,
17952+
lapack_int* lda, const lapack_complex_double* b,
17953+
lapack_int* ldb, lapack_complex_double* c,
17954+
lapack_int* ldc, double* work );
17955+
void LAPACK_clacrm( lapack_int* m, lapack_int* n, const lapack_complex_float* a,
17956+
lapack_int* lda, const float* b,
17957+
lapack_int* ldb, lapack_complex_float* c,
17958+
lapack_int* ldc, float* work );
17959+
void LAPACK_zlacrm( lapack_int* m, lapack_int* n, const lapack_complex_double* a,
17960+
lapack_int* lda, const double* b,
17961+
lapack_int* ldb, lapack_complex_double* c,
17962+
lapack_int* ldc, double* work );
1789917963
float LAPACK_slansy( char* norm, char* uplo, lapack_int* n, const float* a,
1790017964
lapack_int* lda, float* work );
1790117965
double LAPACK_dlansy( char* norm, char* uplo, lapack_int* n, const double* a,

LAPACKE/src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ lapacke_clacp2.c
295295
lapacke_clacp2_work.c
296296
lapacke_clacpy.c
297297
lapacke_clacpy_work.c
298+
lapacke_clacrm.c
299+
lapacke_clacrm_work.c
298300
lapacke_clag2z.c
299301
lapacke_clag2z_work.c
300302
lapacke_clange.c
@@ -309,6 +311,8 @@ lapacke_clapmr.c
309311
lapacke_clapmr_work.c
310312
lapacke_clapmt.c
311313
lapacke_clapmt_work.c
314+
lapacke_clarcm.c
315+
lapacke_clarcm_work.c
312316
lapacke_clarfb.c
313317
lapacke_clarfb_work.c
314318
lapacke_clarfg.c
@@ -1987,6 +1991,8 @@ lapacke_zlacp2.c
19871991
lapacke_zlacp2_work.c
19881992
lapacke_zlacpy.c
19891993
lapacke_zlacpy_work.c
1994+
lapacke_zlacrm.c
1995+
lapacke_zlacrm_work.c
19901996
lapacke_zlag2c.c
19911997
lapacke_zlag2c_work.c
19921998
lapacke_zlange.c
@@ -2001,6 +2007,8 @@ lapacke_zlapmr.c
20012007
lapacke_zlapmr_work.c
20022008
lapacke_zlapmt.c
20032009
lapacke_zlapmt_work.c
2010+
lapacke_zlarcm.c
2011+
lapacke_zlarcm_work.c
20042012
lapacke_zlarfb.c
20052013
lapacke_zlarfb_work.c
20062014
lapacke_zlarfg.c

LAPACKE/src/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ lapacke_clacp2.o \
334334
lapacke_clacp2_work.o \
335335
lapacke_clacpy.o \
336336
lapacke_clacpy_work.o \
337+
lapacke_clacrm.o \
338+
lapacke_clacrm_work.o \
337339
lapacke_clag2z.o \
338340
lapacke_clag2z_work.o \
339341
lapacke_clange.o \
@@ -348,6 +350,8 @@ lapacke_clapmr.o \
348350
lapacke_clapmr_work.o \
349351
lapacke_clapmt.o \
350352
lapacke_clapmt_work.o \
353+
lapacke_clarcm.o \
354+
lapacke_clarcm_work.o \
351355
lapacke_clarfb.o \
352356
lapacke_clarfb_work.o \
353357
lapacke_clarfg.o \
@@ -2034,6 +2038,8 @@ lapacke_zlacp2.o \
20342038
lapacke_zlacp2_work.o \
20352039
lapacke_zlacpy.o \
20362040
lapacke_zlacpy_work.o \
2041+
lapacke_zlacrm.o \
2042+
lapacke_zlacrm_work.o \
20372043
lapacke_zlag2c.o \
20382044
lapacke_zlag2c_work.o \
20392045
lapacke_zlange.o \
@@ -2048,6 +2054,8 @@ lapacke_zlapmr.o \
20482054
lapacke_zlapmr_work.o \
20492055
lapacke_zlapmt.o \
20502056
lapacke_zlapmt_work.o \
2057+
lapacke_zlarcm.o \
2058+
lapacke_zlarcm_work.o \
20512059
lapacke_zlarfb.o \
20522060
lapacke_zlarfb_work.o \
20532061
lapacke_zlarfg.o \

LAPACKE/src/lapacke_clacrm.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*****************************************************************************
2+
Copyright (c) 2017, Intel Corp.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Intel Corporation nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
THE POSSIBILITY OF SUCH DAMAGE.
28+
*****************************************************************************
29+
* Contents: Native high-level C interface to LAPACK function clacrm
30+
* Author: Intel Corporation
31+
* Generated June 2017
32+
*****************************************************************************/
33+
34+
#include "lapacke_utils.h"
35+
36+
lapack_int LAPACKE_clacrm(int matrix_layout, lapack_int m,
37+
lapack_int n, const lapack_complex_float* a,
38+
lapack_int lda, const float* b, lapack_int ldb,
39+
lapack_complex_float* c, lapack_int ldc)
40+
{
41+
lapack_int info = 0;
42+
float* rwork = NULL;
43+
44+
if (matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR) {
45+
LAPACKE_xerbla("LAPACKE_clacrm", -1);
46+
return -1;
47+
}
48+
#ifndef LAPACK_DISABLE_NAN_CHECK
49+
/* Optionally check input matrices for NaNs */
50+
if( LAPACKE_cge_nancheck( matrix_layout, m, n, a, lda ) ) {
51+
return -4;
52+
}
53+
if( LAPACKE_sge_nancheck( matrix_layout, n, n, b, ldb ) ) {
54+
return -6;
55+
}
56+
#endif
57+
/* Allocate memory for work array(s) */
58+
rwork = (float*)
59+
LAPACKE_malloc(sizeof(float) * MAX(1, 2 * m * n));
60+
if (rwork == NULL) {
61+
info = LAPACK_WORK_MEMORY_ERROR;
62+
goto exit_level_0;
63+
}
64+
/* Call middle-level interface */
65+
info = LAPACKE_clacrm_work(matrix_layout, m, n, a, lda, b, ldb,
66+
c, ldc, rwork);
67+
/* Release memory and exit */
68+
LAPACKE_free(rwork);
69+
exit_level_0:
70+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
71+
LAPACKE_xerbla( "LAPACKE_clacrm", info );
72+
}
73+
return info;
74+
}

LAPACKE/src/lapacke_clacrm_work.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*****************************************************************************
2+
Copyright (c) 2017, Intel Corp.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
* Neither the name of Intel Corporation nor the names of its contributors
14+
may be used to endorse or promote products derived from this software
15+
without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27+
THE POSSIBILITY OF SUCH DAMAGE.
28+
*****************************************************************************
29+
* Contents: Native middle-level C interface to LAPACK function clacrm
30+
* Author: Intel Corporation
31+
* Generated June 2017
32+
*****************************************************************************/
33+
34+
#include "lapacke_utils.h"
35+
36+
lapack_int LAPACKE_clacrm_work(int matrix_layout, lapack_int m, lapack_int n,
37+
const lapack_complex_float* a, lapack_int lda,
38+
const float* b, lapack_int ldb,
39+
lapack_complex_float* c, lapack_int ldc,
40+
float* rwork)
41+
{
42+
lapack_int info = 0;
43+
if (matrix_layout == LAPACK_COL_MAJOR) {
44+
/* Call LAPACK function */
45+
LAPACK_clacrm(&m, &n, a, &lda, b, &ldb, c, &ldc, rwork);
46+
} else if (matrix_layout == LAPACK_ROW_MAJOR) {
47+
lapack_int lda_t = MAX(1,m);
48+
lapack_int ldb_t = MAX(1,n);
49+
lapack_int ldc_t = MAX(1,m);
50+
lapack_complex_float* a_t = NULL;
51+
float* b_t = NULL;
52+
lapack_complex_float* c_t = NULL;
53+
/* Check leading dimension(s) */
54+
if( lda < n ) {
55+
info = -5;
56+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
57+
return info;
58+
}
59+
if( ldb < n ) {
60+
info = -7;
61+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
62+
return info;
63+
}
64+
if( ldc < n ) {
65+
info = -9;
66+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
67+
return info;
68+
}
69+
/* Allocate memory for temporary array(s) */
70+
a_t = (lapack_complex_float*)
71+
LAPACKE_malloc(sizeof(lapack_complex_float) * lda_t * MAX(1,n));
72+
b_t = (float*)
73+
LAPACKE_malloc(sizeof(float) * ldb_t * MAX(1,n));
74+
c_t = (lapack_complex_float*)
75+
LAPACKE_malloc((sizeof(lapack_complex_float) * ldc_t * MAX(1,n)));
76+
if (a_t == NULL) {
77+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
78+
goto exit_level_0;
79+
}
80+
if (b_t == NULL) {
81+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
82+
goto exit_level_1;
83+
}
84+
if (c_t == NULL) {
85+
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
86+
goto exit_level_2;
87+
}
88+
/* Transpose input matrices */
89+
LAPACKE_cge_trans(matrix_layout, m, n, a, lda, a_t, lda_t);
90+
LAPACKE_sge_trans(matrix_layout, n, n, b, ldb, b_t, ldb_t);
91+
/* Call LAPACK function */
92+
LAPACK_clacrm(&m, &n, a_t, &lda_t, b_t, &ldb_t, c_t, &ldc_t, rwork);
93+
/* Transpose output matrices */
94+
LAPACKE_cge_trans(LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc);
95+
/* Release memory and exit */
96+
LAPACKE_free(c_t);
97+
exit_level_2:
98+
LAPACKE_free(b_t);
99+
exit_level_1:
100+
LAPACKE_free(a_t);
101+
exit_level_0:
102+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
103+
LAPACKE_xerbla( "LAPACKE_clacrm_work", info );
104+
}
105+
} else {
106+
info = -1;
107+
LAPACKE_xerbla("LAPACKE_clacrm_work", -1);
108+
}
109+
return info;
110+
}

0 commit comments

Comments
 (0)