[librsb] 01/01: Add unit test for numerical bug fixed in version 1.2.0-rc7

Rafael Laboissiere rafael at debian.org
Sun Jul 30 21:58:11 UTC 2017


This is an automated email from the git hooks/post-receive script.

rafael pushed a commit to branch master
in repository librsb.

commit c9a3dbd269664b81362cd6a4748a5965a6e9fdbc
Author: Rafael Laboissiere <rafael at debian.org>
Date:   Sun Jul 30 17:31:22 2017 -0300

    Add unit test for numerical bug fixed in version 1.2.0-rc7
    
    Thanks: Michele Martone for the source file
---
 .gitignore             |  1 +
 debian/clean           |  1 +
 debian/rsb127_bugfix.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 debian/rules           |  3 +++
 4 files changed, 64 insertions(+)

diff --git a/.gitignore b/.gitignore
index 27fa840..f22f4d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,3 +68,4 @@
 /rsbenchxx.cpp
 /scripts/Makefile
 /stamp-h1
+/debian/rsb127_bugfix
diff --git a/debian/clean b/debian/clean
index f3f6bc2..f21f5e7 100644
--- a/debian/clean
+++ b/debian/clean
@@ -10,3 +10,4 @@ sbtc
 test.mtx
 doc/html/
 doc/man/man3/
+debian/rsb127_bugfix
diff --git a/debian/rsb127_bugfix.c b/debian/rsb127_bugfix.c
new file mode 100644
index 0000000..682994d
--- /dev/null
+++ b/debian/rsb127_bugfix.c
@@ -0,0 +1,59 @@
+/* This program demonstrates a bug fixed in librsb-1.2-rc7. */
+
+#include <rsb.h>
+#include <stdio.h>
+
+int main(const int argc, char * const argv[])
+{
+	rsb_err_t errval = RSB_ERR_NO_ERROR;
+	int i;
+  	const int N = 2;
+  	double complex x[N], y[N];
+  	const double complex alpha = 1.0;
+	double complex VA[]={1,1,2};
+	int IA[]={0,0,1},JA[]={0,1,1},nnz=3;
+	struct rsb_mtx_t * mtxAp;
+	// matrix:
+	// (1,0) (1,0)
+	// (1,0) (1,0)
+	// represented as upper hermitian:
+	// (1,0) (1,0)
+	// (0,0) (1,0)
+	// multiplicand vector:
+	// (0,1)
+	// (0,0)
+	// result shall be:
+	// (0,1)
+	// (0,1)
+  	errval = rsb_lib_init(RSB_NULL_INIT_OPTIONS);
+  	if(errval != RSB_ERR_NO_ERROR)
+		goto err;
+	mtxAp = rsb_mtx_alloc_from_coo_begin(2, RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX, N, N, RSB_FLAG_DEFAULT_STORAGE_FLAGS|RSB_FLAG_UPPER_HERMITIAN , &errval);
+	errval = rsb_mtx_set_vals(mtxAp, VA, IA, JA, nnz, RSB_FLAG_NOFLAGS);
+	if(errval != RSB_ERR_NO_ERROR)
+		goto err;
+	errval = rsb_mtx_alloc_from_coo_end(&mtxAp);
+	if(errval != RSB_ERR_NO_ERROR)
+		goto err;
+	for (i = 0; i < N; i++) x[i] = y[i] = 0.0;
+    	x[0] = I;
+	errval = rsb_spmv(RSB_TRANSPOSITION_N, &alpha, mtxAp, x, 1, NULL, y, 1);
+	if(errval != RSB_ERR_NO_ERROR)
+		goto err;
+    	for (i = 0; i < N; i++)
+		printf("(%g,%g)\t", creal(y[i]), cimag(y[i]));
+    	printf("\n");
+    	if(cimag(y[1])!=1)
+		printf("Result seems incorrect -- are you using <  librsb-1.2-rc7?\n");
+	else
+		printf("Result seems correct   -- are you using >= librsb-1.2-rc7?\n");
+    	rsb_mtx_free(mtxAp);
+
+	errval = rsb_lib_exit(RSB_NULL_EXIT_OPTIONS);
+	if(errval != RSB_ERR_NO_ERROR)
+		goto err;
+	return 0;
+err:
+	rsb_perror(NULL,errval);
+	return -1;
+}
diff --git a/debian/rules b/debian/rules
index 7696b56..2872500 100755
--- a/debian/rules
+++ b/debian/rules
@@ -30,6 +30,9 @@ override_dh_auto_build:
 
 override_dh_auto_test:
 	make qtests
+	(cd debian ;							\
+	 gcc -o rsb127_bugfix -I.. -L../.libs -lrsb rsb127_bugfix.c ; 	\
+	 LD_LIBRARY_PATH=../.libs ./rsb127_bugfix )
 
 override_dh_compress:
 	dh_compress -X.c -X.F90

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/librsb.git



More information about the debian-science-commits mailing list