Ticket #748: iml-1.0.3.p0.diff
File iml-1.0.3.p0.diff, 16.2 KB (added by , 9 years ago) |
---|
-
SPKG.txt
# HG changeset patch # User Jeroen Demeyer <jdemeyer@cage.ugent.be> # Date 1371040536 -7200 # Node ID e4789dc8b03d111f9a5ce5eca1c854f7282b606a # Parent f50311951edb14bc77af9d025fbf66ea955b95a4 Trac #748: Upgrade to version 1.0.3. diff --git a/SPKG.txt b/SPKG.txt
a b 27 27 28 28 == Special Update/Build Instructions == 29 29 30 * Sage's current version is fairly out of date. As of June 2013, the31 latest upstream release is 1.0.3 (dated July 28th 2008).32 30 * Various files should be made executable. Run spkg-src after 33 31 extracting the sources to src/ to fix this. 34 32 35 33 === Patches === 36 34 37 * rename_lift.patch: Change lift to iml_lift in padiclift.* and 38 nonsingsolve.*, since otherwise on OSX you'll have horrible weird 39 conflict problems. 40 * Modified some of the examples, and made build scripts that work. 35 * blas_headers.patch: Add BLAS header files from GSL, needed in case 36 ATLAS has not been installed. 37 * build.patch: Made build scripts that work. 38 * configure_default_cflags.patch: get rid of the following error 39 during configure: 40 ./configure: line 18624: -O3: command not found 41 * examples.patch: Modified some of the examples. 42 * memleak.patch: use mpz_set_ui instead of mpz_init_set_ui on mpz 43 which is already allocated. 44 * remove_repl.patch: Do not build/install src/repl at all, since it 45 does nothing anyway and creating empty archives fails on OS X. 41 46 42 47 == Changelog == 43 48 49 === iml-1.0.3.p0 (Jeroen Demeyer, 12 June 2013) === 50 * #748: Upgrade to latest upstream version, rebase patches. 51 * Remove rename_lift.patch and sage2.patch, which were upstreamed. 52 * Removed tinyatlas.patch and #include "tinyatlas.h" 53 * Removed sage1.patch 54 * Apply sage3_memleak.patch in all 3 places with similar code, rename 55 to memleak.patch 56 * Use -O3 optimization level by default. 57 * Add configure_default_cflags.patch. 58 44 59 === iml-1.0.1.p15 (Jean-Pierre Flori, Jeroen Demeyer, 11 June 2013) === 45 60 * #14699: Cleanup spkg, restore upstream sources, moved patches 46 61 into patch files in patches/ -
patches/build.patch
diff --git a/patches/build.patch b/patches/build.patch
a b 1 diff -ruN a/src/Makefile.in b/src/Makefile.in 2 --- a/src/Makefile.in 2006-11-26 15:45:53.000000000 +0100 3 +++ b/src/Makefile.in 2013-06-11 08:27:59.432406016 +0200 4 @@ -94,8 +94,8 @@ 5 AMDEP_TRUE = @AMDEP_TRUE@ 6 AMTAR = @AMTAR@ 7 AR = @AR@ 8 -ATLAS_CFLAGS = @ATLAS_CFLAGS@ 9 -ATLAS_LIBS = @ATLAS_LIBS@ 10 +ATLAS_CFLAGS = 11 +ATLAS_LIBS = 12 AUTOCONF = @AUTOCONF@ 13 AUTOHEADER = @AUTOHEADER@ 14 AUTOMAKE = @AUTOMAKE@ 15 diff -ruN a/Makefile.in b/Makefile.in 16 --- a/Makefile.in 2006-11-26 15:45:52.000000000 +0100 17 +++ b/Makefile.in 2013-06-11 08:27:59.432406016 +0200 1 diff -ruN src/Makefile.in b/Makefile.in 2 --- src/Makefile.in 2008-07-28 16:53:18.000000000 +0200 3 +++ b/Makefile.in 2013-06-12 14:55:49.462405872 +0200 18 4 @@ -79,8 +79,8 @@ 19 5 AMDEP_TRUE = @AMDEP_TRUE@ 20 6 AMTAR = @AMTAR@ … … 26 12 AUTOCONF = @AUTOCONF@ 27 13 AUTOHEADER = @AUTOHEADER@ 28 14 AUTOMAKE = @AUTOMAKE@ 29 diff -ruN a/configure b/configure30 --- a/configure 2006-11-23 22:27:13.000000000 +010031 +++ b/configure 20 07-03-06 17:56:30.000000000 +010032 @@ -200 40,15 +20040,15 @@15 diff -ruN src/configure b/configure 16 --- src/configure 2008-06-16 01:52:33.000000000 +0200 17 +++ b/configure 2013-06-12 14:55:49.962394579 +0200 18 @@ -20000,15 +20000,15 @@ 33 19 sed 's/^/| /' conftest.$ac_ext >&5 34 20 35 21 … … 54 40 55 41 fi 56 42 rm -f conftest.err conftest.$ac_objext \ 57 @@ -200 84,23 +20084,23 @@43 @@ -20044,23 +20044,23 @@ 58 44 elif test -n "$atlas_problem"; then 59 45 echo "$as_me:$LINENO: result: problem" >&5 60 46 echo "${ECHO_T}problem" >&6 … … 95 81 fi 96 82 97 83 CFLAGS=${BACKUP_CFLAGS} 84 diff -ruN src/src/Makefile.in b/src/Makefile.in 85 --- src/src/Makefile.in 2008-07-28 16:53:18.000000000 +0200 86 +++ b/src/Makefile.in 2013-06-12 14:55:49.962394579 +0200 87 @@ -94,8 +94,8 @@ 88 AMDEP_TRUE = @AMDEP_TRUE@ 89 AMTAR = @AMTAR@ 90 AR = @AR@ 91 -ATLAS_CFLAGS = @ATLAS_CFLAGS@ 92 -ATLAS_LIBS = @ATLAS_LIBS@ 93 +ATLAS_CFLAGS = 94 +ATLAS_LIBS = 95 AUTOCONF = @AUTOCONF@ 96 AUTOHEADER = @AUTOHEADER@ 97 AUTOMAKE = @AUTOMAKE@ -
new file patches/configure_default_cflags.patch
diff --git a/patches/configure_default_cflags.patch b/patches/configure_default_cflags.patch new file mode 100644
- + 1 diff -ru src/configure b/configure 2 --- src/configure 2008-06-16 01:52:33.000000000 +0200 3 +++ b/configure 2013-06-12 18:12:47.002405386 +0200 4 @@ -18621,8 +18621,7 @@ 5 6 7 DEFAULT_CFLAGS="-O3 -Wall" 8 -${CFLAGS:=$DEFAULT_CFLAGS} 9 -CFLAGS="-I. ${CFLAGS}" 10 +CFLAGS="-I. ${CFLAGS:-$DEFAULT_CFLAGS}" 11 12 13 -
patches/examples.patch
diff --git a/patches/examples.patch b/patches/examples.patch
a b 17 17 18 18 /* generate a n x m random left hand side matrix A */ 19 19 n = 5; 20 - m = 8;21 - bd = 16; /* entris of A satisfying -2^bd < e < 2^bd */20 - m = 10; 21 - bd = 34; /* entris of A satisfying -2^bd < e < 2^bd */ 22 22 + m = 6; 23 23 + bd = 3; /* entris of A satisfying -2^bd < e < 2^bd */ 24 24 A = randomLongMat (n, m, bd); -
.patch
diff --git a/patches/sage3_memleak.patch b/patches/memleak.patch rename from patches/sage3_memleak.patch rename to patches/memleak.patch
old new 1 --- a/src/nullspace.c 2013-06-10 23:44:52.982405509 +0200 2 +++ b/src/nullspace.c 2007-10-23 17:59:19.000000000 +0200 3 @@ -251,7 +251,7 @@ 1 diff -ru src/src/nullspace.c b/src/nullspace.c 2 --- src/src/nullspace.c 2008-06-16 00:26:25.000000000 +0200 3 +++ b/src/nullspace.c 2013-06-12 14:28:39.382392511 +0200 4 @@ -109,7 +109,7 @@ 4 5 for (i = 0; i < m; i++) { 5 6 for (j = 0; j < m; j++) 6 7 mpz_init_set_ui(mp_N[i * m + j], 0); … … 9 10 } 10 11 *mp_N_pass = mp_N; 11 12 } else { /* r>0 and s>0 */ 13 @@ -253,7 +253,7 @@ 14 for (i = 0; i < m; i++) { 15 for (j = 0; j < m; j++) 16 mpz_init_set_ui(mp_N[i * m + j], 0); 17 - mpz_init_ui(mp_N[i * m + i], 1); 18 + mpz_set_ui(mp_N[i * m + i], 1); 19 } 20 *mp_N_pass = mp_N; 21 } else { /* r>0 and s>0 */ 22 @@ -400,7 +400,7 @@ 23 for (i = 0; i < m; i++) { 24 for (j = 0; j < m; j++) 25 mpz_init_set_ui(mp_N[i * m + j], 0); 26 - mpz_init_set_ui(mp_N[i * m + i], 1); 27 + mpz_set_ui(mp_N[i * m + i], 1); 28 } 29 *mp_N_pass = mp_N; 30 } else { /* r>0 and s>0 */ -
deleted file patches/rename_lift.patch
diff --git a/patches/rename_lift.patch b/patches/rename_lift.patch deleted file mode 100644
+ - 1 diff -ruN a/src/nonsysolve.c b/src/nonsysolve.c2 --- a/src/nonsysolve.c 2006-11-23 22:25:23.000000000 +01003 +++ b/src/nonsysolve.c 2013-06-10 23:07:48.882393429 +02004 @@ -188,7 +188,7 @@5 #endif6 7 /* lifting kincr more steps */8 - C1 = lift(solupos, kincr, n, m, basislen, extbasislen, mp_basisprod, \9 + C1 = iml_lift(solupos, kincr, n, m, basislen, extbasislen, mp_basisprod, \10 mp_extbasisprod, liftbasis, cmbasis, extbdcoeff, liftbasisInv, \11 mp_r, extbasis, AInv, ARNS);12 13 @@ -396,7 +396,7 @@14 C = NULL;15 do {16 /* lifting kincr more steps */17 - C1 = lift(solupos, kincr, n, m, basislen, extbasislen, mp_basisprod, \18 + C1 = iml_lift(solupos, kincr, n, m, basislen, extbasislen, mp_basisprod, \19 mp_extbasisprod, liftbasis, cmbasis, extbdcoeff, liftbasisInv, \20 mp_r, extbasis, AInv, ARNS);21 22 @@ -617,7 +617,7 @@23 #endif24 25 /* lifting kincr more steps */26 - C1 = lift(solupos, kincr, n, m, liftbasislen, extbasislen, \27 + C1 = iml_lift(solupos, kincr, n, m, liftbasislen, extbasislen, \28 mp_liftbasisprod, mp_extbasisprod, liftbasis, cmliftbasis, \29 extbdcoeff, liftbasisInv, mp_r, extbasis, AInv, AExtRNS);30 31 diff -ruN a/src/padiclift.c b/src/padiclift.c32 --- a/src/padiclift.c 2006-11-23 22:25:23.000000000 +010033 +++ b/src/padiclift.c 2013-06-10 23:07:48.882393429 +020034 @@ -446,7 +446,7 @@35 */36 37 Double ***38 -lift (const enum SOLU_POS solupos, const long k, const long n, \39 +iml_lift (const enum SOLU_POS solupos, const long k, const long n, \40 const long m, const long liftbasislen, const long extbasislen, \41 const mpz_t mp_basisprod, const mpz_t mp_extbasisprod, \42 const FiniteField *liftbasis, const FiniteField *cmbasis, \43 diff -ruN a/src/padiclift.h b/src/padiclift.h44 --- a/src/padiclift.h 2006-11-23 22:25:24.000000000 +010045 +++ b/src/padiclift.h 2013-06-10 23:07:48.882393429 +020046 @@ -95,7 +95,7 @@47 Double **AInv, FiniteField ***extbasis, Double ***AExtRNS);48 49 50 -Double*** lift(const enum SOLU_POS solupos, const long k, const long n, \51 +Double*** iml_lift(const enum SOLU_POS solupos, const long k, const long n, \52 const long m, const long liftbasislen, const long extbasislen, \53 const mpz_t mp_basisprod, const mpz_t mp_extbasisprod, \54 const FiniteField *liftbasis, const FiniteField *cmbasis, \ -
deleted file patches/sage1.patch
diff --git a/patches/sage1.patch b/patches/sage1.patch deleted file mode 100644
+ - 1 diff -ruN b/src/RNSop.c a/src/RNSop.c2 --- b/src/RNSop.c 2006-11-23 22:25:23.000000000 +01003 +++ a/src/RNSop.c 2013-06-10 23:05:18.872404179 +02004 @@ -46,6 +46,7 @@5 6 7 #include "RNSop.h"8 +#include "tinyatlas.h"9 10 /*11 *12 diff -ruN b/src/memalloc.c a/src/memalloc.c13 --- b/src/memalloc.c 2006-11-23 22:25:23.000000000 +010014 +++ a/src/memalloc.c 2013-06-10 23:05:18.872404179 +020015 @@ -48,13 +48,16 @@16 17 #include "error.h"18 #include "common.h"19 +#include "stdio.h"20 21 void *22 xmalloc (size_t num)23 {24 void * new = malloc(num);25 - if (!new)26 - iml_fatal ("Memory exhausted");27 + if (!new) {28 + printf("%ul\n", num);29 + iml_fatal ("Memory exhausted in xmalloc");30 + }31 return new;32 }33 34 @@ -65,8 +68,10 @@35 if (!p)36 return xmalloc(num);37 new = realloc(p, num);38 - if (!new)39 - iml_fatal("Memory exhausted");40 + if (!new) {41 + printf("%ul\n", num);42 + iml_fatal("Memory exhausted in xrealloc");43 + }44 return new;45 }46 47 @@ -76,8 +81,10 @@48 {49 #if HAVE_CALLOC50 void * new = calloc(num, size);51 - if (!new)52 - iml_fatal("Memory exhausted");53 + if (!new) {54 + printf("%ul\n", num);55 + iml_fatal("Memory exhausted in xcalloc");56 + }57 #else58 void * new = xmalloc(num*size);59 bzero(new, num*size);60 diff -ruN b/src/nullspace.c a/src/nullspace.c61 --- b/src/nullspace.c 2006-11-26 04:34:23.000000000 +010062 +++ a/src/nullspace.c 2013-06-10 23:05:18.872404179 +020063 @@ -44,7 +44,6 @@64 *65 */66 67 -68 #include "nullspace.h"69 70 /*71 @@ -187,3 +186,143 @@72 return s;73 74 }75 +76 +/*77 + * Calling Sequence:78 + * nullspaceLong(n, m, A, mp_N_pass)79 + *80 + * Summary: Compute the right nullspace of A. In this function A is a81 + * 1-dimensional mpz_t array.82 + *83 + * Input: n: long, row dimension of A84 + * m: long, column dimension of A85 + * A: 1-dim mpz_t array length n*m, representing n x m matrix86 + * in row major order87 + *88 + * Output:89 + * - *mp_N_pass: points to a 1-dim mpz_t array of length m*s, where s is the90 + * dimension of the right nullspace of A91 + * - the dimension s of the nullspace is returned92 + *93 + * Notes:94 + * - The matrix A is represented by one-dimension array in row major order.95 + * - Space for what mp_N_points to is allocated by this procedure: if the96 + * nullspace is empty, mp_N_pass is set to NULL.97 + */98 +99 +long100 +nullspaceMP(const long n, const long m, const mpz_t *A, mpz_t * *mp_N_pass)101 +{102 + long i, j, k, r, s, *P, *rp, *Pt, *rpt, flag, temp;103 + double *DA;104 + FiniteField p, d = 1;105 + mpz_t *mp_B, *mp_N, mp_D, mp_t1, mp_t2, *C, mp_r;106 +107 + mpz_init(mp_r);108 +109 + P = XCALLOC(long, n + 1);110 + rp = XCALLOC(long, n + 1);111 + while (1) {112 + p = RandPrime(15, 19);113 + DA = XCALLOC(double, n * m);114 + for (i = 0; i < n * m; i++) {115 + mpz_mod_ui (mp_r, A[i], p);116 + DA[i] = mpz_get_d(mp_r);117 + }118 + for (i = 0; i < n + 1; i++) {119 + P[i] = i;120 + rp[i] = 0;121 + }122 + d = 1;123 + RowEchelonTransform(p, DA, n, m, 1, 1, 0, 0, P, rp, &d);124 + XFREE(DA);125 + r = rp[0];126 + s = m - r;127 + if (s == 0) {128 + *mp_N_pass = NULL;129 + } else if (r == 0) {130 + flag = 1;131 + for (i = 0; i < n * m; i++)132 + if ( mpz_cmp_si(A[i],0) )133 + flag = 0;134 + if (!flag)135 + continue;136 + mp_N = XCALLOC(mpz_t, m * m);137 + for (i = 0; i < m; i++) {138 + for (j = 0; j < m; j++)139 + mpz_init_set_ui(mp_N[i * m + j], 0);140 + mpz_init_set_ui(mp_N[i * m + i], 1);141 + }142 + *mp_N_pass = mp_N;143 + } else { /* r>0 and s>0 */144 +145 + Pt = revseq(r, n, P);146 + rpt = revseq(r, m, rp);147 +148 + C = XCALLOC(mpz_t, r * r);149 + for (i = 0; i < r; i++)150 + for (j = 0; j < r; j++)151 + mpz_init_set(C[i * r + j], A[Pt[i] * m + rpt[j]]);152 +153 + mp_B = XCALLOC(mpz_t, r * s);154 + for (i = 0; i < r; i++)155 + for (j = 0; j < s; j++)156 + mpz_init_set(mp_B[i * s + j], A[Pt[i] * m + rpt[r + j]]);157 +158 + mpz_init(mp_D);159 + mp_N = XCALLOC(mpz_t, m * s);160 + for (i = 0; i < m * s; i++)161 + mpz_init(mp_N[i]);162 + nonsingSolvLlhsMM(RightSolu, r, s, C, mp_B, mp_N, mp_D);163 + mpz_neg(mp_D, mp_D);164 + for (i = 0; i < s; i++)165 + mpz_set(mp_N[(r + i) * s + i], mp_D);166 +167 + XFREE(C);168 + for (i = 0; i < r * s; i++)169 + mpz_clear(mp_B[i]);170 + XFREE(mp_B);171 + mpz_clear(mp_D);172 +173 + for (i = r; i >= 1; i--)174 + for (j = 0; j < s; j++)175 + mpz_swap(mp_N[(i - 1) * s + j],176 + mp_N[(rp[i] - 1) * s + j]);177 +178 + *mp_N_pass = mp_N;179 +180 + flag = 1;181 + mpz_init(mp_t1);182 + mpz_init(mp_t2);183 + for (i = r; i < n && flag; i++) {184 + for (j = 0; j < s && flag; j++) {185 + mpz_set_ui(mp_t2, 0);186 + for (k = 0; k < m; k++) {187 + mpz_mul(mp_t1, mp_N[k * s + j], A[Pt[i] * m + k]);188 + mpz_add(mp_t2, mp_t2, mp_t1);189 + }190 + if (mpz_sgn(mp_t2) != 0)191 + flag = 0;192 + }193 + }194 + mpz_clear(mp_t1);195 + mpz_clear(mp_t2);196 +197 + XFREE(Pt);198 + XFREE(rpt);199 +200 + if (!flag) {201 + for (i = 0; i < m * s; i++)202 + mpz_clear(mp_N[i]);203 + XFREE(mp_N);204 + continue;205 + }206 + }207 + break;208 + }209 + XFREE(P);210 + XFREE(rp);211 +212 + return s;213 +214 +} -
deleted file patches/sage2.patch
diff --git a/patches/sage2.patch b/patches/sage2.patch deleted file mode 100644
+ - 1 # HG changeset patch2 # User William Stein <wstein@gmail.com>3 # Date 1172736931 288004 # Node ID f0a617a1c36473f86e542406cba3e90778a45c495 # Parent 65361f8749433213043132225730e8aaef9a28906 Fix some memory leaks.7 8 --- a/src/nullspace.c9 +++ b/src/nullspace.c10 @@ -273,12 +273,18 @@11 mp_N = XCALLOC(mpz_t, m * s);12 for (i = 0; i < m * s; i++)13 mpz_init(mp_N[i]);14 +15 +16 nonsingSolvLlhsMM(RightSolu, r, s, C, mp_B, mp_N, mp_D);17 +18 mpz_neg(mp_D, mp_D);19 for (i = 0; i < s; i++)20 mpz_set(mp_N[(r + i) * s + i], mp_D);21 22 + for (i = 0; i < r*r; i++)23 + mpz_clear(C[i]);24 XFREE(C);25 +26 for (i = 0; i < r * s; i++)27 mpz_clear(mp_B[i]);28 XFREE(mp_B);29 @@ -323,6 +329,7 @@30 XFREE(P);31 XFREE(rp);32 33 + mpz_clear(mp_r);34 return s;35 36 } -
deleted file patches/tinyatlas.patch
diff --git a/patches/tinyatlas.patch b/patches/tinyatlas.patch deleted file mode 100644
+ - 1 diff -ruN iml-1.0.1-sage/src/tinyatlas.h src/src/tinyatlas.h2 --- iml-1.0.1-sage/src/tinyatlas.h 1970-01-01 01:00:00.000000000 +01003 +++ src/src/tinyatlas.h 2007-03-01 04:11:42.000000000 +01004 @@ -0,0 +1,17 @@5 +/*6 +Compute Y = alpha * X + beta * Y7 +8 +where9 + N = degree of each vector10 + incX = X stride11 + incY = Y stride12 +*/13 +14 +void catlas_daxpby(const int N, const double alpha, const double *X,15 +const int incX, const double beta, double *Y, const int incY)16 +{17 + int i;18 + for(i=0; i < N; i++) {19 + Y[i*incY] = alpha * X[i*incX] + beta * Y[i*incY];20 + }21 +} -
spkg-install
diff --git a/spkg-install b/spkg-install
a b 23 23 echo "Building a debug version of IML." 24 24 export CFLAGS="-O0 -g $CFLAGS" 25 25 else 26 export CFLAGS="-O 2-g $CFLAGS"26 export CFLAGS="-O3 -g $CFLAGS" 27 27 fi 28 28 29 29 if [ "$SAGE64" = "yes" ]; then -
spkg-src
diff --git a/spkg-src b/spkg-src
a b 4 4 5 5 # Make various files executable 6 6 cd src 7 chmod ugo+x bootstrap configure8 chmod ugo+x config/compile config/depcomp config/ install-sh config/ltmain.sh config/missing7 chmod ugo+x bootstrap 8 chmod ugo+x config/compile config/depcomp config/ltmain.sh config/missing 9 9