1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
Author: Andreas Tille <tille@debian.org>
Author: Sébastien Villemot <sebastien@debian.org>
Last-Update: 2017-09-10
Description: Use Debian package for BLAS/LAPACK (instead of obsolete clapack)
- Use -lblas instead of -lblaswr
- Use -ltmglib instead of -ltmg
- Do not use f2c, not needed
- Introduce prototypes for LAPACK functions used in the package
(those are documented in the manpages from the liblapack-doc package)
Forwarded: https://github.com/CshlSiepelLab/phast/issues/48
--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -12,29 +12,9 @@
ifdef CLAPACKPATH # only do below if using CLAPACK
-all: liblinks phastlib
-
-sharedlib: liblinks sharedphastlib
-
-# by default, CLAPACK uses non-standard library names, which confuses
-# the compiler. We'll just create symbolic links in ${PHAST}/lib that
-# have proper names
-liblinks: ${PHAST}/lib/liblapack.a ${PHAST}/lib/libtmg.a \
- ${PHAST}/lib/libblaswr.a
-
-${PHAST}/lib/liblapack.a: ${CLAPACKPATH}/lapack${PLAT}.a
- mkdir -p ${PHAST}/lib
- ${LN} -s $< $@
-
-${PHAST}/lib/libtmg.a: ${CLAPACKPATH}/tmglib${PLAT}.a
- mkdir -p ${PHAST}/lib
- ${LN} -s $< $@
-
-${PHAST}/lib/libblaswr.a: ${CLAPACKPATH}/blas${PLAT}.a
- mkdir -p ${PHAST}/lib
- ${LN} -s $< $@
+all: phastlib
-else # no CLAPACK: links not necessary
+sharedlib: sharedphastlib
all: phastlib
--- a/src/make-include.mk
+++ b/src/make-include.mk
@@ -120,8 +120,6 @@
# PLAT is empty for windows builds
PLAT =
endif
- # F2C libraries used by CLAPACK; most users won't need to edit
- F2CPATH = ${CLAPACKPATH}/F2CLIBS
endif
# if neither VECLIB nor CLAPACKPATH is defined, then LAPACK will be
@@ -139,8 +137,7 @@
else
ifdef CLAPACKPATH
ifneq ($(TARGETOS), Windows)
- CFLAGS += -I${CLAPACKPATH}/INCLUDE -I${F2CPATH}
- LIBS = -lphast -llapack -ltmg -lblaswr -lc -lf2c -lm
+ LIBS = -lphast -llapack -ltmglib -lblas -lc -lm
else
CFLAGS += -I${CLAPACKPATH}/INCLUDE -I${F2CPATH} -DPCRE_STATIC
LIBS = -lphast -lm ${CLAPACKPATH}/liblapack.a ${CLAPACKPATH}/libf2c.a ${CLAPACKPATH}/libblas.a
@@ -149,7 +146,6 @@
# older than 3.1.1
#CFLAGS += -I${CLAPACKPATH} -I${F2CPATH}
#LIBS = -lphast -llapack -ltmg -lblaswr -lc -lF77 -lI77 -lm
-LIBPATH += -L${F2CPATH}
# bypass
else
--- a/include/phast/external_libs.h
+++ b/include/phast/external_libs.h
@@ -39,10 +39,8 @@
#else
#ifndef SKIP_LAPACK
-#include <f2c.h>
-#include <clapack.h>
-#define LAPACK_INT integer
-#define LAPACK_DOUBLE doublereal
+#define LAPACK_INT int
+#define LAPACK_DOUBLE double
#endif /*ifndef SKIP_LAPACK */
#endif /*ifdef VECLIB */
--- a/src/lib/base/phast_eigen.c
+++ b/src/lib/base/phast_eigen.c
@@ -19,7 +19,7 @@
#include <math.h>
#include <phast/external_libs.h>
#include <phast/misc.h>
-
+#include <lapack.h>
/* Diagonalize a square, real, nonsymmetric matrix. Computes vector
of eigenvalues and matrices of right and left eigenvectors,
@@ -59,7 +59,7 @@
F77_CALL(dgeev)(&jobvl, &jobvr, &n, tmp, &n, wr, wi, vl, &n,
vr, &n, work, &lwork, &info);
#else
- dgeev_(&jobvl, &jobvr, &n, tmp, &n, wr, wi, vl,
+ LAPACK_dgeev(&jobvl, &jobvr, &n, tmp, &n, wr, wi, vl,
&n, vr, &n, work, &lwork, &info);
#endif
@@ -196,7 +196,7 @@
F77_CALL(dgeev)(&jobvl, &jobvr, &n, tmp, &n, wr, wi, NULL,
&n, NULL, &n, work, &lwork, &info);
#else
- dgeev_(&jobvl, &jobvr, &n, tmp, &n, wr, wi, NULL,
+ LAPACK_dgeev(&jobvl, &jobvr, &n, tmp, &n, wr, wi, NULL,
&n, NULL, &n, work, &lwork, &info);
#endif
--- a/src/lib/base/phast_markov_matrix.c
+++ b/src/lib/base/phast_markov_matrix.c
@@ -21,6 +21,7 @@
#include <phast/eigen.h>
#include <phast/prob_vector.h>
#include <phast/external_libs.h>
+#include <lapack.h>
#define SUM_EPSILON 0.0001
#define ELEMENT_EPSILON 0.00001
@@ -285,7 +286,7 @@
#ifdef R_LAPACK
F77_CALL(dgebal)(&job, &ln, mat, &ln, &ilo, &ihi, scale, &info);
#else
- dgebal_(&job, &ln, mat, &ln, &ilo, &ihi, scale, &info);
+ LAPACK_dgebal(&job, &ln, mat, &ln, &ilo, &ihi, scale, &info);
#endif
if (info != 0)
die("Error in balancing matrix in lapack routine dgebal info=%i\n", info);
@@ -400,7 +401,7 @@
#ifdef R_LAPACK
F77_CALL(dgesv)(&ln, &ln, matU, &ln, ipiv, matV, &ln, &info);
#else
- dgesv_(&ln, &ln, matU, &ln, ipiv, matV, &ln, &info);
+ LAPACK_dgesv(&ln, &ln, matU, &ln, ipiv, matV, &ln, &info);
#endif
if (info !=0)
die("Error solving U'X=V' in mm_exp_higham");
@@ -425,7 +426,7 @@
#ifdef R_LAPACK
F77_CALL(dgebak)(&job, &side, &ln, &ilo, &ihi, scale, &ln, mat, &ln, &info);
#else
- dgebak_(&job, &side, &ln, &ilo, &ihi, scale, &ln, mat, &ln, &info);
+ LAPACK_dgebak(&job, &side, &ln, &ilo, &ihi, scale, &ln, mat, &ln, &info);
#endif
mat_from_lapack(P->matrix, mat);
}
--- a/src/lib/base/phast_matrix.c
+++ b/src/lib/base/phast_matrix.c
@@ -15,6 +15,7 @@
#include <phast/external_libs.h>
#include <math.h>
#include <phast/misc.h>
+#include <lapack.h>
Matrix *mat_new(int nrows, int ncols) {
int i;
@@ -260,7 +261,7 @@
#ifdef R_LAPACK
F77_CALL(dgetrf)(&n, &n, (LAPACK_DOUBLE*)tmp, &n, ipiv, &info);
#else
- dgetrf_(&n, &n, (LAPACK_DOUBLE*)tmp, &n, ipiv, &info);
+ LAPACK_dgetrf(&n, &n, (LAPACK_DOUBLE*)tmp, &n, ipiv, &info);
#endif
if (info != 0) {
@@ -270,7 +271,7 @@
#ifdef R_LAPACK
F77_CALL(dgetri)(&n, (LAPACK_DOUBLE*)tmp, &n, ipiv, work, &lwork, &info);
#else
- dgetri_(&n, (LAPACK_DOUBLE*)tmp, &n, ipiv, work, &lwork, &info);
+ LAPACK_dgetri(&n, (LAPACK_DOUBLE*)tmp, &n, ipiv, work, &lwork, &info);
#endif
if (info != 0) {
|