lbfgsb 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +149 -0
- data/.github/workflows/build.yml +2 -2
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -1
- data/Steepfile +20 -0
- data/ext/lbfgsb/lbfgsbext.c +8 -15
- data/ext/lbfgsb/lbfgsbext.h +1 -0
- data/ext/lbfgsb/src/blas.c +6 -10
- data/ext/lbfgsb/src/blas.h +4 -4
- data/ext/lbfgsb/src/lbfgsb.c +96 -176
- data/ext/lbfgsb/src/lbfgsb.h +68 -109
- data/ext/lbfgsb/src/linpack.c +55 -53
- data/ext/lbfgsb/src/linpack.h +2 -2
- data/lib/lbfgsb/version.rb +1 -1
- data/sig/lbfgsb.rbs +31 -0
- data/sig/patch.rbs +11 -0
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 209395124eb39ffdf43a87f346023646fa5367a66f382378542dabdc15668cdf
|
4
|
+
data.tar.gz: 9684de7283ba7ff88d6c8408dead7c8468f11e33b4a8010b1c837a2efeb635aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89cf143fe2b33ab916200814aed666bbcbe2de19852955bcb672ff065939657d2d82dde2e12b14d8cf79aa73d40aebba68d335dd49b68a302af311d7d45f3b3f
|
7
|
+
data.tar.gz: bca9b1a012e020669b1b491ff54a40230da72f70efbf8540945239b487d4d6b08fd2a7f3a11600736b40bc6a25f661ed040a0e8077f80273e17a484000a1c045
|
data/.clang-format
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
---
|
2
|
+
Language: Cpp
|
3
|
+
# BasedOnStyle: LLVM
|
4
|
+
AccessModifierOffset: -2
|
5
|
+
AlignAfterOpenBracket: Align
|
6
|
+
AlignConsecutiveMacros: false
|
7
|
+
AlignConsecutiveAssignments: false
|
8
|
+
AlignConsecutiveBitFields: false
|
9
|
+
AlignConsecutiveDeclarations: false
|
10
|
+
AlignEscapedNewlines: Right
|
11
|
+
AlignOperands: Align
|
12
|
+
AlignTrailingComments: true
|
13
|
+
AllowAllArgumentsOnNextLine: true
|
14
|
+
AllowAllConstructorInitializersOnNextLine: true
|
15
|
+
AllowAllParametersOfDeclarationOnNextLine: true
|
16
|
+
AllowShortEnumsOnASingleLine: true
|
17
|
+
AllowShortBlocksOnASingleLine: Never
|
18
|
+
AllowShortCaseLabelsOnASingleLine: false
|
19
|
+
AllowShortFunctionsOnASingleLine: All
|
20
|
+
AllowShortLambdasOnASingleLine: All
|
21
|
+
AllowShortIfStatementsOnASingleLine: Never
|
22
|
+
AllowShortLoopsOnASingleLine: false
|
23
|
+
AlwaysBreakAfterDefinitionReturnType: None
|
24
|
+
AlwaysBreakAfterReturnType: None
|
25
|
+
AlwaysBreakBeforeMultilineStrings: false
|
26
|
+
AlwaysBreakTemplateDeclarations: MultiLine
|
27
|
+
BinPackArguments: true
|
28
|
+
BinPackParameters: true
|
29
|
+
BraceWrapping:
|
30
|
+
AfterCaseLabel: false
|
31
|
+
AfterClass: false
|
32
|
+
AfterControlStatement: Never
|
33
|
+
AfterEnum: false
|
34
|
+
AfterFunction: false
|
35
|
+
AfterNamespace: false
|
36
|
+
AfterObjCDeclaration: false
|
37
|
+
AfterStruct: false
|
38
|
+
AfterUnion: false
|
39
|
+
AfterExternBlock: false
|
40
|
+
BeforeCatch: false
|
41
|
+
BeforeElse: false
|
42
|
+
BeforeLambdaBody: false
|
43
|
+
BeforeWhile: false
|
44
|
+
IndentBraces: false
|
45
|
+
SplitEmptyFunction: true
|
46
|
+
SplitEmptyRecord: true
|
47
|
+
SplitEmptyNamespace: true
|
48
|
+
BreakBeforeBinaryOperators: None
|
49
|
+
BreakBeforeBraces: Attach
|
50
|
+
BreakBeforeInheritanceComma: false
|
51
|
+
BreakInheritanceList: BeforeColon
|
52
|
+
BreakBeforeTernaryOperators: true
|
53
|
+
BreakConstructorInitializersBeforeComma: false
|
54
|
+
BreakConstructorInitializers: BeforeColon
|
55
|
+
BreakAfterJavaFieldAnnotations: false
|
56
|
+
BreakStringLiterals: true
|
57
|
+
ColumnLimit: 128
|
58
|
+
CommentPragmas: '^ IWYU pragma:'
|
59
|
+
CompactNamespaces: false
|
60
|
+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
61
|
+
ConstructorInitializerIndentWidth: 4
|
62
|
+
ContinuationIndentWidth: 4
|
63
|
+
Cpp11BracedListStyle: true
|
64
|
+
DeriveLineEnding: true
|
65
|
+
DerivePointerAlignment: false
|
66
|
+
DisableFormat: false
|
67
|
+
ExperimentalAutoDetectBinPacking: false
|
68
|
+
FixNamespaceComments: true
|
69
|
+
ForEachMacros:
|
70
|
+
- foreach
|
71
|
+
- Q_FOREACH
|
72
|
+
- BOOST_FOREACH
|
73
|
+
IncludeBlocks: Preserve
|
74
|
+
IncludeCategories:
|
75
|
+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
76
|
+
Priority: 2
|
77
|
+
SortPriority: 0
|
78
|
+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
79
|
+
Priority: 3
|
80
|
+
SortPriority: 0
|
81
|
+
- Regex: '.*'
|
82
|
+
Priority: 1
|
83
|
+
SortPriority: 0
|
84
|
+
IncludeIsMainRegex: '(Test)?$'
|
85
|
+
IncludeIsMainSourceRegex: ''
|
86
|
+
IndentCaseLabels: false
|
87
|
+
IndentCaseBlocks: false
|
88
|
+
IndentGotoLabels: true
|
89
|
+
IndentPPDirectives: None
|
90
|
+
IndentExternBlock: AfterExternBlock
|
91
|
+
IndentWidth: 2
|
92
|
+
IndentWrappedFunctionNames: false
|
93
|
+
InsertTrailingCommas: None
|
94
|
+
JavaScriptQuotes: Leave
|
95
|
+
JavaScriptWrapImports: true
|
96
|
+
KeepEmptyLinesAtTheStartOfBlocks: true
|
97
|
+
MacroBlockBegin: ''
|
98
|
+
MacroBlockEnd: ''
|
99
|
+
MaxEmptyLinesToKeep: 1
|
100
|
+
NamespaceIndentation: None
|
101
|
+
ObjCBinPackProtocolList: Auto
|
102
|
+
ObjCBlockIndentWidth: 2
|
103
|
+
ObjCBreakBeforeNestedBlockParam: true
|
104
|
+
ObjCSpaceAfterProperty: false
|
105
|
+
ObjCSpaceBeforeProtocolList: true
|
106
|
+
PenaltyBreakAssignment: 2
|
107
|
+
PenaltyBreakBeforeFirstCallParameter: 19
|
108
|
+
PenaltyBreakComment: 300
|
109
|
+
PenaltyBreakFirstLessLess: 120
|
110
|
+
PenaltyBreakString: 1000
|
111
|
+
PenaltyBreakTemplateDeclaration: 10
|
112
|
+
PenaltyExcessCharacter: 1000000
|
113
|
+
PenaltyReturnTypeOnItsOwnLine: 60
|
114
|
+
PointerAlignment: Left
|
115
|
+
ReflowComments: true
|
116
|
+
SortIncludes: true
|
117
|
+
SortUsingDeclarations: true
|
118
|
+
SpaceAfterCStyleCast: false
|
119
|
+
SpaceAfterLogicalNot: false
|
120
|
+
SpaceAfterTemplateKeyword: true
|
121
|
+
SpaceBeforeAssignmentOperators: true
|
122
|
+
SpaceBeforeCpp11BracedList: false
|
123
|
+
SpaceBeforeCtorInitializerColon: true
|
124
|
+
SpaceBeforeInheritanceColon: true
|
125
|
+
SpaceBeforeParens: ControlStatements
|
126
|
+
SpaceBeforeRangeBasedForLoopColon: true
|
127
|
+
SpaceInEmptyBlock: false
|
128
|
+
SpaceInEmptyParentheses: false
|
129
|
+
SpacesBeforeTrailingComments: 1
|
130
|
+
SpacesInAngles: false
|
131
|
+
SpacesInConditionalStatement: false
|
132
|
+
SpacesInContainerLiterals: true
|
133
|
+
SpacesInCStyleCastParentheses: false
|
134
|
+
SpacesInParentheses: false
|
135
|
+
SpacesInSquareBrackets: false
|
136
|
+
SpaceBeforeSquareBrackets: false
|
137
|
+
Standard: Latest
|
138
|
+
StatementMacros:
|
139
|
+
- Q_UNUSED
|
140
|
+
- QT_REQUIRE_VERSION
|
141
|
+
TabWidth: 8
|
142
|
+
UseCRLF: false
|
143
|
+
UseTab: Never
|
144
|
+
WhitespaceSensitiveMacros:
|
145
|
+
- STRINGIZE
|
146
|
+
- PP_STRINGIZE
|
147
|
+
- BOOST_PP_STRINGIZE
|
148
|
+
...
|
149
|
+
|
data/.github/workflows/build.yml
CHANGED
@@ -7,7 +7,7 @@ jobs:
|
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
ruby: [ '2.
|
10
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
11
11
|
steps:
|
12
12
|
- uses: actions/checkout@v2
|
13
13
|
- name: Set up Ruby ${{ matrix.ruby }}
|
@@ -16,6 +16,6 @@ jobs:
|
|
16
16
|
ruby-version: ${{ matrix.ruby }}
|
17
17
|
- name: Build and test with Rake
|
18
18
|
run: |
|
19
|
-
gem install bundler
|
19
|
+
gem install --no-document bundler
|
20
20
|
bundle install --jobs 4 --retry 3
|
21
21
|
bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Steepfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
target :lib do
|
2
|
+
signature "sig"
|
3
|
+
#
|
4
|
+
check "lib" # Directory name
|
5
|
+
# check "Gemfile" # File name
|
6
|
+
# check "app/models/**/*.rb" # Glob
|
7
|
+
# # ignore "lib/templates/*.rb"
|
8
|
+
#
|
9
|
+
# # library "pathname", "set" # Standard libraries
|
10
|
+
# library "numo-narray" # Gems
|
11
|
+
end
|
12
|
+
|
13
|
+
# target :spec do
|
14
|
+
# signature "sig", "sig-private"
|
15
|
+
#
|
16
|
+
# check "spec"
|
17
|
+
#
|
18
|
+
# # library "pathname", "set" # Standard libraries
|
19
|
+
# # library "rspec"
|
20
|
+
# end
|
data/ext/lbfgsb/lbfgsbext.c
CHANGED
@@ -2,12 +2,8 @@
|
|
2
2
|
|
3
3
|
VALUE rb_mLbfgsb;
|
4
4
|
|
5
|
-
static
|
6
|
-
VALUE
|
7
|
-
VALUE fnc, VALUE x_val, VALUE jcb, VALUE args,
|
8
|
-
VALUE l_val, VALUE u_val, VALUE nbd_val,
|
9
|
-
VALUE maxcor, VALUE ftol, VALUE gtol, VALUE maxiter, VALUE disp)
|
10
|
-
{
|
5
|
+
static VALUE lbfgsb_min_l_bfgs_b(VALUE self, VALUE fnc, VALUE x_val, VALUE jcb, VALUE args, VALUE l_val, VALUE u_val,
|
6
|
+
VALUE nbd_val, VALUE maxcor, VALUE ftol, VALUE gtol, VALUE maxiter, VALUE disp) {
|
11
7
|
long n_iter;
|
12
8
|
long n_fev;
|
13
9
|
long n_jev;
|
@@ -115,10 +111,7 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
|
|
115
111
|
n_jev = 0;
|
116
112
|
|
117
113
|
for (n_iter = 0; n_iter < max_iter;) {
|
118
|
-
setulb_(
|
119
|
-
&n, &m, x_ptr, l_ptr, u_ptr, nbd_ptr, &f, g, &factr, &pgtol, wa, iwa,
|
120
|
-
task, &iprint, csave, lsave, isave, dsave
|
121
|
-
);
|
114
|
+
setulb_(&n, &m, x_ptr, l_ptr, u_ptr, nbd_ptr, &f, g, &factr, &pgtol, wa, iwa, task, &iprint, csave, lsave, isave, dsave);
|
122
115
|
if (strncmp(task, "FG", 2) == 0) {
|
123
116
|
if (RB_TYPE_P(jcb, T_TRUE)) {
|
124
117
|
fg_arr = rb_funcall(self, rb_intern("fnc"), 3, fnc, x_val, args);
|
@@ -130,8 +123,10 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
|
|
130
123
|
}
|
131
124
|
n_fev++;
|
132
125
|
n_jev++;
|
133
|
-
if (CLASS_OF(g_val) != numo_cDFloat)
|
134
|
-
|
126
|
+
if (CLASS_OF(g_val) != numo_cDFloat)
|
127
|
+
g_val = rb_funcall(numo_cDFloat, rb_intern("cast"), 1, g_val);
|
128
|
+
if (!RTEST(nary_check_contiguous(g_val)))
|
129
|
+
g_val = nary_dup(g_val);
|
135
130
|
memcpy(g, na_get_pointer_for_read(g_val), n * sizeof(*g));
|
136
131
|
RB_GC_GUARD(g_val);
|
137
132
|
} else if (strncmp(task, "NEW_X", 5) == 0) {
|
@@ -163,9 +158,7 @@ VALUE lbfgsb_min_l_bfgs_b(VALUE self,
|
|
163
158
|
return ret;
|
164
159
|
}
|
165
160
|
|
166
|
-
void
|
167
|
-
Init_lbfgsbext(void)
|
168
|
-
{
|
161
|
+
void Init_lbfgsbext(void) {
|
169
162
|
rb_mLbfgsb = rb_define_module("Lbfgsb");
|
170
163
|
/* The value of double epsilon used in the native extension. */
|
171
164
|
rb_define_const(rb_mLbfgsb, "DBL_EPSILON", DBL2NUM(DBL_EPSILON));
|
data/ext/lbfgsb/lbfgsbext.h
CHANGED
data/ext/lbfgsb/src/blas.c
CHANGED
@@ -5,8 +5,7 @@
|
|
5
5
|
*/
|
6
6
|
#include "blas.h"
|
7
7
|
|
8
|
-
int lbfgsb_rb_daxpy_(long
|
9
|
-
{
|
8
|
+
int lbfgsb_rb_daxpy_(long* n, double* da, double* dx, long* incx, double* dy, long* incy) {
|
10
9
|
long i__1;
|
11
10
|
static long i__, m, ix, iy, mp1;
|
12
11
|
|
@@ -70,8 +69,7 @@ L40:
|
|
70
69
|
return 0;
|
71
70
|
}
|
72
71
|
|
73
|
-
int lbfgsb_rb_dcopy_(long
|
74
|
-
{
|
72
|
+
int lbfgsb_rb_dcopy_(long* n, double* dx, long* incx, double* dy, long* incy) {
|
75
73
|
long i__1;
|
76
74
|
static long i__, m, ix, iy, mp1;
|
77
75
|
|
@@ -135,8 +133,7 @@ L40:
|
|
135
133
|
return 0;
|
136
134
|
}
|
137
135
|
|
138
|
-
double lbfgsb_rb_ddot_(long
|
139
|
-
{
|
136
|
+
double lbfgsb_rb_ddot_(long* n, double* dx, long* incx, double* dy, long* incy) {
|
140
137
|
long i__1;
|
141
138
|
double ret_val;
|
142
139
|
static long i__, m, ix, iy, mp1;
|
@@ -194,16 +191,15 @@ L40:
|
|
194
191
|
mp1 = m + 1;
|
195
192
|
i__1 = *n;
|
196
193
|
for (i__ = mp1; i__ <= i__1; i__ += 5) {
|
197
|
-
dtemp = dtemp + dx[i__] * dy[i__] + dx[i__ + 1] * dy[i__ + 1]
|
198
|
-
|
194
|
+
dtemp = dtemp + dx[i__] * dy[i__] + dx[i__ + 1] * dy[i__ + 1] + dx[i__ + 2] * dy[i__ + 2] + dx[i__ + 3] * dy[i__ + 3] +
|
195
|
+
dx[i__ + 4] * dy[i__ + 4];
|
199
196
|
}
|
200
197
|
L60:
|
201
198
|
ret_val = dtemp;
|
202
199
|
return ret_val;
|
203
200
|
}
|
204
201
|
|
205
|
-
int lbfgsb_rb_dscal_(long
|
206
|
-
{
|
202
|
+
int lbfgsb_rb_dscal_(long* n, double* da, double* dx, long* incx) {
|
207
203
|
long i__1, i__2;
|
208
204
|
static long i__, m, mp1, nincx;
|
209
205
|
|
data/ext/lbfgsb/src/blas.h
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
#include <math.h>
|
5
5
|
|
6
|
-
extern int lbfgsb_rb_daxpy_(long
|
7
|
-
extern int lbfgsb_rb_dcopy_(long
|
8
|
-
extern double lbfgsb_rb_ddot_(long
|
9
|
-
extern int lbfgsb_rb_dscal_(long
|
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);
|
10
10
|
|
11
11
|
#endif /* LBFGSB_RB_BLAS_H_ */
|
data/ext/lbfgsb/src/lbfgsb.c
CHANGED
@@ -44,9 +44,9 @@
|
|
44
44
|
* March 2011
|
45
45
|
*/
|
46
46
|
|
47
|
+
#include "lbfgsb.h"
|
47
48
|
#include "blas.h"
|
48
49
|
#include "linpack.h"
|
49
|
-
#include "lbfgsb.h"
|
50
50
|
|
51
51
|
static double c_b9 = 0.;
|
52
52
|
static long c__1 = 1;
|
@@ -232,12 +232,8 @@ static double c_b282 = .1;
|
|
232
232
|
* Ciyou Zhu
|
233
233
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
234
234
|
*/
|
235
|
-
int setulb_(long
|
236
|
-
|
237
|
-
double *factr, double *pgtol, double *wa, long *iwa,
|
238
|
-
char *task, long *iprint, char *csave, long *lsave,
|
239
|
-
long *isave, double *dsave)
|
240
|
-
{
|
235
|
+
int setulb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double* f, double* g, double* factr, double* pgtol,
|
236
|
+
double* wa, long* iwa, char* task, long* iprint, char* csave, long* lsave, long* isave, double* dsave) {
|
241
237
|
long i__1;
|
242
238
|
|
243
239
|
static long ld, lr, lt, lz, lwa, lwn, lss, lxp, lws, lwt, lsy, lwy, lsnd;
|
@@ -287,11 +283,9 @@ int setulb_(long *n, long *m, double *x,
|
|
287
283
|
lt = isave[14];
|
288
284
|
lxp = isave[15];
|
289
285
|
lwa = isave[16];
|
290
|
-
mainlb_(n, m, &x[1], &l[1], &u[1], &nbd[1], f, &g[1], factr, pgtol, &wa[lws],
|
291
|
-
&wa[
|
292
|
-
&
|
293
|
-
&iwa[*n + 1], &iwa[(*n << 1) + 1], task, iprint, csave, &lsave[1],
|
294
|
-
&isave[22], &dsave[1]);
|
286
|
+
mainlb_(n, m, &x[1], &l[1], &u[1], &nbd[1], f, &g[1], factr, pgtol, &wa[lws], &wa[lwy], &wa[lsy], &wa[lss], &wa[lwt],
|
287
|
+
&wa[lwn], &wa[lsnd], &wa[lz], &wa[lr], &wa[ld], &wa[lt], &wa[lxp], &wa[lwa], &iwa[1], &iwa[*n + 1],
|
288
|
+
&iwa[(*n << 1) + 1], task, iprint, csave, &lsave[1], &isave[22], &dsave[1]);
|
295
289
|
return 0;
|
296
290
|
}
|
297
291
|
|
@@ -471,20 +465,14 @@ int setulb_(long *n, long *m, double *x,
|
|
471
465
|
* Ciyou Zhu
|
472
466
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
473
467
|
*/
|
474
|
-
int mainlb_(long
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
long *iwhere, long *indx2, char *task, long *iprint,
|
481
|
-
char *csave, long *lsave, long *isave, double *dsave)
|
482
|
-
{
|
483
|
-
long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset,
|
484
|
-
ss_dim1, ss_offset, wt_dim1, wt_offset, wn_dim1, wn_offset,
|
485
|
-
snd_dim1, snd_offset, i__1;
|
468
|
+
int mainlb_(long* n, long* m, double* x, double* l, double* u, long* nbd, double* f, double* g, double* factr, double* pgtol,
|
469
|
+
double* ws, double* wy, double* sy, double* ss, double* wt, double* wn, double* snd, double* z__, double* r__,
|
470
|
+
double* d__, double* t, double* xp, double* wa, long* index, long* iwhere, long* indx2, char* task, long* iprint,
|
471
|
+
char* csave, long* lsave, long* isave, double* dsave) {
|
472
|
+
long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, wt_dim1, wt_offset, wn_dim1, wn_offset,
|
473
|
+
snd_dim1, snd_offset, i__1;
|
486
474
|
double d__1, d__2;
|
487
|
-
FILE
|
475
|
+
FILE* itfptr;
|
488
476
|
static long i__, k;
|
489
477
|
static double gd, dr, rr, dtd;
|
490
478
|
static long col;
|
@@ -610,9 +598,8 @@ int mainlb_(long *n, long *m, double *x,
|
|
610
598
|
/* Check the input arguments for errors. */
|
611
599
|
errclb_(n, m, factr, &l[1], &u[1], &nbd[1], task, &info, &k);
|
612
600
|
if (strncmp(task, "ERROR", 5) == 0) {
|
613
|
-
prn3lb_(n, &x[1], f, task, iprint, &info, &itfile, &iter, &nfgv, &nintol,
|
614
|
-
|
615
|
-
&stp, &xstep, &k, &cachyt, &sbtime, &lnscht);
|
601
|
+
prn3lb_(n, &x[1], f, task, iprint, &info, &itfile, &iter, &nfgv, &nintol, &nskip, &nact, &sbgnrm, &c_b9, &nseg, word,
|
602
|
+
&iback, &stp, &xstep, &k, &cachyt, &sbtime, &lnscht);
|
616
603
|
return 0;
|
617
604
|
}
|
618
605
|
prn1lb_(n, m, &l[1], &u[1], &x[1], iprint, &itfile, &epsmch);
|
@@ -707,7 +694,7 @@ L222:
|
|
707
694
|
}
|
708
695
|
iword = -1;
|
709
696
|
|
710
|
-
if (!
|
697
|
+
if (!cnstnd && col > 0) {
|
711
698
|
/* skip the search for GCP. */
|
712
699
|
lbfgsb_rb_dcopy_(n, &x[1], &c__1, &z__[1], &c__1);
|
713
700
|
wrk = updatd;
|
@@ -718,10 +705,9 @@ L222:
|
|
718
705
|
* Compute the Generalized Cauchy Point (GCP).
|
719
706
|
*/
|
720
707
|
timer_(&cpu1);
|
721
|
-
cauchy_(n, &x[1], &l[1], &u[1], &nbd[1], &g[1], &indx2[1], &iwhere[1], &t[1],
|
722
|
-
|
723
|
-
|
724
|
-
&wa[(*m << 2) + 1], &wa[*m * 6 + 1], &nseg, iprint, &sbgnrm, &info, &epsmch);
|
708
|
+
cauchy_(n, &x[1], &l[1], &u[1], &nbd[1], &g[1], &indx2[1], &iwhere[1], &t[1], &d__[1], &z__[1], m, &wy[wy_offset],
|
709
|
+
&ws[ws_offset], &sy[sy_offset], &wt[wt_offset], &theta, &col, &head, &wa[1], &wa[(*m << 1) + 1], &wa[(*m << 2) + 1],
|
710
|
+
&wa[*m * 6 + 1], &nseg, iprint, &sbgnrm, &info, &epsmch);
|
725
711
|
if (info != 0) {
|
726
712
|
/* singular triangular system detected; refresh the lbfgs memory. */
|
727
713
|
if (*iprint >= 1) {
|
@@ -762,9 +748,8 @@ L333:
|
|
762
748
|
/* where E = [-I 0] */
|
763
749
|
/* [ 0 I] */
|
764
750
|
if (wrk) {
|
765
|
-
formk_(n, &nfree, &index[1], &nenter, &ileave, &indx2[1], &iupdat, &updatd,
|
766
|
-
|
767
|
-
&sy[sy_offset], &theta, &col, &head, &info);
|
751
|
+
formk_(n, &nfree, &index[1], &nenter, &ileave, &indx2[1], &iupdat, &updatd, &wn[wn_offset], &snd[snd_offset], m,
|
752
|
+
&ws[ws_offset], &wy[wy_offset], &sy[sy_offset], &theta, &col, &head, &info);
|
768
753
|
}
|
769
754
|
if (info != 0) {
|
770
755
|
/* nonpositive definiteness in Cholesky factorization; */
|
@@ -786,16 +771,14 @@ L333:
|
|
786
771
|
}
|
787
772
|
/* compute r=-Z'B(xcp-xk)-Z'g (using wa(2m+1)=W'(xcp-x) */
|
788
773
|
/* from 'cauchy'). */
|
789
|
-
cmprlb_(n, m, &x[1], &g[1], &ws[ws_offset], &wy[wy_offset], &sy[sy_offset],
|
790
|
-
|
791
|
-
&head, &nfree, &cnstnd, &info);
|
774
|
+
cmprlb_(n, m, &x[1], &g[1], &ws[ws_offset], &wy[wy_offset], &sy[sy_offset], &wt[wt_offset], &z__[1], &r__[1], &wa[1],
|
775
|
+
&index[1], &theta, &col, &head, &nfree, &cnstnd, &info);
|
792
776
|
if (info != 0) {
|
793
777
|
goto L444;
|
794
778
|
}
|
795
779
|
/* jlm-jn call the direct method. */
|
796
|
-
subsm_(n, m, &nfree, &index[1], &l[1], &u[1], &nbd[1], &z__[1], &r__[1], &xp[1],
|
797
|
-
|
798
|
-
&head, &iword, &wa[1], &wn[wn_offset], iprint, &info);
|
780
|
+
subsm_(n, m, &nfree, &index[1], &l[1], &u[1], &nbd[1], &z__[1], &r__[1], &xp[1], &ws[ws_offset], &wy[wy_offset], &theta,
|
781
|
+
&x[1], &g[1], &col, &head, &iword, &wa[1], &wn[wn_offset], iprint, &info);
|
799
782
|
L444:
|
800
783
|
if (info != 0) {
|
801
784
|
/* singular triangular system detected; */
|
@@ -828,10 +811,8 @@ L555:
|
|
828
811
|
}
|
829
812
|
timer_(&cpu1);
|
830
813
|
L666:
|
831
|
-
lnsrlb_(n, &l[1], &u[1], &nbd[1], &x[1], f, &fold, &gd, &gdold, &g[1],
|
832
|
-
|
833
|
-
&stpmx, &iter, &ifun, &iback, &nfgv, &info, task, &boxed, &cnstnd,
|
834
|
-
csave, &isave[22], &dsave[17]);
|
814
|
+
lnsrlb_(n, &l[1], &u[1], &nbd[1], &x[1], f, &fold, &gd, &gdold, &g[1], &d__[1], &r__[1], &t[1], &z__[1], &stp, &dnorm, &dtd,
|
815
|
+
&xstep, &stpmx, &iter, &ifun, &iback, &nfgv, &info, task, &boxed, &cnstnd, csave, &isave[22], &dsave[17]);
|
835
816
|
if (info != 0 || iback >= 20) {
|
836
817
|
/* restore the previous iterate. */
|
837
818
|
lbfgsb_rb_dcopy_(n, &t[1], &c__1, &x[1], &c__1);
|
@@ -881,8 +862,7 @@ L666:
|
|
881
862
|
/* Compute the infinity norm of the projected (-)gradient. */
|
882
863
|
projgr_(n, &l[1], &u[1], &nbd[1], &x[1], &g[1], &sbgnrm);
|
883
864
|
/* Print iteration information. */
|
884
|
-
prn2lb_(n, &x[1], f, &g[1], iprint, &itfile, &iter, &nfgv, &nact,
|
885
|
-
&sbgnrm, &nseg, word, &iword, &iback, &stp, &xstep);
|
865
|
+
prn2lb_(n, &x[1], f, &g[1], iprint, &itfile, &iter, &nfgv, &nact, &sbgnrm, &nseg, word, &iword, &iback, &stp, &xstep);
|
886
866
|
goto L1000;
|
887
867
|
}
|
888
868
|
L777:
|
@@ -934,9 +914,8 @@ L777:
|
|
934
914
|
updatd = TRUE_;
|
935
915
|
++iupdat;
|
936
916
|
/* Update matrices WS and WY and form the middle matrix in B. */
|
937
|
-
matupd_(n, m, &ws[ws_offset], &wy[wy_offset], &sy[sy_offset],
|
938
|
-
|
939
|
-
&theta, &rr, &dr, &stp, &dtd);
|
917
|
+
matupd_(n, m, &ws[ws_offset], &wy[wy_offset], &sy[sy_offset], &ss[ss_offset], &d__[1], &r__[1], &itail, &iupdat, &col, &head,
|
918
|
+
&theta, &rr, &dr, &stp, &dtd);
|
940
919
|
/* Form the upper half of the pds T = theta*SS + L*D^(-1)*L'; */
|
941
920
|
/* Store T in the upper triangular of the array wt; */
|
942
921
|
/* Cholesky factorize T to J*J' with */
|
@@ -967,9 +946,8 @@ L888:
|
|
967
946
|
L999:
|
968
947
|
timer_(&time2);
|
969
948
|
time = time2 - time1;
|
970
|
-
prn3lb_(n, &x[1], f, task, iprint, &info, &itfile, &iter, &nfgv, &nintol,
|
971
|
-
|
972
|
-
&k, &cachyt, &sbtime, &lnscht);
|
949
|
+
prn3lb_(n, &x[1], f, task, iprint, &info, &itfile, &iter, &nfgv, &nintol, &nskip, &nact, &sbgnrm, &time, &nseg, word, &iback,
|
950
|
+
&stp, &xstep, &k, &cachyt, &sbtime, &lnscht);
|
973
951
|
L1000:
|
974
952
|
/* Save local variables. */
|
975
953
|
lsave[1] = prjctd;
|
@@ -1035,10 +1013,8 @@ L1000:
|
|
1035
1013
|
* Ciyou Zhu
|
1036
1014
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
1037
1015
|
*/
|
1038
|
-
int active_(long
|
1039
|
-
|
1040
|
-
long *prjctd, long *cnstnd, long *boxed)
|
1041
|
-
{
|
1016
|
+
int active_(long* n, double* l, double* u, long* nbd, double* x, long* iwhere, long* iprint, long* prjctd, long* cnstnd,
|
1017
|
+
long* boxed) {
|
1042
1018
|
long i__1;
|
1043
1019
|
static long i__, nbdd;
|
1044
1020
|
--iwhere;
|
@@ -1080,7 +1056,7 @@ int active_(long *n, double *l, double *u,
|
|
1080
1056
|
if (nbd[i__] == 0) {
|
1081
1057
|
/* this variable is always free */
|
1082
1058
|
iwhere[i__] = -1;
|
1083
|
-
|
1059
|
+
/* otherwise set x(i)=mid(x(i), u(i), l(i)). */
|
1084
1060
|
} else {
|
1085
1061
|
*cnstnd = TRUE_;
|
1086
1062
|
if (nbd[i__] == 2 && u[i__] - l[i__] <= 0.) {
|
@@ -1095,7 +1071,7 @@ int active_(long *n, double *l, double *u,
|
|
1095
1071
|
if (*prjctd) {
|
1096
1072
|
fprintf(stdout, " The initial X is infeasible. Restart with its projection.\n");
|
1097
1073
|
}
|
1098
|
-
if (!
|
1074
|
+
if (!(*cnstnd)) {
|
1099
1075
|
fprintf(stdout, " This problem is unconstrained.\n");
|
1100
1076
|
}
|
1101
1077
|
}
|
@@ -1159,9 +1135,7 @@ int active_(long *n, double *l, double *u,
|
|
1159
1135
|
* Ciyou Zhu
|
1160
1136
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
1161
1137
|
*/
|
1162
|
-
int bmv_(long
|
1163
|
-
*col, double *v, double *p, long *info)
|
1164
|
-
{
|
1138
|
+
int bmv_(long* m, double* sy, double* wt, long* col, double* v, double* p, long* info) {
|
1165
1139
|
long sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
|
1166
1140
|
static long i__, k, i2;
|
1167
1141
|
static double sum;
|
@@ -1400,14 +1374,10 @@ int bmv_(long *m, double *sy, double *wt, long
|
|
1400
1374
|
* Ciyou Zhu
|
1401
1375
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
1402
1376
|
*/
|
1403
|
-
int cauchy_(long
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
double *theta, long *col, long *head, double *p,
|
1408
|
-
double *c__, double *wbp, double *v, long *nseg,
|
1409
|
-
long *iprint, double *sbgnrm, long *info, double *epsmch)
|
1410
|
-
{
|
1377
|
+
int cauchy_(long* n, double* x, double* l, double* u, long* nbd, double* g, long* iorder, long* iwhere, double* t, double* d__,
|
1378
|
+
double* xcp, long* m, double* wy, double* ws, double* sy, double* wt, double* theta, long* col, long* head,
|
1379
|
+
double* p, double* c__, double* wbp, double* v, long* nseg, long* iprint, double* sbgnrm, long* info,
|
1380
|
+
double* epsmch) {
|
1411
1381
|
long wy_dim1, wy_offset, ws_dim1, ws_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
|
1412
1382
|
double d__1;
|
1413
1383
|
static long i__, j;
|
@@ -1782,12 +1752,8 @@ L999:
|
|
1782
1752
|
* Ciyou Zhu
|
1783
1753
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
1784
1754
|
*/
|
1785
|
-
int cmprlb_(long
|
1786
|
-
|
1787
|
-
double *wt, double *z__, double *r__, double *wa,
|
1788
|
-
long *index, double *theta, long *col, long *head,
|
1789
|
-
long *nfree, long *cnstnd, long *info)
|
1790
|
-
{
|
1755
|
+
int cmprlb_(long* n, long* m, double* x, double* g, double* ws, double* wy, double* sy, double* wt, double* z__, double* r__,
|
1756
|
+
double* wa, long* index, double* theta, long* col, long* head, long* nfree, long* cnstnd, long* info) {
|
1791
1757
|
long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, wt_dim1, wt_offset, i__1, i__2;
|
1792
1758
|
static long i__, j, k;
|
1793
1759
|
static double a1, a2;
|
@@ -1812,7 +1778,7 @@ int cmprlb_(long *n, long *m, double *x,
|
|
1812
1778
|
ws_offset = 1 + ws_dim1;
|
1813
1779
|
ws -= ws_offset;
|
1814
1780
|
|
1815
|
-
if (!
|
1781
|
+
if (!(*cnstnd) && *col > 0) {
|
1816
1782
|
i__1 = *n;
|
1817
1783
|
for (i__ = 1; i__ <= i__1; ++i__) {
|
1818
1784
|
r__[i__] = -g[i__];
|
@@ -1858,9 +1824,7 @@ int cmprlb_(long *n, long *m, double *x,
|
|
1858
1824
|
* Ciyou Zhu
|
1859
1825
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
1860
1826
|
*/
|
1861
|
-
int errclb_(long
|
1862
|
-
double *l, double *u, long *nbd, char *task, long *info, long *k)
|
1863
|
-
{
|
1827
|
+
int errclb_(long* n, long* m, double* factr, double* l, double* u, long* nbd, char* task, long* info, long* k) {
|
1864
1828
|
long i__1;
|
1865
1829
|
static long i__;
|
1866
1830
|
--nbd;
|
@@ -2017,14 +1981,9 @@ int errclb_(long *n, long *m, double *factr,
|
|
2017
1981
|
* Ciyou Zhu
|
2018
1982
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2019
1983
|
*/
|
2020
|
-
int formk_(long
|
2021
|
-
|
2022
|
-
|
2023
|
-
double *wy, double *sy, double *theta, long *col,
|
2024
|
-
long *head, long *info)
|
2025
|
-
{
|
2026
|
-
long wn_dim1, wn_offset, wn1_dim1, wn1_offset, ws_dim1, ws_offset,
|
2027
|
-
wy_dim1, wy_offset, sy_dim1, sy_offset, i__1, i__2, i__3;
|
1984
|
+
int formk_(long* n, long* nsub, long* ind, long* nenter, long* ileave, long* indx2, long* iupdat, long* updatd, double* wn,
|
1985
|
+
double* wn1, long* m, double* ws, double* wy, double* sy, double* theta, long* col, long* head, long* info) {
|
1986
|
+
long wn_dim1, wn_offset, wn1_dim1, wn1_offset, ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, i__1, i__2, i__3;
|
2028
1987
|
static long i__, k, k1, m2, is, js, iy, jy, is1, js1, col2, dend, pend;
|
2029
1988
|
static long upcl;
|
2030
1989
|
static double temp1, temp2, temp3, temp4;
|
@@ -2265,9 +2224,7 @@ int formk_(long *n, long *nsub, long *ind, long *nenter,
|
|
2265
2224
|
* Ciyou Zhu
|
2266
2225
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2267
2226
|
*/
|
2268
|
-
int formt_(long
|
2269
|
-
double *ss, long *col, double *theta, long *info)
|
2270
|
-
{
|
2227
|
+
int formt_(long* m, double* wt, double* sy, double* ss, long* col, double* theta, long* info) {
|
2271
2228
|
long wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2, i__3;
|
2272
2229
|
static long i__, j, k, k1;
|
2273
2230
|
static double ddum;
|
@@ -2343,11 +2300,8 @@ int formt_(long *m, double *wt, double *sy,
|
|
2343
2300
|
* Ciyou Zhu
|
2344
2301
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2345
2302
|
*/
|
2346
|
-
int freev_(long
|
2347
|
-
|
2348
|
-
long *wrk, long *updatd, long *cnstnd, long *iprint,
|
2349
|
-
long *iter)
|
2350
|
-
{
|
2303
|
+
int freev_(long* n, long* nfree, long* index, long* nenter, long* ileave, long* indx2, long* iwhere, long* wrk, long* updatd,
|
2304
|
+
long* cnstnd, long* iprint, long* iter) {
|
2351
2305
|
long i__1;
|
2352
2306
|
static long i__, k, iact;
|
2353
2307
|
|
@@ -2385,7 +2339,7 @@ int freev_(long *n, long *nfree, long *index,
|
|
2385
2339
|
}
|
2386
2340
|
if (*iprint >= 99) {
|
2387
2341
|
i__1 = *n + 1 - *ileave;
|
2388
|
-
fprintf(stdout,
|
2342
|
+
fprintf(stdout, " %2ld variables leave; %2ld variables enter\n", i__1, *nenter);
|
2389
2343
|
}
|
2390
2344
|
}
|
2391
2345
|
*wrk = *ileave < *n + 1 || *nenter > 0 || *updatd;
|
@@ -2448,8 +2402,7 @@ int freev_(long *n, long *nfree, long *index,
|
|
2448
2402
|
* Ciyou Zhu
|
2449
2403
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2450
2404
|
*/
|
2451
|
-
int hpsolb_(long
|
2452
|
-
{
|
2405
|
+
int hpsolb_(long* n, double* t, long* iorder, long* iheap) {
|
2453
2406
|
long i__1;
|
2454
2407
|
static long i__, j, k;
|
2455
2408
|
static double out, ddum;
|
@@ -2466,7 +2419,7 @@ int hpsolb_(long *n, double *t, long *iorder, long *iheap)
|
|
2466
2419
|
indxin = iorder[k];
|
2467
2420
|
/* Add ddum to the heap. */
|
2468
2421
|
i__ = k;
|
2469
|
-
L10:
|
2422
|
+
L10:
|
2470
2423
|
if (i__ > 1) {
|
2471
2424
|
j = i__ / 2;
|
2472
2425
|
if (ddum < t[j]) {
|
@@ -2490,7 +2443,7 @@ L10:
|
|
2490
2443
|
ddum = t[*n];
|
2491
2444
|
indxin = iorder[*n];
|
2492
2445
|
/* Restore the heap */
|
2493
|
-
L30:
|
2446
|
+
L30:
|
2494
2447
|
j = i__ + i__;
|
2495
2448
|
if (j <= *n - 1) {
|
2496
2449
|
if (t[j + 1] < t[j]) {
|
@@ -2534,15 +2487,10 @@ L30:
|
|
2534
2487
|
* Ciyou Zhu
|
2535
2488
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2536
2489
|
*/
|
2537
|
-
int lnsrlb_(long
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
double *dnorm, double *dtd, double *xstep, double *stpmx,
|
2542
|
-
long *iter, long *ifun, long *iback, long *nfgv,
|
2543
|
-
long *info, char *task, long *boxed, long *cnstnd,
|
2544
|
-
char *csave, long *isave, double *dsave)
|
2545
|
-
{
|
2490
|
+
int lnsrlb_(long* n, double* l, double* u, long* nbd, double* x, double* f, double* fold, double* gd, double* gdold, double* g,
|
2491
|
+
double* d__, double* r__, double* t, double* z__, double* stp, double* dnorm, double* dtd, double* xstep,
|
2492
|
+
double* stpmx, long* iter, long* ifun, long* iback, long* nfgv, long* info, char* task, long* boxed, long* cnstnd,
|
2493
|
+
char* csave, long* isave, double* dsave) {
|
2546
2494
|
long i__1;
|
2547
2495
|
double d__1;
|
2548
2496
|
static long i__;
|
@@ -2594,7 +2542,7 @@ int lnsrlb_(long *n, double *l, double *u,
|
|
2594
2542
|
}
|
2595
2543
|
}
|
2596
2544
|
}
|
2597
|
-
if (*iter == 0 && !
|
2545
|
+
if (*iter == 0 && !(*boxed)) {
|
2598
2546
|
d__1 = 1. / *dnorm;
|
2599
2547
|
*stp = d__1 <= *stpmx ? d__1 : *stpmx;
|
2600
2548
|
} else {
|
@@ -2658,12 +2606,8 @@ L556:
|
|
2658
2606
|
* Ciyou Zhu
|
2659
2607
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2660
2608
|
*/
|
2661
|
-
int matupd_(long
|
2662
|
-
|
2663
|
-
double *r__, long *itail, long *iupdat, long *col,
|
2664
|
-
long *head, double *theta, double *rr, double *dr,
|
2665
|
-
double *stp, double *dtd)
|
2666
|
-
{
|
2609
|
+
int matupd_(long* n, long* m, double* ws, double* wy, double* sy, double* ss, double* d__, double* r__, long* itail,
|
2610
|
+
long* iupdat, long* col, long* head, double* theta, double* rr, double* dr, double* stp, double* dtd) {
|
2667
2611
|
long ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1, i__2;
|
2668
2612
|
static long j;
|
2669
2613
|
static long pointr;
|
@@ -2743,12 +2687,9 @@ int matupd_(long *n, long *m, double *ws,
|
|
2743
2687
|
* Ciyou Zhu
|
2744
2688
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2745
2689
|
*/
|
2746
|
-
int prn1lb_(long
|
2747
|
-
double *u, double *x, long *iprint, long *itfile,
|
2748
|
-
double *epsmch)
|
2749
|
-
{
|
2690
|
+
int prn1lb_(long* n, long* m, double* l, double* u, double* x, long* iprint, long* itfile, double* epsmch) {
|
2750
2691
|
long i__1;
|
2751
|
-
FILE
|
2692
|
+
FILE* itfptr;
|
2752
2693
|
static long i__;
|
2753
2694
|
|
2754
2695
|
--x;
|
@@ -2840,14 +2781,11 @@ int prn1lb_(long *n, long *m, double *l,
|
|
2840
2781
|
* Ciyou Zhu
|
2841
2782
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2842
2783
|
*/
|
2843
|
-
int prn2lb_(long
|
2844
|
-
|
2845
|
-
long *nfgv, long *nact, double *sbgnrm, long *nseg, char*word,
|
2846
|
-
long *iword, long *iback, double *stp, double *xstep)
|
2847
|
-
{
|
2784
|
+
int prn2lb_(long* n, double* x, double* f, double* g, long* iprint, long* itfile, long* iter, long* nfgv, long* nact,
|
2785
|
+
double* sbgnrm, long* nseg, char* word, long* iword, long* iback, double* stp, double* xstep) {
|
2848
2786
|
long i__1;
|
2849
2787
|
static long i__, imod;
|
2850
|
-
FILE
|
2788
|
+
FILE* itfptr;
|
2851
2789
|
--g;
|
2852
2790
|
--x;
|
2853
2791
|
|
@@ -2890,8 +2828,8 @@ int prn2lb_(long *n, double *x, double *f,
|
|
2890
2828
|
}
|
2891
2829
|
if (*iprint >= 1) {
|
2892
2830
|
itfptr = fopen("iterate.dat", "a");
|
2893
|
-
fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E %10.3E %10.3E\n",
|
2894
|
-
|
2831
|
+
fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E %10.3E %10.3E\n", *iter, *nfgv, *nseg, *nact, word, *iback,
|
2832
|
+
*stp, *xstep, *sbgnrm, *f);
|
2895
2833
|
fclose(itfptr);
|
2896
2834
|
}
|
2897
2835
|
return 0;
|
@@ -2913,15 +2851,11 @@ int prn2lb_(long *n, double *x, double *f,
|
|
2913
2851
|
* Ciyou Zhu
|
2914
2852
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
2915
2853
|
*/
|
2916
|
-
int prn3lb_(long
|
2917
|
-
|
2918
|
-
|
2919
|
-
double *sbgnrm, double *time, long *nseg, char *word,
|
2920
|
-
long *iback, double *stp, double *xstep, long *k,
|
2921
|
-
double *cachyt, double *sbtime, double *lnscht)
|
2922
|
-
{
|
2854
|
+
int prn3lb_(long* n, double* x, double* f, char* task, long* iprint, long* info, long* itfile, long* iter, long* nfgv,
|
2855
|
+
long* nintol, long* nskip, long* nact, double* sbgnrm, double* time, long* nseg, char* word, long* iback,
|
2856
|
+
double* stp, double* xstep, long* k, double* cachyt, double* sbtime, double* lnscht) {
|
2923
2857
|
long i__1;
|
2924
|
-
FILE
|
2858
|
+
FILE* itfptr;
|
2925
2859
|
static long i__;
|
2926
2860
|
|
2927
2861
|
--x;
|
@@ -3023,8 +2957,8 @@ L999:
|
|
3023
2957
|
if (*iprint >= 1) {
|
3024
2958
|
itfptr = fopen("iterate.dat", "a");
|
3025
2959
|
if (*info == -4 || *info == -9) {
|
3026
|
-
fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E - -\n",
|
3027
|
-
|
2960
|
+
fprintf(itfptr, " %4ld %4ld %5ld %5ld %3s %4ld %7.1E %7.1E - -\n", *iter, *nfgv, *nseg, *nact, word,
|
2961
|
+
*iback, *stp, *xstep);
|
3028
2962
|
}
|
3029
2963
|
fprintf(itfptr, "\n");
|
3030
2964
|
fprintf(itfptr, "%s\n", task);
|
@@ -3090,9 +3024,7 @@ L999:
|
|
3090
3024
|
* Ciyou Zhu
|
3091
3025
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.
|
3092
3026
|
*/
|
3093
|
-
int projgr_(long
|
3094
|
-
long *nbd, double *x, double *g, double *sbgnrm)
|
3095
|
-
{
|
3027
|
+
int projgr_(long* n, double* l, double* u, long* nbd, double* x, double* g, double* sbgnrm) {
|
3096
3028
|
long i__1;
|
3097
3029
|
double d__1, d__2;
|
3098
3030
|
static long i__;
|
@@ -3299,13 +3231,9 @@ int projgr_(long *n, double *l, double *u,
|
|
3299
3231
|
* Ciyou Zhu
|
3300
3232
|
* in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal
|
3301
3233
|
*/
|
3302
|
-
int subsm_(long
|
3303
|
-
|
3304
|
-
|
3305
|
-
double *theta, double *xx, double *gg, long *col,
|
3306
|
-
long *head, long *iword, double *wv, double *wn,
|
3307
|
-
long *iprint, long *info)
|
3308
|
-
{
|
3234
|
+
int subsm_(long* n, long* m, long* nsub, long* ind, double* l, double* u, long* nbd, double* x, double* d__, double* xp,
|
3235
|
+
double* ws, double* wy, double* theta, double* xx, double* gg, long* col, long* head, long* iword, double* wv,
|
3236
|
+
double* wn, long* iprint, long* info) {
|
3309
3237
|
long ws_dim1, ws_offset, wy_dim1, wy_offset, wn_dim1, wn_offset, i__1, i__2;
|
3310
3238
|
double d__1, d__2;
|
3311
3239
|
static long i__, j, k, m2;
|
@@ -3381,8 +3309,7 @@ int subsm_(long *n, long *m, long *nsub, long *ind,
|
|
3381
3309
|
i__2 = *nsub;
|
3382
3310
|
for (i__ = 1; i__ <= i__2; ++i__) {
|
3383
3311
|
k = ind[i__];
|
3384
|
-
d__[i__] = d__[i__] + wy[k + pointr * wy_dim1] * wv[jy] / *theta
|
3385
|
-
+ ws[k + pointr * ws_dim1] * wv[js];
|
3312
|
+
d__[i__] = d__[i__] + wy[k + pointr * wy_dim1] * wv[jy] / *theta + ws[k + pointr * ws_dim1] * wv[js];
|
3386
3313
|
}
|
3387
3314
|
pointr = pointr % *m + 1;
|
3388
3315
|
}
|
@@ -3637,11 +3564,8 @@ L911:
|
|
3637
3564
|
* Argonne National Laboratory and University of Minnesota.
|
3638
3565
|
* Brett M. Averick, Richard G. Carter, and Jorge J. More'.
|
3639
3566
|
*/
|
3640
|
-
int dcsrch_(double
|
3641
|
-
|
3642
|
-
double *stpmin, double *stpmax,
|
3643
|
-
char *task, long *isave, double *dsave)
|
3644
|
-
{
|
3567
|
+
int dcsrch_(double* f, double* g, double* stp, double* ftol, double* gtol, double* xtol, double* stpmin, double* stpmax,
|
3568
|
+
char* task, long* isave, double* dsave) {
|
3645
3569
|
|
3646
3570
|
double d__1;
|
3647
3571
|
static double fm, gm, fx, fy, gx, gy, fxm, fym, gxm, gym, stx, sty;
|
@@ -3917,11 +3841,8 @@ L1000:
|
|
3917
3841
|
* Argonne National Laboratory and University of Minnesota.
|
3918
3842
|
* Brett M. Averick and Jorge J. More'.
|
3919
3843
|
*/
|
3920
|
-
int dcstep_(double
|
3921
|
-
|
3922
|
-
double *fp, double *dp, long *brackt, double *stpmin,
|
3923
|
-
double *stpmax)
|
3924
|
-
{
|
3844
|
+
int dcstep_(double* stx, double* fx, double* dx, double* sty, double* fy, double* dy, double* stp, double* fp, double* dp,
|
3845
|
+
long* brackt, double* stpmin, double* stpmax) {
|
3925
3846
|
double d__1, d__2, d__3;
|
3926
3847
|
static double p, q, r__, s, sgnd, stpc, stpf, stpq, gamma, theta;
|
3927
3848
|
|
@@ -3953,10 +3874,10 @@ int dcstep_(double *stx, double *fx, double *dx,
|
|
3953
3874
|
stpf = stpc + (stpq - stpc) / 2.;
|
3954
3875
|
}
|
3955
3876
|
*brackt = TRUE_;
|
3956
|
-
|
3957
|
-
|
3958
|
-
|
3959
|
-
|
3877
|
+
/* Second case: A lower function value and derivatives of opposite */
|
3878
|
+
/* sign. The minimum is bracketed. If the cubic step is farther from */
|
3879
|
+
/* stp than the secant step, the cubic step is taken, otherwise the */
|
3880
|
+
/* secant step is taken. */
|
3960
3881
|
} else if (sgnd < 0.) {
|
3961
3882
|
theta = (*fx - *fp) * 3. / (*stp - *stx) + *dx + *dp;
|
3962
3883
|
d__1 = fabs(theta);
|
@@ -3980,8 +3901,8 @@ int dcstep_(double *stx, double *fx, double *dx,
|
|
3980
3901
|
stpf = stpq;
|
3981
3902
|
}
|
3982
3903
|
*brackt = TRUE_;
|
3983
|
-
|
3984
|
-
|
3904
|
+
/* Third case: A lower function value, derivatives of the same sign, */
|
3905
|
+
/* and the magnitude of the derivative decreases. */
|
3985
3906
|
} else if (fabs(*dp) < fabs(*dx)) {
|
3986
3907
|
/* The cubic step is computed only if the cubic tends to infinity */
|
3987
3908
|
/* in the direction of the step or if the minimum of the cubic */
|
@@ -4041,10 +3962,10 @@ int dcstep_(double *stx, double *fx, double *dx,
|
|
4041
3962
|
stpf = *stpmax <= stpf ? *stpmax : stpf;
|
4042
3963
|
stpf = *stpmin >= stpf ? *stpmin : stpf;
|
4043
3964
|
}
|
4044
|
-
|
4045
|
-
|
4046
|
-
|
4047
|
-
|
3965
|
+
/* Fourth case: A lower function value, derivatives of the same sign, */
|
3966
|
+
/* and the magnitude of the derivative does not decrease. If the */
|
3967
|
+
/* minimum is not bracketed, the step is either stpmin or stpmax, */
|
3968
|
+
/* otherwise the cubic step is taken. */
|
4048
3969
|
} else {
|
4049
3970
|
if (*brackt) {
|
4050
3971
|
theta = (*fp - *fy) * 3. / (*sty - *stp) + *dy + *dp;
|
@@ -4052,7 +3973,7 @@ int dcstep_(double *stx, double *fx, double *dx,
|
|
4052
3973
|
d__2 = fabs(*dy);
|
4053
3974
|
d__1 = d__1 >= d__2 ? d__1 : d__2;
|
4054
3975
|
d__2 = fabs(*dp);
|
4055
|
-
s = d__1 >= d__2 ? d__1: d__2;
|
3976
|
+
s = d__1 >= d__2 ? d__1 : d__2;
|
4056
3977
|
d__1 = theta / s;
|
4057
3978
|
gamma = s * sqrt(d__1 * d__1 - *dy / s * (*dp / s));
|
4058
3979
|
if (*stp > *sty) {
|
@@ -4089,8 +4010,7 @@ int dcstep_(double *stx, double *fx, double *dx,
|
|
4089
4010
|
return 0;
|
4090
4011
|
}
|
4091
4012
|
|
4092
|
-
int timer_(double
|
4093
|
-
{
|
4013
|
+
int timer_(double* ttime) {
|
4094
4014
|
*ttime = (double)clock() / CLOCKS_PER_SEC;
|
4095
4015
|
return 0;
|
4096
4016
|
}
|