Sat May 29 09:55:14 2021 UTC ()
math/qrupdate: add package for QR and Cholesky matrix decomposition

This is scheduled to be a dependency for math/octave to support the
named operations.

Qrupdate is a linear algebra library for fast updating of QR and Cholesky
decompositions.

Supported operations:

- QR rank-1 update (qr1up)
- QR column insert (qrinc)
- QR column delete (qrdec)
- QR column shift (qrshc)
- QR row insert (qrinr)
- QR row delete (qrder)
- Cholesky rank-1 update (ch1up)
- Cholesky rank-1 downdate (ch1dn)
- Cholesky symmetric insert (chinx)
- Cholesky symmetric insert (chdex)
- Cholesky symmetric shift (chshx)
- LU rank-1 update (lu1up)
- LU pivoted rank-1 update (lup1up)


(thor)
diff -r1.500 -r1.501 pkgsrc/math/Makefile
diff -r0 -r1.1 pkgsrc/math/qrupdate/DESCR
diff -r0 -r1.1 pkgsrc/math/qrupdate/Makefile
diff -r0 -r1.1 pkgsrc/math/qrupdate/PLIST
diff -r0 -r1.1 pkgsrc/math/qrupdate/buildlink3.mk
diff -r0 -r1.1 pkgsrc/math/qrupdate/distinfo
diff -r0 -r1.1 pkgsrc/math/qrupdate/patches/patch-src_Makefile
diff -r0 -r1.1 pkgsrc/math/qrupdate/patches/patch-test_Makefile
diff -r0 -r1.1 pkgsrc/math/qrupdate/patches/patch-test_report__results
diff -r0 -r1.1 pkgsrc/math/qrupdate/patches/patch-test_utils.f

cvs diff -r1.500 -r1.501 pkgsrc/math/Makefile (expand / switch to unified diff)

--- pkgsrc/math/Makefile 2021/05/20 07:52:37 1.500
+++ pkgsrc/math/Makefile 2021/05/29 09:55:14 1.501
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.500 2021/05/20 07:52:37 wiz Exp $ 1# $NetBSD: Makefile,v 1.501 2021/05/29 09:55:14 thor Exp $
2 2
3COMMENT= Mathematics 3COMMENT= Mathematics
4 4
5SUBDIR+= R 5SUBDIR+= R
6SUBDIR+= R-CGIwithR 6SUBDIR+= R-CGIwithR
7SUBDIR+= R-DAAG 7SUBDIR+= R-DAAG
8SUBDIR+= R-DBI 8SUBDIR+= R-DBI
9SUBDIR+= R-DEoptimR 9SUBDIR+= R-DEoptimR
10SUBDIR+= R-FNN 10SUBDIR+= R-FNN
11SUBDIR+= R-Formula 11SUBDIR+= R-Formula
12SUBDIR+= R-GRASS 12SUBDIR+= R-GRASS
13SUBDIR+= R-ISLR 13SUBDIR+= R-ISLR
14SUBDIR+= R-ISwR 14SUBDIR+= R-ISwR
@@ -395,26 +395,27 @@ SUBDIR+= py-simpleeval @@ -395,26 +395,27 @@ SUBDIR+= py-simpleeval
395SUBDIR+= py-sklearn-pandas 395SUBDIR+= py-sklearn-pandas
396SUBDIR+= py-smt 396SUBDIR+= py-smt
397SUBDIR+= py-statsmodels 397SUBDIR+= py-statsmodels
398SUBDIR+= py-sympy 398SUBDIR+= py-sympy
399SUBDIR+= py-tables 399SUBDIR+= py-tables
400SUBDIR+= py-tensorboard 400SUBDIR+= py-tensorboard
401SUBDIR+= py-uncertainties 401SUBDIR+= py-uncertainties
402SUBDIR+= py-xarray 402SUBDIR+= py-xarray
403SUBDIR+= py-z3 403SUBDIR+= py-z3
404SUBDIR+= py-z3solver 404SUBDIR+= py-z3solver
405SUBDIR+= qalculate 405SUBDIR+= qalculate
406SUBDIR+= qalculate-gtk 406SUBDIR+= qalculate-gtk
407SUBDIR+= qhull 407SUBDIR+= qhull
 408SUBDIR+= qrupdate
