| 1 | /* |
| 2 | * |
| 3 | * lbfgsb_new.h |
| 4 | * HAL_HAS |
| 5 | * |
| 6 | * CSIRO Open Source Software License Agreement (GPLv3) |
| 7 | * Copyright (c) 2014, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. |
| 8 | * All rights reserved. CSIRO is willing to grant you a license to HAL-HAS on the terms of the GNU General Public |
| 9 | * License version 3 as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.html), except |
| 10 | * where otherwise indicated for third party material. |
| 11 | * The following additional terms apply under clause 7 of that license: |
| 12 | * EXCEPT AS EXPRESSLY STATED IN THIS AGREEMENT AND TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, THE SOFTWARE |
| 13 | * IS PROVIDED "AS-IS". CSIRO MAKES NO REPRESENTATIONS, WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, |
| 14 | * INCLUDING BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS REGARDING THE CONTENTS OR ACCURACY |
| 15 | * OF THE SOFTWARE, OR OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, THE ABSENCE |
| 16 | * OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. |
| 17 | * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL CSIRO BE LIABLE ON ANY LEGAL THEORY (INCLUDING, |
| 18 | * WITHOUT LIMITATION, IN AN ACTION FOR BREACH OF CONTRACT, NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES |
| 19 | * OR OTHER LIABILITY HOWSOEVER INCURRED. WITHOUT LIMITING THE SCOPE OF THE PREVIOUS SENTENCE THE EXCLUSION OF |
| 20 | * LIABILITY SHALL INCLUDE: LOSS OF PRODUCTION OR OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; |
| 21 | * OR LOSS OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR OTHER ECONOMIC LOSS; OR ANY SPECIAL, |
| 22 | * INCIDENTAL, INDIRECT, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN CONNECTION WITH THIS |
| 23 | * AGREEMENT, ACCESS OF THE SOFTWARE OR ANY OTHER DEALINGS WITH THE SOFTWARE, EVEN IF CSIRO HAS BEEN ADVISED OF |
| 24 | * THE POSSIBILITY OF SUCH CLAIM, LOSS, DAMAGES OR OTHER LIABILITY. |
| 25 | * APPLICABLE LEGISLATION SUCH AS THE AUSTRALIAN CONSUMER LAW MAY APPLY REPRESENTATIONS, WARRANTIES, OR CONDITIONS, |
| 26 | * OR IMPOSES OBLIGATIONS OR LIABILITY ON CSIRO THAT CANNOT BE EXCLUDED, RESTRICTED OR MODIFIED TO THE FULL EXTENT |
| 27 | * SET OUT IN THE EXPRESS TERMS OF THIS CLAUSE ABOVE "CONSUMER GUARANTEES". TO THE EXTENT THAT SUCH CONSUMER |
| 28 | * GUARANTEES CONTINUE TO APPLY, THEN TO THE FULL EXTENT PERMITTED BY THE APPLICABLE LEGISLATION, THE LIABILITY |
| 29 | * OF CSIRO UNDER THE RELEVANT CONSUMER GUARANTEE IS LIMITED (WHERE PERMITTED AT CSIRO’S OPTION) TO ONE OF FOLLOWING |
| 30 | * REMEDIES OR SUBSTANTIALLY EQUIVALENT REMEDIES: |
| 31 | * (a) THE REPLACEMENT OF THE SOFTWARE, THE SUPPLY OF EQUIVALENT SOFTWARE, OR SUPPLYING RELEVANT |
| 32 | * SERVICES AGAIN; |
| 33 | * (b) THE REPAIR OF THE SOFTWARE; |
| 34 | * (c) THE PAYMENT OF THE COST OF REPLACING THE SOFTWARE, OF ACQUIRING EQUIVALENT SOFTWARE, HAVING THE |
| 35 | * RELEVANT SERVICES SUPPLIED AGAIN, OR HAVING THE SOFTWARE REPAIRED. |
| 36 | * IN THIS CLAUSE, CSIRO INCLUDES ANY THIRD PARTY AUTHOR OR OWNER OF ANY PART OF THE SOFTWARE OR MATERIAL DISTRIBUTED |
| 37 | * WITH IT. CSIRO MAY ENFORCE ANY RIGHTS ON BEHALF OF THE RELEVANT THIRD PARTY. |
| 38 | * Third Party Components |
| 39 | * The following third party components are distributed with the Software. You agree to comply with the license |
| 40 | * terms for these components as part of accessing the Software. Other third party software may also be identified |
| 41 | * in separate files distributed with the Software. |
| 42 | * ___________________________________________________________________ |
| 43 | * |
| 44 | * R : A Computer Language for Statistical Data Analysis version 3.0.1 (http://cran.r-project.org/src/base/R-3/R-3.0.1.tar.gz) |
| 45 | * Copyright (C) 2000-2004 The R Core Team |
| 46 | * This software is licensed under GNU GPL |
| 47 | * |
| 48 | * JACOBI_EIGENVALUE.C (http://people.sc.fsu.edu/~jburkardt/c_src/jacobi_eigenvalue/jacobi_eigenvalue.c) |
| 49 | * Copyright (C) 2003-2013 John Burkardt |
| 50 | * This software is licensed under GNU LGPL (http://www.gnu.org/licenses/lgpl.html) |
| 51 | * ___________________________________________________________________ |
| 52 | */ |
| 53 | |
| 54 | |
| 55 | #ifndef __RAL_RAS__lbfgsb_new__ |
| 56 | #define __RAL_RAS__lbfgsb_new__cxx . . $ `lbfgsb/lbfgsb_new.h:56:9`! |
| 57 | |
| 58 | #include <cstring> |
| 59 | #include <stdlib.h> |
| 60 | #include <iostream> |
| 61 | #include <math.h> |
| 62 | #include <float.h> |
| 63 | //#include "gradient.h" |
| 64 | |
| 65 | using namespace std; |
| 66 | |
| 67 | // Function to access the L-BFGS-B function |
| 68 | // 1. int n : The number of the variables |
| 69 | // 2. double* x : initial values of the variables |
| 70 | // 3. double* l : lower bounds of the variables |
| 71 | // 4. int maxit : max # of iterations |
| 72 | // 5. void* ex : the wrapped variables for objective function |
| 73 | // After the function is invoked, the values of x will be updated |
| 74 | void lbfgsb_Rcxx . . $ lbfgsb_R(81be12a3e00c12a5).(int n, double* x, double* l, int maxit, void* ex); |
| 75 | |
| 76 | // Function to access the L-BFGS-B function |
| 77 | // 1. int n : The number of the variables |
| 78 | // 2. double* x : initial values of the variables |
| 79 | // 3. double* l : lower bounds of the variables |
| 80 | // 4. double* u : upper bounds of the variables |
| 81 | // 4. int maxit : max # of iterations |
| 82 | // 5. void* ex : the wrapped variables for objective function |
| 83 | // After the function is invoked, the values of x will be updated |
| 84 | void lbfgsb_R2cxx . . $ lbfgsb_R2(c1d5e56f04c995e7).(int n, double* x, double* l, double* u, int maxit, void* ex); |
| 85 | |
| 86 | |
| 87 | |
| 88 | // ========================================================= // |
| 89 | // FUNCTIONS converted from R v 3.0.1 |
| 90 | // ========================================================= // |
| 91 | |
| 92 | typedef double optimfncxx . . $ optimfn#(int, double *, void *); |
| 93 | typedef void optimgrcxx . . $ optimgr#(int, double *, double *, void *); |
| 94 | |
| 95 | void lbfgsbcxx . . $ lbfgsb(e954471bc6c5e60b).(int n, int m, double *x, double *l, double *u, int *nbd, |
| 96 | double *Fmin, optimfncxx . . $ optimfn# fminfn, optimgrcxx . . $ optimgr# fmingr, int *fail, |
| 97 | void *ex, double factr, double pgtol, |
| 98 | int *fncount, int *grcount, int maxit, char *msg, |
| 99 | int trace, int nREPORT); |
| 100 | |
| 101 | |
| 102 | void setulbcxx . . $ setulb(876b7d0277784c27).(int n, int m, double *x, double *l, double *u, int *nbd, |
| 103 | double *f, double *g, double factr, double *pgtol, |
| 104 | double *wa, int * iwa, char *task, int iprint, |
| 105 | int *lsave, int *isave, double *dsave); |
| 106 | |
| 107 | void mainlbcxx . . $ mainlb(6b4f23c635ef2f3d).(int n, int m, double *x, |
| 108 | double *l, double *u, int *nbd, double *f, double *g, |
| 109 | double factr, double *pgtol, double *ws, double * wy, |
| 110 | double *sy, double *ss, double *wt, double *wn, |
| 111 | double *snd, double *z, double *r, double *d, |
| 112 | double *t, double *wa, int *indx, int *iwhere, |
| 113 | int *indx2, char *task, int iprint, |
| 114 | char *csave, int *lsave, int *isave, double *dsave); |
| 115 | |
| 116 | void errclbcxx . . $ errclb(47cb8ede54f6686a).(int n, int m, double factr, double *l, double *u, |
| 117 | int *nbd, char *task, int *info, int *k); |
| 118 | |
| 119 | void prn3lbcxx . . $ prn3lb(b242b2e134f4172).(int n, double *x, double *f, char *task, int iprint, |
| 120 | int info, int iter, int nfgv, int nintol, int nskip, |
| 121 | int nact, double sbgnrm, int nint, |
| 122 | char *word, int iback, double stp, double xstep, |
| 123 | int k); |
| 124 | |
| 125 | void prn1lbcxx . . $ prn1lb(487dcc018a815374).(int n, int m, double *l, double *u, double *x, |
| 126 | int iprint, double epsmch); |
| 127 | |
| 128 | void activecxx . . $ active(87b38f773730375).(int n, double *l, double *u, |
| 129 | int *nbd, double *x, int *iwhere, int iprint, |
| 130 | int *prjctd, int *cnstnd, int *boxed); |
| 131 | |
| 132 | void projgrcxx . . $ projgr(80bef34762518a18).(int n, double *l, double *u, |
| 133 | int *nbd, double *x, double *g, double *sbgnrm); |
| 134 | |
| 135 | void timercxx . . $ timer(9757410f5581be28).(double * ttime); |
| 136 | |
| 137 | void cauchycxx . . $ cauchy(7dbf4349dbf52d21).(int n, double *x, double *l, double *u, int *nbd, |
| 138 | double *g, int *iorder, int * iwhere, double *t, |
| 139 | double *d, double *xcp, int m, |
| 140 | double *wy, double *ws, double *sy, double *wt, |
| 141 | double *theta, int *col, int *head, double *p, |
| 142 | double *c, double *wbp, double *v, int *nint, |
| 143 | int iprint, double *sbgnrm, int *info, double * epsmch); |
| 144 | |
| 145 | void freevcxx . . $ freev(7d2f883eafc7f20c).(int n, int *nfree, int *indx, |
| 146 | int *nenter, int *ileave, int *indx2, int *iwhere, |
| 147 | int *wrk, int *updatd, int *cnstnd, int iprint, |
| 148 | int *iter); |
| 149 | |
| 150 | void formkcxx . . $ formk(cf351c92cb000f22).(int n, int *nsub, int *ind, int * nenter, int *ileave, |
| 151 | int *indx2, int *iupdat, int * updatd, double *wn, |
| 152 | double *wn1, int m, double *ws, double *wy, double *sy, |
| 153 | double *theta, int *col, int *head, int *info); |
| 154 | |
| 155 | void cmprlbcxx . . $ cmprlb(49cff65702c51243).(int n, int m, double *x, |
| 156 | double *g, double *ws, double *wy, double *sy, |
| 157 | double *wt, double *z, double *r, double *wa, |
| 158 | int *indx, double *theta, int *col, int *head, |
| 159 | int *nfree, int *cnstnd, int *info); |
| 160 | |
| 161 | void subsmcxx . . $ subsm(bbd90188f5635e14).(int n, int m, int *nsub, int *ind, |
| 162 | double *l, double *u, int *nbd, double *x, |
| 163 | double *d, double *ws, double *wy, double *theta, |
| 164 | int *col, int *head, int *iword, double *wv, |
| 165 | double *wn, int iprint, int *info); |
| 166 | |
| 167 | void lnsrlbcxx . . $ lnsrlb(13bb85a9ce07619a).(int n, double *l, double *u, |
| 168 | int *nbd, double *x, double *f, double *fold, |
| 169 | double *gd, double *gdold, double *g, double *d, |
| 170 | double *r, double *t, double *z, double *stp, |
| 171 | double *dnorm, double *dtd, double *xstep, |
| 172 | double *stpmx, int *iter, int *ifun, int *iback, int *nfgv, |
| 173 | int *info, char *task, int *boxed, int *cnstnd, |
| 174 | char *csave, int *isave, double *dsave); |
| 175 | |
| 176 | void matupdcxx . . $ matupd(f8c4a5e0789a9ee).(int n, int m, double *ws, |
| 177 | double *wy, double *sy, double *ss, double *d, |
| 178 | double *r, int *itail, int *iupdat, int *col, |
| 179 | int *head, double *theta, double *rr, double *dr, |
| 180 | double *stp, double *dtd); |
| 181 | |
| 182 | void prn2lbcxx . . $ prn2lb(b461cbde86805157).(int n, double *x, double *f, double *g, int iprint, |
| 183 | int iter, int nfgv, int nact, double sbgnrm, |
| 184 | int nint, char *word, int iword, int iback, |
| 185 | double stp, double xstep); |
| 186 | |
| 187 | void pvectorcxx . . $ pvector(d58d583298ded4b).(char *title, double *x, int n); |
| 188 | |
| 189 | void formtcxx . . $ formt(79f4cb0d3b7a9bdb).(int m, double *wt, double *sy, double *ss, |
| 190 | int *col, double *theta, int *info); |
| 191 | |
| 192 | void bmvcxx . . $ bmv(6b712b2f7be47d6a).(int m, double *sy, double *wt, |
| 193 | int *col, double *v, double *p, int *info); |
| 194 | |
| 195 | void hpsolbcxx . . $ hpsolb(ba1b6b76bba53e00).(int n, double *t, int *iorder, int iheap); |
| 196 | |
| 197 | void dcsrchcxx . . $ dcsrch(baf54ad6b8f3f404).(double *f, double *g, double *stp, |
| 198 | /*Chgd: the next five are no longer pointers:*/ |
| 199 | double ftol, double gtol, double xtol, |
| 200 | double stpmin, double stpmax, |
| 201 | char *task, int *isave, double *dsave); |
| 202 | |
| 203 | void dcstepcxx . . $ dcstep(89b55cf546a65cd2).(double *stx, double *fx, double *dx, |
| 204 | double *sty, double *fy, double *dy, double *stp, |
| 205 | double *fp, double *dp, int *brackt, double *stpmin, |
| 206 | double *stpmax); |
| 207 | |
| 208 | // ========================================================= // |
| 209 | // Other fortan functions |
| 210 | // ========================================================= // |
| 211 | |
| 212 | #define DYcxx . . $ `lbfgsb/lbfgsb_new.h:212:9`!(I) dy[(I)-1] |
| 213 | #define DXcxx . . $ `lbfgsb/lbfgsb_new.h:213:9`!(I) dx[(I)-1] |
| 214 | |
| 215 | int dcopycxx . . $ dcopy(cf58b19f92bec480).(int *n, double *dx, int *incx, |
| 216 | double *dy, int *incy); |
| 217 | |
| 218 | int dscalcxx . . $ dscal(60b70981d4cbe3cc).(int *n, double *da, double *dx, |
| 219 | int *incx); |
| 220 | |
| 221 | double ddotcxx . . $ ddot(c9ba308584a9665a).(int *n, double *dx, int *incx, double *dy, |
| 222 | int *incy); |
| 223 | |
| 224 | int daxpycxx . . $ daxpy(219f4dc8a044d385).(int *n, double *da, double *dx, |
| 225 | int *incx, double *dy, int *incy); |
| 226 | |
| 227 | int dpofacxx . . $ dpofa(c733fa74aaef6115).(double *a, int *lda, int *n, int *info); |
| 228 | |
| 229 | int dtrslcxx . . $ dtrsl(9abce285406fd35a).(double *t, int *ldt, int *n, |
| 230 | double *b, int *job, int *info); |
| 231 | |
| 232 | #endif /* defined(__RAL_RAS__lbfgsb_new__) */ |