lbfgsb 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/lbfgsb/lbfgsbext.c +1 -0
- data/ext/lbfgsb/src/blas.c +4 -34
- data/ext/lbfgsb/src/blas.h +4 -5
- data/ext/lbfgsb/src/lbfgsb.c +44 -44
- data/ext/lbfgsb/src/linpack.c +7 -7
- data/ext/lbfgsb/src/linpack.h +2 -2
- data/lib/lbfgsb/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b3fbdad3f3976d24e542cdb86a2a8c2c4fdadf85948526c51e513dc2165343
|
4
|
+
data.tar.gz: 3a42da751483bb5b8d3940208b47da081388ba39c44c9cfc9b3eec0f41b6ec67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00ca5c403a6871799f94540e91fb8ee8cbdf921ab81510408c6c75465f5db7ea9b911048b78c56933bac7ada91a6264b5f704f6f805ba126bc25c572e7327020
|
7
|
+
data.tar.gz: 36e5bfa35fc9bf58bfb5cb008c5c2efa4460a9fc76119d48d7dd9f92f0e4d61b851281e8a752a4dbb89b41bbbb2e8abdcc186f55366d3f115b2c861dad2617f8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
- Add library name prefix to functions derived from blas and linpack
|
3
|
+
to avoid errors due to collision with the blas functions called by numo-linalg.
|
4
|
+
|
1
5
|
## 0.2.0
|
2
6
|
- Add an option to minimize method for calculating both function value and gradient vector using fnc.
|
3
7
|
If true is given to jcb, fnc is assumed to return the function value and gardient vector as [f, g] array.
|
data/ext/lbfgsb/lbfgsbext.c
CHANGED
data/ext/lbfgsb/src/blas.c
CHANGED
@@ -5,37 +5,7 @@
|
|
5
5
|
*/
|
6
6
|
#include "blas.h"
|
7
7
|
|
8
|
-
|
9
|
-
{
|
10
|
-
long i__1, i__2;
|
11
|
-
double ret_val, d__1, d__2, d__3;
|
12
|
-
static long i__;
|
13
|
-
static double scale;
|
14
|
-
|
15
|
-
--x;
|
16
|
-
|
17
|
-
ret_val = 0.;
|
18
|
-
scale = 0.;
|
19
|
-
i__1 = *n;
|
20
|
-
i__2 = *incx;
|
21
|
-
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
|
22
|
-
d__2 = scale, d__3 = (d__1 = x[i__], fabs(d__1));
|
23
|
-
scale = d__2 >= d__3 ? d__2 : d__3;
|
24
|
-
}
|
25
|
-
if (scale == 0.) {
|
26
|
-
return ret_val;
|
27
|
-
}
|
28
|
-
i__2 = *n;
|
29
|
-
i__1 = *incx;
|
30
|
-
for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) {
|
31
|
-
d__1 = x[i__] / scale;
|
32
|
-
ret_val += d__1 * d__1;
|
33
|
-
}
|
34
|
-
ret_val = scale * sqrt(ret_val);
|
35
|
-
return ret_val;
|
36
|
-
}
|
37
|
-
|
38
|
-
int daxpy_(long *n, double *da, double *dx, long *incx, double *dy, long *incy)
|
8
|
+
int lbfgsb_rb_daxpy_(long *n, double *da, double *dx, long *incx, double *dy, long *incy)
|
39
9
|
{
|
40
10
|
long i__1;
|
41
11
|
static long i__, m, ix, iy, mp1;
|
@@ -100,7 +70,7 @@ L40:
|
|
100
70
|
return 0;
|
101
71
|
}
|
102
72
|
|
103
|
-
int
|
73
|
+
int lbfgsb_rb_dcopy_(long *n, double *dx, long *incx, double *dy, long *incy)
|
104
74
|
{
|
105
75
|
long i__1;
|
106
76
|
static long i__, m, ix, iy, mp1;
|
@@ -165,7 +135,7 @@ L40:
|
|
165
135
|
return 0;
|
166
136
|
}
|
167
137
|
|
168
|
-
double
|
138
|
+
double lbfgsb_rb_ddot_(long *n, double *dx, long *incx, double *dy, long *incy)
|
169
139
|
{
|
170
140
|
long i__1;
|
171
141
|
double ret_val;
|
@@ -232,7 +202,7 @@ L60:
|
|
232
202
|
return ret_val;
|
233
203
|
}
|
234
204
|
|
235
|
-
int
|
205
|
+
int lbfgsb_rb_dscal_(long *n, double *da, double *dx, long *incx)
|
236
206
|
{
|
237
207
|
long i__1, i__2;
|
238
208
|
static long i__, m, mp1, nincx;
|
data/ext/lbfgsb/src/blas.h
CHANGED
@@ -3,10 +3,9 @@
|
|
3
3
|
|
4
4
|
#include <math.h>
|
5
5
|
|
6
|
-
extern
|
7
|
-
extern int
|
8
|
-
extern
|
9
|
-
extern
|
10
|
-
extern int dscal_(long *n, double *da, double *dx, long *incx);
|
6
|
+
extern int lbfgsb_rb_daxpy_(long *n, double *da, double *dx, long *incx, double *dy, long *incy);
|
7
|
+
extern int lbfgsb_rb_dcopy_(long *n, double *dx, long *incx, double *dy, long *incy);
|
8
|
+
extern double lbfgsb_rb_ddot_(long *n, double *dx, long *incx, double *dy, long *incy);
|
9
|
+
extern int lbfgsb_rb_dscal_(long *n, double *da, double *dx, long *incx);
|
11
10
|
|
12
11
|
#endif /* LBFGSB_RB_BLAS_H_ */
|
data/ext/lbfgsb/src/lbfgsb.c
CHANGED
@@ -673,8 +673,8 @@ int mainlb_(long *n, long *m, double *x,
|
|
673
673
|
if (strncmp(task, "STOP", 4) == 0) {
|
674
674
|
if (strncmp(task + 6, "CPU", 3) == 0) {
|
675
675
|
/* restore the previous iterate. */
|
676
|
-
|
677
|
-
|
676
|
+
lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1);
|
677
|
+
lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &g[1], &c__1);
|
678
678
|
*f = fold;
|
679
679
|
}
|
680
680
|
goto L999;
|
@@ -709,7 +709,7 @@ L222:
|
|
709
709
|
|
710
710
|
if (! cnstnd && col > 0) {
|
711
711
|
/* skip the search for GCP. */
|
712
|
-
|
712
|
+
lbfgsb_rb_dcopy_(n, &x[1], &c__1, &z__[1], &c__1);
|
713
713
|
wrk = updatd;
|
714
714
|
nseg = 0;
|
715
715
|
goto L333;
|
@@ -834,8 +834,8 @@ L666:
|
|
834
834
|
csave, &isave[22], &dsave[17]);
|
835
835
|
if (info != 0 || iback >= 20) {
|
836
836
|
/* restore the previous iterate. */
|
837
|
-
|
838
|
-
|
837
|
+
lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1);
|
838
|
+
lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &g[1], &c__1);
|
839
839
|
*f = fold;
|
840
840
|
if (col == 0) {
|
841
841
|
/* abnormal termination. */
|
@@ -910,13 +910,13 @@ L777:
|
|
910
910
|
for (i__ = 1; i__ <= i__1; ++i__) {
|
911
911
|
r__[i__] = g[i__] - r__[i__];
|
912
912
|
}
|
913
|
-
rr =
|
913
|
+
rr = lbfgsb_rb_ddot_(n, &r__[1], &c__1, &r__[1], &c__1);
|
914
914
|
if (stp == 1.) {
|
915
915
|
dr = gd - gdold;
|
916
916
|
ddum = -gdold;
|
917
917
|
} else {
|
918
918
|
dr = (gd - gdold) * stp;
|
919
|
-
|
919
|
+
lbfgsb_rb_dscal_(n, &stp, &d__[1], &c__1);
|
920
920
|
ddum = -gdold * stp;
|
921
921
|
}
|
922
922
|
if (dr <= epsmch * ddum) {
|
@@ -1193,7 +1193,7 @@ int bmv_(long *m, double *sy, double *wt, long
|
|
1193
1193
|
p[i2] = v[i2] + sum;
|
1194
1194
|
}
|
1195
1195
|
/* Solve the triangular system */
|
1196
|
-
|
1196
|
+
lbfgsb_rb_dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__11, info);
|
1197
1197
|
if (*info != 0) {
|
1198
1198
|
return 0;
|
1199
1199
|
}
|
@@ -1205,7 +1205,7 @@ int bmv_(long *m, double *sy, double *wt, long
|
|
1205
1205
|
/* PART II: solve [ -D^(1/2) D^(-1/2)*L' ] [ p1 ] = [ p1 ] */
|
1206
1206
|
/* [ 0 J' ] [ p2 ] [ p2 ]. */
|
1207
1207
|
/* solve J^Tp2=p2. */
|
1208
|
-
|
1208
|
+
lbfgsb_rb_dtrsl_(&wt[wt_offset], m, col, &p[*col + 1], &c__1, info);
|
1209
1209
|
if (*info != 0) {
|
1210
1210
|
return 0;
|
1211
1211
|
}
|
@@ -1463,7 +1463,7 @@ int cauchy_(long *n, double *x, double *l,
|
|
1463
1463
|
if (*iprint >= 0) {
|
1464
1464
|
fprintf(stdout, " Subgnorm = 0. GCP = X.\n");
|
1465
1465
|
}
|
1466
|
-
|
1466
|
+
lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xcp[1], &c__1);
|
1467
1467
|
return 0;
|
1468
1468
|
}
|
1469
1469
|
bnded = TRUE_;
|
@@ -1562,10 +1562,10 @@ int cauchy_(long *n, double *x, double *l,
|
|
1562
1562
|
/* The smallest of the nbreak breakpoints is in t(ibkmin)=bkmin. */
|
1563
1563
|
if (*theta != 1.) {
|
1564
1564
|
/* complete the initialization of p for theta not= one. */
|
1565
|
-
|
1565
|
+
lbfgsb_rb_dscal_(col, theta, &p[*col + 1], &c__1);
|
1566
1566
|
}
|
1567
1567
|
/* Initialize GCP xcp = x. */
|
1568
|
-
|
1568
|
+
lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xcp[1], &c__1);
|
1569
1569
|
if (nbreak == 0 && nfree == *n + 1) {
|
1570
1570
|
/* is a zero vector, return with the initial xcp as GCP. */
|
1571
1571
|
if (*iprint > 100) {
|
@@ -1596,7 +1596,7 @@ int cauchy_(long *n, double *x, double *l,
|
|
1596
1596
|
if (*info != 0) {
|
1597
1597
|
return 0;
|
1598
1598
|
}
|
1599
|
-
f2 -=
|
1599
|
+
f2 -= lbfgsb_rb_ddot_(&col2, &v[1], &c__1, &p[1], &c__1);
|
1600
1600
|
}
|
1601
1601
|
dtm = -f1 / f2;
|
1602
1602
|
tsum = 0.;
|
@@ -1685,7 +1685,7 @@ L777:
|
|
1685
1685
|
f2 -= *theta * dibp2;
|
1686
1686
|
if (*col > 0) {
|
1687
1687
|
/* update c = c + dt*p. */
|
1688
|
-
|
1688
|
+
lbfgsb_rb_daxpy_(&col2, &dt, &p[1], &c__1, &c__[1], &c__1);
|
1689
1689
|
/* choose wbp, */
|
1690
1690
|
/* the row of W corresponding to the breakpoint encountered. */
|
1691
1691
|
pointr = *head;
|
@@ -1700,12 +1700,12 @@ L777:
|
|
1700
1700
|
if (*info != 0) {
|
1701
1701
|
return 0;
|
1702
1702
|
}
|
1703
|
-
wmc =
|
1704
|
-
wmp =
|
1705
|
-
wmw =
|
1703
|
+
wmc = lbfgsb_rb_ddot_(&col2, &c__[1], &c__1, &v[1], &c__1);
|
1704
|
+
wmp = lbfgsb_rb_ddot_(&col2, &p[1], &c__1, &v[1], &c__1);
|
1705
|
+
wmw = lbfgsb_rb_ddot_(&col2, &wbp[1], &c__1, &v[1], &c__1);
|
1706
1706
|
/* update p = p - dibp*wbp. */
|
1707
1707
|
d__1 = -dibp;
|
1708
|
-
|
1708
|
+
lbfgsb_rb_daxpy_(&col2, &d__1, &wbp[1], &c__1, &p[1], &c__1);
|
1709
1709
|
/* complete updating f1 and f2 while col > 0. */
|
1710
1710
|
f1 += dibp * wmc;
|
1711
1711
|
f2 = f2 + dibp * 2. * wmp - dibp2 * wmw;
|
@@ -1737,12 +1737,12 @@ L888:
|
|
1737
1737
|
tsum += dtm;
|
1738
1738
|
/* Move free variables (i.e., the ones w/o breakpoints) and */
|
1739
1739
|
/* the variables whose breakpoints haven't been reached. */
|
1740
|
-
|
1740
|
+
lbfgsb_rb_daxpy_(n, &tsum, &d__[1], &c__1, &xcp[1], &c__1);
|
1741
1741
|
L999:
|
1742
1742
|
/* Update c = c + dtm*p = W'(x^c - x) */
|
1743
1743
|
/* which will be used in computing r = Z'(B(x^c - x) + g). */
|
1744
1744
|
if (*col > 0) {
|
1745
|
-
|
1745
|
+
lbfgsb_rb_daxpy_(&col2, &dtm, &p[1], &c__1, &c__[1], &c__1);
|
1746
1746
|
}
|
1747
1747
|
if (*iprint > 100) {
|
1748
1748
|
fprintf(stdout, "Cauchy X = \n");
|
@@ -2060,11 +2060,11 @@ int formk_(long *n, long *nsub, long *ind, long *nenter,
|
|
2060
2060
|
for (jy = 1; jy <= i__1; ++jy) {
|
2061
2061
|
js = *m + jy;
|
2062
2062
|
i__2 = *m - jy;
|
2063
|
-
|
2063
|
+
lbfgsb_rb_dcopy_(&i__2, &wn1[jy + 1 + (jy + 1) * wn1_dim1], &c__1, &wn1[jy + jy * wn1_dim1], &c__1);
|
2064
2064
|
i__2 = *m - jy;
|
2065
|
-
|
2065
|
+
lbfgsb_rb_dcopy_(&i__2, &wn1[js + 1 + (js + 1) * wn1_dim1], &c__1, &wn1[js + js * wn1_dim1], &c__1);
|
2066
2066
|
i__2 = *m - 1;
|
2067
|
-
|
2067
|
+
lbfgsb_rb_dcopy_(&i__2, &wn1[*m + 2 + (jy + 1) * wn1_dim1], &c__1, &wn1[*m + 1 + jy * wn1_dim1], &c__1);
|
2068
2068
|
}
|
2069
2069
|
}
|
2070
2070
|
/* put new rows in blocks (1,1), (2,1) and (2,2). */
|
@@ -2215,7 +2215,7 @@ int formk_(long *n, long *nsub, long *ind, long *nenter,
|
|
2215
2215
|
/* [(-L_a +R_z)L'^-1 S'AA'S*theta ] */
|
2216
2216
|
/* first Cholesky factor (1,1) block of wn to get LL' */
|
2217
2217
|
/* with L' stored in the upper triangle of wn. */
|
2218
|
-
|
2218
|
+
lbfgsb_rb_dpofa_(&wn[wn_offset], &m2, col, info);
|
2219
2219
|
if (*info != 0) {
|
2220
2220
|
*info = -1;
|
2221
2221
|
return 0;
|
@@ -2224,7 +2224,7 @@ int formk_(long *n, long *nsub, long *ind, long *nenter,
|
|
2224
2224
|
col2 = *col << 1;
|
2225
2225
|
i__1 = col2;
|
2226
2226
|
for (js = *col + 1; js <= i__1; ++js) {
|
2227
|
-
|
2227
|
+
lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, col, &wn[js * wn_dim1 + 1], &c__11, info);
|
2228
2228
|
}
|
2229
2229
|
/* Form S'AA'S*theta + (L^-1(-L_a'+R_z'))'L^-1(-L_a'+R_z') in the */
|
2230
2230
|
/* upper triangle of (2,2) block of wn. */
|
@@ -2232,11 +2232,11 @@ int formk_(long *n, long *nsub, long *ind, long *nenter,
|
|
2232
2232
|
for (is = *col + 1; is <= i__1; ++is) {
|
2233
2233
|
i__2 = col2;
|
2234
2234
|
for (js = is; js <= i__2; ++js) {
|
2235
|
-
wn[is + js * wn_dim1] +=
|
2235
|
+
wn[is + js * wn_dim1] += lbfgsb_rb_ddot_(col, &wn[is * wn_dim1 + 1], &c__1, &wn[js * wn_dim1 + 1], &c__1);
|
2236
2236
|
}
|
2237
2237
|
}
|
2238
2238
|
/* Cholesky factorization of (2,2) block of wn. */
|
2239
|
-
|
2239
|
+
lbfgsb_rb_dpofa_(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info);
|
2240
2240
|
if (*info != 0) {
|
2241
2241
|
*info = -2;
|
2242
2242
|
return 0;
|
@@ -2303,7 +2303,7 @@ int formt_(long *m, double *wt, double *sy,
|
|
2303
2303
|
}
|
2304
2304
|
/* Cholesky factorize T to J*J' with */
|
2305
2305
|
/* J' stored in the upper triangle of wt. */
|
2306
|
-
|
2306
|
+
lbfgsb_rb_dpofa_(&wt[wt_offset], m, col, info);
|
2307
2307
|
if (*info != 0) {
|
2308
2308
|
*info = -3;
|
2309
2309
|
}
|
@@ -2563,7 +2563,7 @@ int lnsrlb_(long *n, double *l, double *u,
|
|
2563
2563
|
if (strncmp(task, "FG_LN", 5) == 0) {
|
2564
2564
|
goto L556;
|
2565
2565
|
}
|
2566
|
-
*dtd =
|
2566
|
+
*dtd = lbfgsb_rb_ddot_(n, &d__[1], &c__1, &d__[1], &c__1);
|
2567
2567
|
*dnorm = sqrt(*dtd);
|
2568
2568
|
/* Determine the maximum step length. */
|
2569
2569
|
*stpmx = 1e10;
|
@@ -2600,14 +2600,14 @@ int lnsrlb_(long *n, double *l, double *u,
|
|
2600
2600
|
} else {
|
2601
2601
|
*stp = 1.;
|
2602
2602
|
}
|
2603
|
-
|
2604
|
-
|
2603
|
+
lbfgsb_rb_dcopy_(n, &x[1], &c__1, &t[1], &c__1);
|
2604
|
+
lbfgsb_rb_dcopy_(n, &g[1], &c__1, &r__[1], &c__1);
|
2605
2605
|
*fold = *f;
|
2606
2606
|
*ifun = 0;
|
2607
2607
|
*iback = 0;
|
2608
2608
|
strcpy(csave, "START");
|
2609
2609
|
L556:
|
2610
|
-
*gd =
|
2610
|
+
*gd = lbfgsb_rb_ddot_(n, &g[1], &c__1, &d__[1], &c__1);
|
2611
2611
|
if (*ifun == 0) {
|
2612
2612
|
*gdold = *gd;
|
2613
2613
|
if (*gd >= 0.) {
|
@@ -2626,7 +2626,7 @@ L556:
|
|
2626
2626
|
++(*nfgv);
|
2627
2627
|
*iback = *ifun - 1;
|
2628
2628
|
if (*stp == 1.) {
|
2629
|
-
|
2629
|
+
lbfgsb_rb_dcopy_(n, &z__[1], &c__1, &x[1], &c__1);
|
2630
2630
|
} else {
|
2631
2631
|
i__1 = *n;
|
2632
2632
|
for (i__ = 1; i__ <= i__1; ++i__) {
|
@@ -2693,8 +2693,8 @@ int matupd_(long *n, long *m, double *ws,
|
|
2693
2693
|
*head = *head % *m + 1;
|
2694
2694
|
}
|
2695
2695
|
/* Update matrices WS and WY. */
|
2696
|
-
|
2697
|
-
|
2696
|
+
lbfgsb_rb_dcopy_(n, &d__[1], &c__1, &ws[*itail * ws_dim1 + 1], &c__1);
|
2697
|
+
lbfgsb_rb_dcopy_(n, &r__[1], &c__1, &wy[*itail * wy_dim1 + 1], &c__1);
|
2698
2698
|
/* Set theta=yy/ys. */
|
2699
2699
|
*theta = *rr / *dr;
|
2700
2700
|
/* Form the middle matrix in B. */
|
@@ -2704,9 +2704,9 @@ int matupd_(long *n, long *m, double *ws,
|
|
2704
2704
|
/* move old information */
|
2705
2705
|
i__1 = *col - 1;
|
2706
2706
|
for (j = 1; j <= i__1; ++j) {
|
2707
|
-
|
2707
|
+
lbfgsb_rb_dcopy_(&j, &ss[(j + 1) * ss_dim1 + 2], &c__1, &ss[j * ss_dim1 + 1], &c__1);
|
2708
2708
|
i__2 = *col - j;
|
2709
|
-
|
2709
|
+
lbfgsb_rb_dcopy_(&i__2, &sy[j + 1 + (j + 1) * sy_dim1], &c__1, &sy[j + j * sy_dim1], &c__1);
|
2710
2710
|
}
|
2711
2711
|
}
|
2712
2712
|
/* add new information: the last row of SY */
|
@@ -2714,8 +2714,8 @@ int matupd_(long *n, long *m, double *ws,
|
|
2714
2714
|
pointr = *head;
|
2715
2715
|
i__1 = *col - 1;
|
2716
2716
|
for (j = 1; j <= i__1; ++j) {
|
2717
|
-
sy[*col + j * sy_dim1] =
|
2718
|
-
ss[j + *col * ss_dim1] =
|
2717
|
+
sy[*col + j * sy_dim1] = lbfgsb_rb_ddot_(n, &d__[1], &c__1, &wy[pointr * wy_dim1 + 1], &c__1);
|
2718
|
+
ss[j + *col * ss_dim1] = lbfgsb_rb_ddot_(n, &ws[pointr * ws_dim1 + 1], &c__1, &d__[1], &c__1);
|
2719
2719
|
pointr = pointr % *m + 1;
|
2720
2720
|
}
|
2721
2721
|
if (*stp == 1.) {
|
@@ -3361,7 +3361,7 @@ int subsm_(long *n, long *m, long *nsub, long *ind,
|
|
3361
3361
|
/* Compute wv:=K^(-1)wv. */
|
3362
3362
|
m2 = *m << 1;
|
3363
3363
|
col2 = *col << 1;
|
3364
|
-
|
3364
|
+
lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__11, info);
|
3365
3365
|
if (*info != 0) {
|
3366
3366
|
return 0;
|
3367
3367
|
}
|
@@ -3369,7 +3369,7 @@ int subsm_(long *n, long *m, long *nsub, long *ind,
|
|
3369
3369
|
for (i__ = 1; i__ <= i__1; ++i__) {
|
3370
3370
|
wv[i__] = -wv[i__];
|
3371
3371
|
}
|
3372
|
-
|
3372
|
+
lbfgsb_rb_dtrsl_(&wn[wn_offset], &m2, &col2, &wv[1], &c__1, info);
|
3373
3373
|
if (*info != 0) {
|
3374
3374
|
return 0;
|
3375
3375
|
}
|
@@ -3387,12 +3387,12 @@ int subsm_(long *n, long *m, long *nsub, long *ind,
|
|
3387
3387
|
pointr = pointr % *m + 1;
|
3388
3388
|
}
|
3389
3389
|
d__1 = 1. / *theta;
|
3390
|
-
|
3390
|
+
lbfgsb_rb_dscal_(nsub, &d__1, &d__[1], &c__1);
|
3391
3391
|
|
3392
3392
|
/* ----------------------------------------------------------------- */
|
3393
3393
|
/* Let us try the projection, d is the Newton direction */
|
3394
3394
|
*iword = 0;
|
3395
|
-
|
3395
|
+
lbfgsb_rb_dcopy_(n, &x[1], &c__1, &xp[1], &c__1);
|
3396
3396
|
|
3397
3397
|
i__1 = *nsub;
|
3398
3398
|
for (i__ = 1; i__ <= i__1; ++i__) {
|
@@ -3445,7 +3445,7 @@ int subsm_(long *n, long *m, long *nsub, long *ind,
|
|
3445
3445
|
dd_p__ += (x[i__] - xx[i__]) * gg[i__];
|
3446
3446
|
}
|
3447
3447
|
if (dd_p__ > 0.) {
|
3448
|
-
|
3448
|
+
lbfgsb_rb_dcopy_(n, &xp[1], &c__1, &x[1], &c__1);
|
3449
3449
|
fprintf(stderr, " Positive dir derivative in projection\n");
|
3450
3450
|
fprintf(stderr, " Using the backtracking step\n");
|
3451
3451
|
} else {
|
data/ext/lbfgsb/src/linpack.c
CHANGED
@@ -44,7 +44,7 @@ static long c__1 = 1;
|
|
44
44
|
* linpack. this version dated 08/14/78 .
|
45
45
|
* cleve moler, university of new mexico, argonne national lab.
|
46
46
|
*/
|
47
|
-
int
|
47
|
+
int lbfgsb_rb_dpofa_(double *a, long *lda, long *n, long *info)
|
48
48
|
{
|
49
49
|
long a_dim1, a_offset, i__1, i__2, i__3;
|
50
50
|
static long j, k;
|
@@ -66,7 +66,7 @@ int dpofa_(double *a, long *lda, long *n, long *info)
|
|
66
66
|
i__2 = jm1;
|
67
67
|
for (k = 1; k <= i__2; ++k) {
|
68
68
|
i__3 = k - 1;
|
69
|
-
t = a[k + j * a_dim1] -
|
69
|
+
t = a[k + j * a_dim1] - lbfgsb_rb_ddot_(&i__3, &a[k * a_dim1 + 1], &c__1, &a[j * a_dim1 + 1], &c__1);
|
70
70
|
t /= a[k + k * a_dim1];
|
71
71
|
a[k + j * a_dim1] = t;
|
72
72
|
s += t * t;
|
@@ -133,7 +133,7 @@ L40:
|
|
133
133
|
* linpack. this version dated 08/14/78 .
|
134
134
|
* g. w. stewart, university of maryland, argonne national lab.
|
135
135
|
*/
|
136
|
-
int
|
136
|
+
int lbfgsb_rb_dtrsl_(double *t, long *ldt, long *n, double *b, long *job, long *info)
|
137
137
|
{
|
138
138
|
long t_dim1, t_offset, i__1, i__2;
|
139
139
|
static long j, jj, case__;
|
@@ -179,7 +179,7 @@ L20:
|
|
179
179
|
for (j = 2; j <= i__1; ++j) {
|
180
180
|
temp = -b[j - 1];
|
181
181
|
i__2 = *n - j + 1;
|
182
|
-
|
182
|
+
lbfgsb_rb_daxpy_(&i__2, &temp, &t[j + (j - 1) * t_dim1], &c__1, &b[j], &c__1);
|
183
183
|
b[j] /= t[j + j * t_dim1];
|
184
184
|
}
|
185
185
|
L40:
|
@@ -195,7 +195,7 @@ L50:
|
|
195
195
|
for (jj = 2; jj <= i__1; ++jj) {
|
196
196
|
j = *n - jj + 1;
|
197
197
|
temp = -b[j + 1];
|
198
|
-
|
198
|
+
lbfgsb_rb_daxpy_(&j, &temp, &t[(j + 1) * t_dim1 + 1], &c__1, &b[1], &c__1);
|
199
199
|
b[j] /= t[j + j * t_dim1];
|
200
200
|
}
|
201
201
|
L70:
|
@@ -211,7 +211,7 @@ L80:
|
|
211
211
|
for (jj = 2; jj <= i__1; ++jj) {
|
212
212
|
j = *n - jj + 1;
|
213
213
|
i__2 = jj - 1;
|
214
|
-
b[j] -=
|
214
|
+
b[j] -= lbfgsb_rb_ddot_(&i__2, &t[j + 1 + j * t_dim1], &c__1, &b[j + 1], &c__1);
|
215
215
|
b[j] /= t[j + j * t_dim1];
|
216
216
|
}
|
217
217
|
L100:
|
@@ -226,7 +226,7 @@ L110:
|
|
226
226
|
i__1 = *n;
|
227
227
|
for (j = 2; j <= i__1; ++j) {
|
228
228
|
i__2 = j - 1;
|
229
|
-
b[j] -=
|
229
|
+
b[j] -= lbfgsb_rb_ddot_(&i__2, &t[j * t_dim1 + 1], &c__1, &b[1], &c__1);
|
230
230
|
b[j] /= t[j + j * t_dim1];
|
231
231
|
}
|
232
232
|
L130:
|
data/ext/lbfgsb/src/linpack.h
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#include <math.h>
|
5
5
|
|
6
|
-
extern int
|
7
|
-
extern int
|
6
|
+
extern int lbfgsb_rb_dpofa_(double *a, long *lda, long *n, long *info);
|
7
|
+
extern int lbfgsb_rb_dtrsl_(double *t, long *ldt, long *n, double *b, long *job, long *info);
|
8
8
|
|
9
9
|
#endif /* LBFGSB_RB_LINPACK_H_ */
|
data/lib/lbfgsb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lbfgsb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.1.
|
80
|
+
rubygems_version: 3.1.4
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Lbfgsb.rb is a Ruby binding for L-BFGS-B
|