Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Commit

Permalink
lapack/cgo: apply LAPACK_dlantr fix patch and test
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Sep 7, 2015
1 parent 88f250e commit 0c5c24b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 7af11f77e3a08d529c45b43cb9121ca331342313 Mon Sep 17 00:00:00 2001
From: kortschak <dan.kortschak@adelaide.edu.au>
Date: Mon, 7 Sep 2015 15:39:22 +0930
Subject: [PATCH] Fix LAPACKE_dlantr transpose for row major matrices

---
lapack-netlib/lapacke/src/lapacke_dlantr.c | 2 +-
lapack-netlib/lapacke/src/lapacke_dlantr_work.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lapack-netlib/lapacke/src/lapacke_dlantr.c b/lapack-netlib/lapacke/src/lapacke_dlantr.c
index 522122c..2cde1eb 100644
--- a/lapack-netlib/lapacke/src/lapacke_dlantr.c
+++ b/lapack-netlib/lapacke/src/lapacke_dlantr.c
@@ -53,7 +53,7 @@ double LAPACKE_dlantr( int matrix_order, char norm, char uplo, char diag,
/* Allocate memory for working array(s) */
if( LAPACKE_lsame( norm, 'i' ) || LAPACKE_lsame( norm, '1' ) ||
LAPACKE_lsame( norm, '0' ) ) {
- work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,m) );
+ work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,MAX(m,n)) );
if( work == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
diff --git a/lapack-netlib/lapacke/src/lapacke_dlantr_work.c b/lapack-netlib/lapacke/src/lapacke_dlantr_work.c
index 0a937bd..44d638f 100644
--- a/lapack-netlib/lapacke/src/lapacke_dlantr_work.c
+++ b/lapack-netlib/lapacke/src/lapacke_dlantr_work.c
@@ -46,7 +46,7 @@ double LAPACKE_dlantr_work( int matrix_order, char norm, char uplo,
info = info - 1;
}
} else if( matrix_order == LAPACK_ROW_MAJOR ) {
- lapack_int lda_t = MAX(1,n);
+ lapack_int lda_t = MAX(1,m);
double* a_t = NULL;
/* Check leading dimension(s) */
if( lda < n ) {
@@ -55,13 +55,13 @@ double LAPACKE_dlantr_work( int matrix_order, char norm, char uplo,
return info;
}
/* Allocate memory for temporary array(s) */
- a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
+ a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,MAX(m,n)) );
if( a_t == NULL ) {
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
goto exit_level_0;
}
/* Transpose input matrices */
- LAPACKE_dtr_trans( matrix_order, uplo, diag, n, a, lda, a_t, lda_t );
+ LAPACKE_dtr_trans( matrix_order, uplo, diag, MAX(m,n), a, lda, a_t, lda_t );
/* Call LAPACK function and adjust info */
res = LAPACK_dlantr( &norm, &uplo, &diag, &m, &n, a_t, &lda_t, work );
info = 0; /* LAPACK call is ok! */
--
1.7.9.5

2 changes: 2 additions & 0 deletions .travis/linux/OpenBLAS/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pushd ~
sudo git clone --depth=1 git://github.com/xianyi/OpenBLAS
pushd OpenBLAS
echo OpenBLAS $(git rev-parse HEAD)
pwd
git apply ~/.travis/linux/OpenBLAS/0001-Fix-LAPACKE_dlantr-transpose-for-row-major-matrices.patch
sudo make FC=gfortran &> /dev/null
sudo make PREFIX=/usr install
popd
Expand Down
9 changes: 3 additions & 6 deletions cgo/lapack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ func TestDlange(t *testing.T) {
testlapack.DlangeTest(t, impl)
}

// The results from Dlantr do not match the results from Dlange. In some cases,
// there also appear to be memory corruption issues.
// TODO(btracey): Re-enable this test when the implementations are fixed.
// func TestDlantr(t *testing.T) {
// testlapack.DlantrTest(t, impl)
// }
func TestDlantr(t *testing.T) {
testlapack.DlantrTest(t, impl)
}

func TestDpotrf(t *testing.T) {
testlapack.DpotrfTest(t, impl)
Expand Down

0 comments on commit 0c5c24b

Please sign in to comment.