408SUBDIR+= quadpack 409SUBDIR+= quadpack
409SUBDIR+= randlib 410SUBDIR+= randlib
410SUBDIR+= ranger 411SUBDIR+= ranger
411SUBDIR+= ruby-gsl 412SUBDIR+= ruby-gsl
412SUBDIR+= ruby-narray 413SUBDIR+= ruby-narray
413SUBDIR+= ruby-roo 414SUBDIR+= ruby-roo
414SUBDIR+= ruby-spreadsheet 415SUBDIR+= ruby-spreadsheet
415SUBDIR+= sc 416SUBDIR+= sc
416SUBDIR+= sc-im 417SUBDIR+= sc-im
417SUBDIR+= scilab 418SUBDIR+= scilab
418SUBDIR+= slatec 419SUBDIR+= slatec
419SUBDIR+= snns 420SUBDIR+= snns
420SUBDIR+= sollya 421SUBDIR+= sollya

File Added: pkgsrc/math/qrupdate/DESCR
Qrupdate is a linear algebra library for fast updating of QR and Cholesky
decompositions.

Supported operations:

- QR rank-1 update (qr1up)
- QR column insert (qrinc)
- QR column delete (qrdec)
- QR column shift (qrshc)
- QR row insert (qrinr)
- QR row delete (qrder)
- Cholesky rank-1 update (ch1up)
- Cholesky rank-1 downdate (ch1dn)
- Cholesky symmetric insert (chinx)
- Cholesky symmetric insert (chdex)
- Cholesky symmetric shift (chshx)
- LU rank-1 update (lu1up)
- LU pivoted rank-1 update (lup1up)

File Added: pkgsrc/math/qrupdate/Makefile
# $NetBSD: Makefile,v 1.1 2021/05/29 09:55:14 thor Exp $

DISTNAME=	qrupdate-1.1.2
CATEGORIES=	math
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE:=qrupdate/}

MAINTAINER=	thomas.orgis@uni-hamburg.de
HOMEPAGE=	https://qrupdate.sourceforge.io/
COMMENT=	Library for fast updating of QR and Cholesky decompositions
LICENSE=	gnu-gpl-v2

USE_LANGUAGES=	fortran
USE_TOOLS=	gmake
REPLACE_SH=	test/report_results

TEST_TARGET=	test

MAKE_FLAGS=	FC=${FC:Q} LDFLAGS=${LDFLAGS:Q} FFLAGS=${FFLAGS:Q} PREFIX=${PREFIX} LIBDIR=lib
MAKE_FLAGS+=	BLAS=${BLAS_LIBS} LAPACK=${LAPACK_LIBS}

do-build:
	cd ${WRKSRC} && gmake ${MAKE_FLAGS} FPICFLAGS= lib \
	&& rm src/*.o && gmake ${MAKE_FLAGS} FPICFLAGS=-fPIC solib

.include "../../mk/blas.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

File Added: pkgsrc/math/qrupdate/PLIST
@comment $NetBSD: PLIST,v 1.1 2021/05/29 09:55:14 thor Exp $
lib/libqrupdate.a
lib/libqrupdate.so
lib/libqrupdate.so.1
lib/libqrupdate.so.1.1

File Added: pkgsrc/math/qrupdate/buildlink3.mk
# $NetBSD: buildlink3.mk,v 1.1 2021/05/29 09:55:14 thor Exp $

BUILDLINK_TREE+=	qrupdate

.if !defined(QRUPDATE_BUILDLINK3_MK)
QRUPDATE_BUILDLINK3_MK:=

BUILDLINK_API_DEPENDS.qrupdate+=	qrupdate>=1.1.2
BUILDLINK_PKGSRCDIR.qrupdate?=		../../math/qrupdate

.include "../../mk/blas.buildlink3.mk"

.endif	# QRUPDATE_BUILDLINK3_MK

BUILDLINK_TREE+=	-qrupdate

File Added: pkgsrc/math/qrupdate/distinfo
$NetBSD: distinfo,v 1.1 2021/05/29 09:55:14 thor Exp $

SHA1 (qrupdate-1.1.2.tar.gz) = f7403b646ace20f4a2b080b4933a1e9152fac526
RMD160 (qrupdate-1.1.2.tar.gz) = 9d23b2d13278c335f6208ebb6775df4b4049785c
SHA512 (qrupdate-1.1.2.tar.gz) = cc4e466ea91958e15c66be82b0c4c8ad813fbe4643f21259a9cb3ca8e0a411dd764bb2397ece848a7045f322d30316801d1540c4ebf7912030bef6995b44917c
Size (qrupdate-1.1.2.tar.gz) = 49734 bytes
SHA1 (patch-src_Makefile) = 55be251bc4e6ce1d0760f090c28ed14a7aeecc0e
SHA1 (patch-test_Makefile) = 85f21cf81834ae9a3301ed79b4b5472981e8a15a
SHA1 (patch-test_report__results) = f40092414fdd6ec673e051a23d388fdbd1a4708f
SHA1 (patch-test_utils.f) = 1788deb4692c264fb5fe469d5ddbb64179db8d5d

File Added: pkgsrc/math/qrupdate/patches/patch-src_Makefile
$NetBSD: patch-src_Makefile,v 1.1 2021/05/29 09:55:14 thor Exp $

Use LDFLAGS also for the .so library and fix non-portable install -D usage.
Also … the permissions 644 seem wrong for shared libs.

--- src/Makefile.orig	2010-01-19 11:35:49.000000000 +0000
+++ src/Makefile
@@ -47,7 +47,7 @@ solib: ../libqrupdate$(SOEXT)
 	ar -cr $@ $(OBJS)
 
 ../libqrupdate.so: $(OBJS)
-	$(FC) $(FFLAGS) -shared -o $@ -Wl,-soname=libqrupdate.so.$(MAJOR) $(OBJS) \
+	$(FC) $(FFLAGS) $(LDFLAGS) -shared -o $@ -Wl,-soname=libqrupdate.so.$(MAJOR) $(OBJS) \
 		$(BLAS) $(LAPACK)
 
 ../libqrupdate.dylib: $(OBJS)
@@ -65,14 +65,17 @@ install: install-shlib install-staticlib
 install-shlib: ../libqrupdate$(SOEXT) install-lib$(SOEXT)
 
 install-lib.so:
-	install -D -m644 ../libqrupdate.so $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.so.$(VERSION)
+	install -d -m755 $(DESTDIR)$(PREFIX)/$(LIBDIR)
+	install -m755 ../libqrupdate.so $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.so.$(VERSION)
 	ln -s libqrupdate.so.$(VERSION) $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.so.$(MAJOR)
 	ln -s libqrupdate.so.$(VERSION) $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.so
 
 install-lib.dylib:
-	install -D -m644 ../libqrupdate.dylib $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.$(VERSION).dylib
+	install -d -m755 $(DESTDIR)$(PREFIX)/$(LIBDIR)
+	install -m755 ../libqrupdate.dylib $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.$(VERSION).dylib
 	ln -s libqrupdate.$(VERSION).dylib $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.$(MAJOR).dylib
 	ln -s libqrupdate.$(VERSION).dylib $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.dylib
 
 install-staticlib: ../libqrupdate.a
-	install -D -m644 ../libqrupdate.a $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.a
+	install -d -m755 $(DESTDIR)$(PREFIX)/$(LIBDIR)
+	install -m644 ../libqrupdate.a $(DESTDIR)$(PREFIX)/$(LIBDIR)/libqrupdate.a

File Added: pkgsrc/math/qrupdate/patches/patch-test_Makefile
$NetBSD: patch-test_Makefile,v 1.1 2021/05/29 09:55:14 thor Exp $

Use LDFLAGS for tests!

--- test/Makefile.orig	2021-05-29 09:14:58.376660614 +0000
+++ test/Makefile
@@ -35,7 +35,7 @@ $(OUTS): %.out: %
 	./$< | tee $@
 
 $(PROGS): % : %.f utils.o ../libqrupdate.a
-	$(FC) $(FFLAGS) -o $@ $^ $(LIBS)
+	$(FC) $(FFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 utils.o: utils.f
 	$(FC) $(FFLAGS) -c $<

File Added: pkgsrc/math/qrupdate/patches/patch-test_report__results
$NetBSD: patch-test_report__results,v 1.1 2021/05/29 09:55:14 thor Exp $

Drop awk usage and make the test script actually count and evaluate errors
itself so that the test target has a meaningful result as return value.

--- test/report_results.orig	2010-02-11 10:45:19.000000000 +0000
+++ test/report_results
@@ -1,22 +1,30 @@
 #!/bin/sh
 OUTS=$*
 passed_total=0
 failed_total=0
 cat $OUTS
 
-# if awk exists, use it to print total statistics
-if which awk > /dev/null ; then
-	awk '/total:/ { passed += $3; failed += $5; }
-	END { printf " TOTAL:     PASSED %3d     FAILED %3d\n", passed, failed; }' $OUTS
-fi
+ret=0
 for out in $OUTS ; do
 	if [ ! -s $out ] ; then
 		echo " $out file empty (test crashed)!"
+		ret=1
 	else
 		if grep -q WARNING $out ; then
 			echo " $out produced warnings:"
 			grep WARNING $out
+			ret=1
+		fi
+		passed=$(grep total: $out | (read a b num d; echo $num))
+		passed_total=$((passed_total+passed))
+		failed=$(grep total: $out | (read a b c d num f; echo $num))
+		failed_total=$((failed_total+failed))
+		if test "$failed" -gt 0; then
+			echo " $out has failures"
+			ret=1
 		fi
 	fi
 done
+printf "\n TOTAL:     PASSED %3d     FAILED %3d\n" "$passed_total" "$failed_total"
 
+exit $ret

File Added: pkgsrc/math/qrupdate/patches/patch-test_utils.f
$NetBSD: patch-test_utils.f,v 1.1 2021/05/29 09:55:14 thor Exp $

Fix the fortran code for modern compilers who do not like to silently
treat complex arrays as real arrays of twice the size and increase the
error threshold for tests a bit, as the zch1dn test in tch1dn is quite
at the edge.

--- test/utils.f.orig	2021-05-29 07:46:09.748438877 +0000
+++ test/utils.f
@@ -58,18 +58,48 @@ c
       end do
       end subroutine
 
+c In the old days, you would have treated the complex array as twice as
+c much of a real array, but modern compilers do not like that. So
+c resort to a buffer and explicit conversion. This is not
+c performance-relevant code, anyway.
+c Incidentally, this change in random numbers (strides of real and
+c imaginary parts) subtly reduces error in tch1dn to make it pass again.
+c Further hint that the error margin had to be just be a bit widenend.
+
       subroutine crandg(m,n,x,ldx)
       integer m,n,ldx
       complex x(ldx,*)
+      real buf(128,2)
+      integer j,k,b,i
       external srandg
-      call srandg(2*m,n,x,2*ldx)
+      do j=1,n
+        do k=1,m,128
+          b=min(m-k+1,128)
+          call srandg(b,1,buf(1,1),b)
+          call srandg(b,1,buf(1,2),b)
+          do i=1,b
+            x(k+i-1,j) = cmplx(buf(i,1), buf(i,2))
+          end do
+        end do
+      end do
       end subroutine
 
       subroutine zrandg(m,n,x,ldx)
       integer m,n,ldx
       double complex x(ldx,*)
+      double precision buf(128,2)
+      integer j,k,b,i
       external srandg
-      call drandg(2*m,n,x,2*ldx)
+      do j=1,n
+        do k=1,m,128
+          b=min(m-k+1,128)
+          call drandg(b,1,buf(1,1),b)
+          call drandg(b,1,buf(1,2),b)
+          do i=1,b
+            x(k+i-1,j) = cmplx(buf(i,1), buf(i,2))
+          end do
+        end do
+      end do
       end subroutine
 
       block data xrandi
@@ -218,12 +248,16 @@ c
  1002 format (1x,F6.3,SP,F6.3,'i',$)
       end subroutine
 
+c 200*?lamch('p') is a bit tight, some tests are at the fringe, being pushed
+c over by details of the random number generation. Trying 250 as error
+c limit factor.
+
       character*4 function spftol(rnrm)
       real rnrm,slamch
       external slamch
       common /stats/ passed,failed
       integer passed,failed
-      if (rnrm < 2e2*slamch('p')) then
+      if (rnrm < 2.5e2*slamch('p')) then
         spftol = 'PASS'
         passed = passed + 1
       else
@@ -237,7 +271,7 @@ c
       external dlamch
       common /stats/ passed,failed
       integer passed,failed
-      if (rnrm < 2d2*dlamch('p')) then
+      if (rnrm < 2.5d2*dlamch('p')) then
         dpftol = 'PASS'
         passed = passed + 1
       else