ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar.hpp
Go to the documentation of this file.
1 
39 #ifndef FVAR_HPP
40 #define FVAR_HPP
41 
42 #if defined(DEBUG)
43  #if DEBUG==0
44  #define DIAG
45  #endif
46 #endif
47 
53 #if defined(__MINGW64__)
54  #define OFF_T off64_t
55  #define LSEEK lseek64
56  #define READ read
57  #define WRITE write
58  #if defined(AD_LONG_INT)
59  #error "Error: AD_LONG_INT should not be defined."
60  #else
61  #define AD_LONG_INT long long int
62  #endif
63 #elif defined(_MSC_VER)
64  #define OFF_T __int64
65  #define LSEEK _lseeki64
66  #define READ _read
67  #define WRITE _write
68  #if defined(AD_LONG_INT)
69  #error "Error: AD_LONG_INT should not be defined."
70  #else
71  #define AD_LONG_INT long int
72  #endif
73 #else
74  #define OFF_T off_t
75  #define LSEEK lseek
76  #define READ read
77  #define WRITE write
78  #if defined(AD_LONG_INT)
79  #error "Error: AD_LONG_INT should not be defined."
80  #else
81  #define AD_LONG_INT long int
82  #endif
83 #endif
84 
85 #ifdef __OPENCC__
86  #define nullptr 0
87 #endif
88 
89 #include <cmath>
90 #ifndef M_PI
91  //#error "Error: M_PI is not defined."
92  #define M_PI 3.14159265358979323846
93 #endif
94 #ifndef PI
95  #define PI M_PI
96 #endif
97 
98 #if defined(__GNUC__) && (__GNUC__ < 3)
99  #pragma interface
100 #endif
101 
102 #if defined(THREAD_EXPERIMENT)
103 # define THREAD_SAFE
104 #endif
105 
106 #if defined(THREAD_SAFE)
107 # include <pthread.h>
108 #endif
109 
110 #ifndef TINY_AD_USE_TINY_VEC
111  #define TINY_AD_USE_TINY_VEC 1
112  #include <tiny_ad.hpp>
113 #endif
114 
115 #define USE_VECTOR_SHAPE_POOL
116 
117 #if defined(USE_DDOUBLE)
118 # include <qd/qd.h>
119 # define double dd_real
120  dd_real operator ++(dd_real & d)
121  {
122  return d += 1.0;
123  }
124 
125  dd_real pow(const dd_real & d, int i);
126  dd_real pow(const dd_real & d, const dd_real &);
127 #endif
128 
129 #if defined(__TURBOC__)
130 # define __STL_PTHREADS
131 # include <k3stl.h>
132 # include <pthread_alloc>
133 #endif
134 
135 #define __NUMBERVECTOR__
136 
140 #define ADUNCONST(type,obj) type & obj = (type&) _##obj;
141 
142 #define MFCL2_CONSTRUCTORS
143 
144 #if defined(_ADEXEP)
145 # define USE_EXECPTIONS
146 #endif
147 
148 #define __USE_IOSTREAM__
149 
150 #if defined(__BORLANDC__)
151  #if (__BORLANDC__ >= 0x0550)
152  #include <fcntl.h>
153  #endif
154 #endif
155 
156 #if defined(__BORLANDC__) || defined (_MSC_VER) || defined(__WAT32__)
157 # include <io.h>
158 #endif
159 
160 #if !defined(_MSC_VER)
161  #include <fcntl.h> // to get fstreambase
162  #if !defined(O_BINARY)
163  #define O_BINARY 0
164  #endif
165  #define __GNU__
166 #endif
167 
168 #if defined(__DJGPP__)
169  #include <dos.h>
170  #include <pc.h>
171 #endif
172 
173 #ifndef NO_DERIVS
174  #define NO_DERIVS
175 #endif
176 
177 // C language function prototypes
178 extern "C"
179 {
180  typedef void (*exitptr) (int);
181  extern exitptr ad_exit;
182 
183  void spdll_exit(int);
184 }
185 
192 {
193 public:
195  double x;
196 
202  inline double &xvalue()
203  {
204  return x;
205  }
206 };
207 
208 
209 // "forward" class definitions
215 class ad_integer;
216 class index_type;
217 class dlink;
218 class dvector;
219 class dmatrix;
220 class tdmatrix;
221 class imatrix;
222 class prevariable;
223 class dvariable;
224 class dvar_vector;
225 class ivector;
226 class lvector;
227 class dvar_matrix;
228 class uostream;
229 class uistream;
230 class arr_link;
231 class arr_list;
232 class d3_array;
233 class d4_array;
234 class d5_array;
235 class d6_array;
236 class d7_array;
237 class dvar3_array;
238 class dvar4_array;
239 class dvar5_array;
240 class dvar6_array;
241 class dvar7_array;
242 class dlist;
243 class indvar_offset_list;
245 class dmatrix_position;
246 class d3_array_position;
247 class dvector_position;
248 class vector_shape;
249 class ivector_position;
250 class kkludge_object;
253 class gradient_structure;
255 class vector_shapex;
256 class predvar_vector;
258 
259 #if defined(__GNUC__) && (__GNUC__ < 3)
260  #include <fstream.h>
261 #elif defined(_MSC_VER) && (_MSC_VER < 1300)
262  #include <fstream.h>
263 #elif defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
264  #include <fstream.h>
265 #else
266  #include <fstream>
267 #endif
268 
269 #include <stdio.h>
270 
271 #if defined(__BORLANDC__)
272 # if (__BORLANDC__ < 0x0550)
273 # include <fcntl.h> // to get fstreambase
274 # include <strstrea.h>
275 # else
276 # include <strstream>
277 # endif
278 #endif
279 
280 #if defined(_MSC_VER)
281 # if (_MSC_VER < 1300)
282 # include <iostream.h>
283 # include <strstrea.h>
284 # else
285 # include <iostream>
286 # endif
287 # include <stddef.h>
288 # include <fcntl.h> // to get fstreambase
289 # include <dos.h>
290 # undef __ZTC__
291 # undef __SUN__
292 #endif
293 
294 #ifdef __ZTC__
295 # include <fstream.hpp> // to get fstreambase
296 # include <iostream.hpp>
297 # include <dos.h>
298 # undef __SUN__
299 #endif
300 
301 #ifdef __SUN__
302 # undef __NDPX__
303 # include <fstream.h>
304 # include <iostream.h>
305 # ifndef _FPOS_T_DEFINED
306 # ifdef __GNUDOS__
307 # if defined(linux) || defined(__ADSGI__)|| defined(__CYGWIN32__)
308  typedef long int fpos_t;
309 # else
310  typedef unsigned long int fpos_t;
311 # endif
312 # undef __SUN__
313  typedef int fpos_t;
314 # endif
315 # define _FPOS_T_DEFINED
316 # endif
317 #endif
318 
319 #if defined(__BORLANDC__)
320 # if (__BORLANDC__ > 0x0520)
321  using std::ofstream;
322  using std::ifstream;
323 # endif
324 #endif
325 
326 #if defined(__cplusplus)
327  #include <iostream>
328  #include <iomanip>
329  #include <sstream>
330  #include <istream>
331  #include <sstream>
332  using std::ofstream;
333  using std::ostream;
334  using std::ifstream;
335  using std::istream;
336  using std::istringstream;
337  using std::streampos;
338  using std::streambuf;
339  using std::setw;
340  using std::setprecision;
341  using std::istringstream;
342  using std::ios;
343  using std::cerr;
344  using std::cin;
345  using std::cout;
346  using std::endl;
347 #else
348  #include <iomanip.h>
349  #include <strstream.h>
350 #endif
351 
352 #define BEGIN_MINIMIZATION(nvar, objective_function, ind_vars, gradient, \
353 cntrl) \
354 gradient_structure gs; \
355 while (cntrl.ireturn >= 0) \
356 { \
357  cntrl.fmin(objective_function,ind_vars,gradient ); \
358  if (cntrl.ireturn > 0) \
359  {
360 #define END_MINIMIZATION(nvar,gradient) \
361  gradcalc(nvar, gradient); \
362  } \
363 }
364 
365 void default_evaluation4ind(void);
366 void default_evaluation(void);
367 void default_evaluation0(void);
368 void default_evaluation1(void);
369 void default_evaluation1m(void);
370 void default_evaluation2(void);
371 void default_evaluation3(void);
372 void default_evaluation4(void);
373 void default_evaluation4m(void);
374 
375 void myheapcheck(char *);
376 
377 void RETURN_ARRAYS_INCREMENT(void);
378 void RETURN_ARRAYS_DECREMENT(void);
379 
380 void *farptr_norm(void *);
381 #ifdef DIAG
382 long int farptr_tolong(void *);
383 long int _farptr_tolong(void *);
384 #endif
385 
386 class i3_array;
387 
388 ostream & operator<<(const ostream & ostr, const dmatrix & z);
389 istream & operator>>(const istream & istr, const dmatrix & z);
390 uostream & operator<<(const uostream & ostr, const dmatrix & z);
391 uistream & operator>>(const uistream & istr, const dmatrix & z);
392 
393 ostream & operator<<(const ostream & ostr, const d3_array & z);
394 istream & operator>>(const istream & istr, const d3_array & z);
395 uostream & operator<<(const uostream & ostr, const d3_array & z);
396 uistream & operator>>(const uistream & istr, const d3_array & z);
397 
398 ostream & operator<<(const ostream & ostr, const dvar3_array & z);
399 istream & operator>>(const istream & istr, const dvar3_array & z);
400 uostream & operator<<(const uostream & ostr, const dvar3_array & z);
401 uistream & operator>>(const uistream & istr, const dvar3_array & z);
402 
403 ostream & operator<<(const ostream & ostr, const ivector & z);
404 istream & operator>>(const istream & istr, const ivector & z);
405 uostream & operator<<(const uostream & ostr, const ivector & z);
406 uistream & operator>>(const uistream & istr, const ivector & z);
407 
408 ostream & operator<<(const ostream & ostr, const lvector & z);
409 istream & operator>>(const istream & istr, const lvector & z);
410 uostream & operator<<(const uostream & ostr, const lvector & z);
411 uistream & operator>>(const uistream & istr, const lvector & z);
412 
413 ostream & operator<<(const ostream & ostr, const dvector & z);
414 istream & operator>>(const istream & istr, const dvector & z);
415 uostream & operator<<(const uostream & ostr, const dvector & z);
416 uistream & operator>>(const uistream & istr, const dvector & z);
417 
418 ostream & operator<<(const ostream & ostr, const dvar_vector & z);
419 istream & operator>>(const istream & istr, const dvar_vector & z);
420 uostream & operator<<(const uostream & ostr, const dvar_vector & z);
421 uistream & operator>>(const uistream & istr, const dvar_vector & z);
422 
423 ostream & operator<<(const ostream & ostr, const dvar_matrix & z);
424 istream & operator>>(const istream & istr, const dvar_matrix & z);
425 uostream & operator<<(const uostream & ostr, const dvar_matrix & z);
426 uistream & operator>>(const uistream & istr, const dvar_matrix & z);
427 
428 
429 ostream & operator<<(const ostream & ostr, const prevariable & z);
430 istream & operator>>(const istream & istr, const prevariable & z);
431 uostream & operator<<(const uostream & ostr, const prevariable & z);
432 uistream & operator>>(const uistream & istr, const prevariable & z);
433 
434 ostream & setscientific(const ostream & s);
435 
436 //ostream& setshowpoint(const ostream& s);
437 
438 class preshowpoint {};
440 ostream & operator <<(const ostream &, preshowpoint);
441 #if (__BORLANDC__ >= 0x0560)
442  #define setfixed() std::fixed
443 #else
444 ostream & setfixed(const ostream & s);
445 class prefixed {};
446 prefixed setfixed(void);
447 ostream & operator<<(const ostream &, prefixed);
448 #endif
449 
450 #if (__BORLANDC__ >= 0x0560)
451  #define setscientific() std::scientific
452 #else
453 class prescientific {};
455 ostream & operator<<(const ostream &, prescientific);
456 #endif
457 
458 istream & operator>>(const istream & istr, const imatrix & z);
459 ostream & operator<<(const ostream & istr, const imatrix & z);
460 istream & operator>>(const istream & istr, const i3_array & z);
461 ostream & operator<<(const ostream & istr, const i3_array & z);
462 class grad_stack;
463 
470 
471 
472 #ifndef _VECTOR_SHAPE
473 #define _VECTOR_SHAPE
474 #include <dfpool.h>
475 
481 {
482 public:
484  vector_shape_pool(const size_t n): dfpool(n) {}
485  vector_shape_pool(const vector_shape_pool&) = delete;
488 
491 };
492 
498 {
499  public:
502 };
503 #endif
504 
510 {
511 #if defined(USE_VECTOR_SHAPE_POOL)
512 public:
514 
515  void* operator new(size_t);
516  void operator delete(void* ptr, size_t);
517  vector_shape(const vector_shape&) = delete;
518  vector_shape& operator=(const vector_shape&) = delete;
519 #endif
520 public:
521 
522  unsigned int ncopies;
523  void shift(int min);
526  private:
527  friend class dvector;
528  //friend class tdvector;
529  friend class subdvector;
530  friend class dvar_vector;
531  friend class ivector;
532  friend class lvector;
533  friend class ptr_vector;
534  public:
535  unsigned int decr_ncopies(void)
536  {
537  return ncopies == 0 ? 0 : --ncopies;
538  }
539  unsigned int get_ncopies(void)
540  {
541  return ncopies;
542  }
543  unsigned int incr_ncopies(void)
544  {
545  return ++ncopies;
546  }
547  vector_shape(int lb, int lu)
548  {
549  index_min = lb;
550  index_max = lu;
551  ncopies = 0;
552  }
553  int indexmin() const
554  {
555  return index_min;
556  }
557  int indexmax() const
558  {
559  return index_max;
560  }
561 };
562 
563 
569 {
570  void **v;
572 
573 public:
574  ptr_vector();
575  ptr_vector(const ptr_vector & t);
576  ptr_vector(int ncl, int ncu);
577  ~ptr_vector();
578 
579  // returns the minimum allowable index
580  int indexmin() const
581  {
582  return shape->index_min;
583  }
584  // returns the maximum allowable index
585  int indexmax() const
586  {
587  return shape->index_max;
588  }
589  // returns the maximum allowable index
590  int size() const
591  {
592  return shape->index_max - shape->index_min + 1;
593  }
594 
595  void shift(int min);
596  void allocate(int, int);
597  //operator void ** ();
598  void *&operator[] (int i);
599  void *&operator() (int i);
600  //void*& elem(int i);
601  void *&elem(int i)
602  {
603  return (*(v + i));
604  }
605  int operator!(void) const
606  {
607  return (shape == NULL);
608  }
609  int operator() (void) const
610  {
611  return (shape != NULL);
612  }
613 
614  ptr_vector& operator=(const ptr_vector& t);
615  void initialize();
616 };
617 
623 {
625  int lb;
626  int ub;
627  inline preivector(ivector * _p, int _lb, int _ub)
628  {
629  p = _p;
630  lb = _lb, ub = _ub;
631  }
632  friend class ivector;
633 };
634 
635 #include <ivector.h>
636 
642 {
643  int min;
644  int max;
645  int *v;
646  public:
647  lvector_position(void);
648  lvector_position(const lvector & v);
649  lvector_position(const lvector_position & dvp);
650 };
651 
656 class lvector
657 {
660 
661  public:
662  int operator!(void) const
663  {
664  return (shape == NULL);
665  }
666 
667  inline AD_LONG_INT & elem(int i)
668  {
669  return (v[i]);
670  }
671  inline const AD_LONG_INT & elem(int i) const
672  {
673  return v[i];
674  }
675  // returns the minimum allowable index
676  int indexmin() const
677  {
678  return shape->index_min;
679  }
680  // returns the maximum allowable index
681  int indexmax() const
682  {
683  return shape->index_max;
684  }
685  // returns the maximum allowable index
686  int size() const
687  {
688  return shape ? shape->index_max - shape->index_min + 1 : 0;
689  }
690  lvector& shift(int min);
691 
692  void fill(const char *s);
693  void fill_seqadd(const AD_LONG_INT &, const AD_LONG_INT &);
694  void fill_multinomial(const int &seed, const dvector & p);
695  void fill_multinomial(const random_number_generator & rng,
696  const dvector & p);
697 
698  //lvector(unsigned int sz); //makes an array [0..sz]
699 
700  lvector(const lvector &);
701 
702  lvector(const dvector &);
703 
704  lvector(const ivector &);
705 
706  lvector(void);
707 
708  lvector(int ncl, int ncu);
709  void allocate(int ncl, int ncu);
710  void allocate(const lvector &);
711  void allocate(void);
712  // makes an array [ncl..ncu]
713 
714  lvector(unsigned int sz, AD_LONG_INT * x);
715 
716  operator AD_LONG_INT *();
717 
718  ~lvector();
719 
720  void write_on(const ostream & s) const;
721 
722  void read_from(const istream & s);
723 
724  void write_on(const uostream & s) const;
725 
726  void read_from(const uistream & s);
727 
728  AD_LONG_INT& operator[](int i);
729  AD_LONG_INT& operator()(int i);
730  const AD_LONG_INT& operator[](int i) const;
731  const AD_LONG_INT& operator()(int i) const;
732 
733  lvector operator()(const ivector& indexes);
734 
735  lvector & operator=(const lvector & t);
736 
737  void initialize(void);
738  friend class lmatrix;
739 };
740 
741 #ifdef OPT_LIB
743 {
744  return v[i];
745 }
747 {
748  return v[i];
749 }
750 inline const AD_LONG_INT& lvector::operator[](int i) const
751 {
752  return v[i];
753 }
754 inline const AD_LONG_INT& lvector::operator()(int i) const
755 {
756  return v[i];
757 }
758 #endif
759 
760 AD_LONG_INT sum(const lvector &);
761 
767 {
777  friend class gradient_structure;
778 };
781 void arr_free(double_and_int *);
782 
783 #include <gradient_structure.h>
784 
785 void jacobcalc(int nvar, const dmatrix & g);
786 void jacobcalc(int nvar, const ofstream & ofs);
787 void jacobcalc(int nvar, const uostream & ofs);
788 
789 #if defined(__BORLANDC__ )
790 #if defined(__GNUC__)
791 #if (__GNUC__ < 3)
792 #pragma interface
793 #endif
794 #else
795 #pragma interface
796 #endif
797 #endif
798 
799 //class dvect_ptr_ptr { dvector **m; };
800 
804 class dlink
805 {
808 
809 public:
810  dlink* previous() const
811  {
812  return prev;
813  }
814 
815  //access function
817  {
818  return &di;
819  }
820 
821  //friend tempvar();
822  //friend class prevariable;
823  //friend class tempvar;
824  friend class dlist;
825  friend void gradcalc(int nvar, const dvector & g);
826  friend void slave_gradcalc(void);
827  friend void gradloop();
828  friend double_and_int *gradnew();
829  friend void allocate_dvariable_space(void);
830 };
834 class dlist
835 {
837  unsigned int nlinks;
840  double* variables_save;
841 
842 public:
843  // constructor
844  dlist();
845  // destructor
846  ~dlist();
847  // create a new link
848  dlink* create();
849  // append link
850  dlink* append(dlink* link);
851  dlink* last_remove();
852  void initialize();
853  void save_variables();
854  void restore_variables();
855 
857 
858  // check list integrity
859  void check_list(void);
860  size_t total_addresses() const;
861 
862  double* get(const int i) const
863  { return &(dlink_addresses[i]->get_address()->x); }
864 
865  friend double_and_int *gradnew();
866  friend void df_check_derivative_values(void);
867  friend void df_check_derivative_values_indexed(void);
869  friend void gradient_structure::funnel_gradcalc(void);
870  friend void slave_gradcalc(void);
871  friend void gradcalc(int nvar, const dvector& g);
872  friend void gradloop();
875  friend void gradient_structure::jacobcalc(int nvar,
876  const dmatrix& jac);
877  friend void allocate_dvariable_space(void);
878  //friend void gradient_structure::funnel_jacobcalc(void);
879  friend void gradient_structure::jacobcalc(int nvar,
880  const ofstream& jac);
881  friend void gradient_structure::jacobcalc(int nvar,
882  const uostream& jac);
883  friend void funnel_derivatives(void);
884 };
885 
886 class indvar_offset_list;
887 
895 {
896  public:
898  void (*func) (void);
899  double *dep_addr;
900  double *ind_addr1;
901  double mult1;
902  double *ind_addr2;
903  double mult2;
904  public:
905  friend void gradcalc(int nvar, const dvector & g);
906  friend void slave_gradcalc(void);
907  friend void gradloop();
908  friend void default_evaluation(void);
909  friend class grad_stack;
910  friend void gradient_structure::jacobcalc(int nvar,
911  const dmatrix & jac);
912  //friend void gradient_structure::funnel_jacobcalc(void);
913 };
914 void default_evaluation3ind(void);
915 
921 {
922 public:
926 #ifdef __BORLANDC__
927  long int length;
928  long int true_length;
929 #else
930  size_t length;
931  size_t true_length;
932 #endif
933 
935  char gradfile_name[61];
936  char gradfile_name1[61];
937  char gradfile_name2[61];
939 
940  //lvector * table;
941  // js
942  int _GRADFILE_PTR; // should be int gradfile_handle;
943  int _GRADFILE_PTR1; // should be int gradfile_handle;
944  int _GRADFILE_PTR2; // should be int gradfile_handle;
945  int _VARSSAV_PTR; // should be int gradfile_handle;
946  void create_gradfile();
947 #ifdef __BORLANDC__
948  long end_pos;
949  long end_pos1;
950  long end_pos2;
951 #else
955 #endif
956  //dmatrix *table;
957  friend void gradcalc(int nvar, const dvector & g);
958  friend void slave_gradcalc(void);
959  friend void funnel_gradcalc(void);
960  friend void default_evaluation(void);
961  friend void default_evaluation3ind(void);
962  friend void reset_gradient_stack(void);
963  friend void default_evaluation4ind(void);
964  friend void grad_chk(void);
965  friend void gradloop();
966  friend void cleanup_temporary_files();
967  ostream & operator <<(grad_stack);
968  void print();
969 
970  grad_stack(): grad_stack(gradient_structure::GRADSTACK_BUFFER_SIZE) {}
971  grad_stack(const size_t size): grad_stack(size, 0) {}
972  grad_stack(const size_t size, const unsigned int id);
973  grad_stack(const grad_stack&) = delete;
974  ~grad_stack();
975 
979 
980  void set_gradient_stack(void (*func) (void),
981  double *dep_addr, double *ind_addr1 = NULL, double mult1 = 0,
982  double *ind_addr2 = NULL, double mult2 = 0);
983 
984  void set_gradient_stack(void (*func) (void),
985  double *dep_addr, double *ind_addr1,
986  double *ind_addr2);
987 
988  void set_gradient_stack0(void (*func) (void), double *dep_addr);
989 
990  void set_gradient_stack1(void (*func) (void),
991  double *dep_addr, double *ind_addr1);
992 
993  void set_gradient_stack2(void (*func) (void),
994  double *dep_addr, double *ind_addr1, double mult1);
995 
996  void set_gradient_stack4(void (*func) (void),
997  double *dep_addr, double *ind_addr1,
998  double *ind_addr2);
999 
1000  void set_gradient_stack(void (*func) (void),
1001  double *dep_addr, double *ind_addr1,
1002  double mult1, double *ind_addr2, double mult2,
1003  double *ind_addr3, double mult3,
1004  double *ind_addr4, double mult4);
1005 
1006  void set_gradient_stack(void (*func) (void),
1007  double *dep_addr, double *ind_addr1,
1008  double mult1, double *ind_addr2, double mult2,
1009  double *ind_addr3, double mult3);
1010 
1011  int read_grad_stack_buffer(OFF_T & lpos);
1012  void set_gradient_stack(void (*ptr) (void));
1013  void set_gbuffer_pointers(void);
1014  //js
1015  void increment_current_gradfile_ptr(void);
1017  //void open_gradfile();
1018  //void close_gradfile();
1019 #ifdef _MSC_VER
1020  int gradfile_handle();
1021 #else
1022  int &gradfile_handle();
1023 #endif
1024  char *get_gradfile_name();
1025 
1026  size_t total() const
1027  {
1028  size_t count = 0;
1029  for (grad_stack_entry* current = ptr_first; current != ptr; ++current)
1030  {
1031  ++count;
1032  }
1033  return count;
1034  }
1035  friend class gradient_structure;
1036  //int get_ngradfiles();
1037 };
1038 
1039 
1040 #ifdef OPT_LIB
1041 
1045 inline void grad_stack::set_gradient_stack(void (*func) (void),
1046  double *dep_addr, double *ind_addr1, double mult1, double *ind_addr2,
1047  double mult2)
1048 {
1049 #ifdef NO_DERIVS
1051  {
1052 #endif
1053 # if defined(MYDEBUG)
1054  int wrote_buffer = 0;
1055 # endif
1056  if (ptr > ptr_last)
1057  {
1058  // current buffer is full -- write it to disk and reset pointer
1059  // and counter
1060  this->write_grad_stack_buffer();
1061 # if defined(MYDEBUG)
1062  wrote_buffer = 1;
1063 # endif
1064  }
1065 # if defined(MYDEBUG)
1066  if (wrote_buffer == 1)
1067  {
1068  cout << "WROTE BUFFER" << endl;
1069  }
1070 # endif
1071  ptr->func = func;
1072  ptr->dep_addr = dep_addr;
1073  ptr->ind_addr1 = ind_addr1;
1074  ptr->mult1 = mult1;
1075  ptr->ind_addr2 = ind_addr2;
1076  ptr->mult2 = mult2;
1077  ptr++;
1078 #ifdef NO_DERIVS
1079  }
1080 #endif
1081 }
1082 #else
1083  // void grad_stack::set_gradient_stack(void (* func)(void),
1084  // double * dep_addr,double * ind_addr1, double mult1, double * ind_addr2,
1085  // double mult2);
1086 #endif
1087 
1092 inline void grad_stack::set_gradient_stack(void (*func) (void),
1093  double *dep_addr, double *ind_addr1, double mult1, double *ind_addr2,
1094  double mult2, double *ind_addr3, double mult3)
1095 {
1096 #ifdef NO_DERIVS
1098  {
1099 #endif
1100  if (ptr > ptr_last)
1101  {
1102  // current buffer is full -- write it to disk and reset pointer
1103  // and counter
1104  this->write_grad_stack_buffer();
1105  }
1106  ptr->func = NULL;
1107  ptr->dep_addr = dep_addr;
1108  ptr->ind_addr1 = ind_addr1;
1109  ptr->mult1 = mult1;
1110  ptr->ind_addr2 = ind_addr2;
1111  ptr->mult2 = mult2;
1112  ptr++;
1113  if (ptr > ptr_last)
1114  {
1115  // current buffer is full -- write it to disk and reset pointer
1116  // and counter
1117  this->write_grad_stack_buffer();
1118  }
1119  ptr->func = func;
1120  ptr->ind_addr1 = ind_addr3;
1121  ptr->mult1 = mult3;
1122  ptr++;
1123 #ifdef NO_DERIVS
1124  }
1125 #endif
1126 }
1127 
1132 inline void grad_stack::set_gradient_stack(void (*func) (void),
1133  double *dep_addr, double *ind_addr1, double mult1, double *ind_addr2,
1134  double mult2, double *ind_addr3, double mult3, double *ind_addr4,
1135  double mult4)
1136 {
1137 #ifdef NO_DERIVS
1139  {
1140 #endif
1141  if (ptr > ptr_last)
1142  {
1143  // current buffer is full -- write it to disk and reset pointer
1144  // and counter
1145  this->write_grad_stack_buffer();
1146  }
1147  ptr->func = NULL;
1148  ptr->dep_addr = dep_addr;
1149  ptr->ind_addr1 = ind_addr1;
1150  ptr->mult1 = mult1;
1151  ptr->ind_addr2 = ind_addr2;
1152  ptr->mult2 = mult2;
1153  ptr++;
1154  if (ptr > ptr_last)
1155  {
1156  // current buffer is full -- write it to disk and reset pointer
1157  // and counter
1158  this->write_grad_stack_buffer();
1159  }
1160  ptr->func = func;
1161  ptr->ind_addr1 = ind_addr3;
1162  ptr->mult1 = mult3;
1163  ptr->ind_addr2 = ind_addr4;
1164  ptr->mult2 = mult4;
1165  ptr++;
1166 #ifdef NO_DERIVS
1167  }
1168 #endif
1169 }
1170 
1175 inline void grad_stack::set_gradient_stack(void (*func) (void),
1176  double *dep_addr, double *ind_addr1, double *ind_addr2)
1177 {
1178 #ifdef NO_DERIVS
1180  {
1181 #endif
1182  if (ptr > ptr_last)
1183  {
1184  // current buffer is full -- write it to disk and reset pointer
1185  // and counter
1186  this->write_grad_stack_buffer();
1187  }
1188  ptr->func = func;
1189  ptr->dep_addr = dep_addr;
1190  ptr->ind_addr1 = ind_addr1;
1191  ptr->ind_addr2 = ind_addr2;
1192  ptr++;
1193 #ifdef NO_DERIVS
1194  }
1195 #endif
1196 }
1197 
1202 inline void grad_stack::set_gradient_stack2(void (*func) (void),
1203  double *dep_addr, double *ind_addr1, double mult1)
1204 {
1205 #ifdef NO_DERIVS
1207  {
1208 #endif
1209  if (ptr > ptr_last)
1210  {
1211  // current buffer is full -- write it to disk and reset pointer
1212  // and counter
1213  this->write_grad_stack_buffer();
1214  }
1215  ptr->func = func;
1216  ptr->dep_addr = dep_addr;
1217  ptr->ind_addr1 = ind_addr1;
1218  ptr->mult1 = mult1;
1219  ptr++;
1220 #ifdef NO_DERIVS
1221  }
1222 #endif
1223 }
1224 
1229 inline void grad_stack::set_gradient_stack4(void (*func) (void),
1230  double *dep_addr, double *ind_addr1, double *ind_addr2)
1231 {
1232 #ifdef NO_DERIVS
1234  {
1235 #endif
1236  if (ptr > ptr_last)
1237  {
1238  // current buffer is full -- write it to disk and reset pointer
1239  // and counter
1240  this->write_grad_stack_buffer();
1241  }
1242  ptr->func = func;
1243  ptr->dep_addr = dep_addr;
1244  ptr->ind_addr1 = ind_addr1;
1245  ptr->ind_addr2 = ind_addr2;
1246  ptr++;
1247 #ifdef NO_DERIVS
1248  }
1249 #endif
1250 }
1256 inline void grad_stack::set_gradient_stack(void (*func) (void))
1257 {
1258 #ifdef NO_DERIVS
1260  {
1261 #endif
1262  if (ptr > ptr_last)
1263  {
1264  // current buffer is full -- write it to disk and reset pointer
1265  // and counter
1266  this->write_grad_stack_buffer();
1267  }
1268 
1269  ptr->dep_addr = NULL;
1270  ptr->func = func;
1271  // want to put a long int into the memory space of a double
1272  ptr->ind_addr2 = NULL;
1273  ptr->mult2 = 0;
1274  ptr++;
1275 #ifdef NO_DERIVS
1276  }
1277 #endif
1278 }
1279 
1285 {
1286  // The number of independent variables
1287  int nvar;
1288  double **address;
1289 
1290  public:
1291  friend class gradient_structure;
1292  inline double *get_address(const int &i)
1293  {
1294  return address[i];
1295  }
1296  void put_address(unsigned int &i, double *iaddress)
1297  {
1298  address[i] = iaddress;
1299  // cerr << "In put_address i = " << i << "\n";
1300  }
1301 };
1302 
1304 void gradfree(dlink* v);
1305 
1306 class prevariable_position;
1307 
1316 {
1317 protected:
1319  prevariable() = delete;
1321  {
1322  }
1323 
1324 public:
1331  prevariable(const prevariable& other): v(other.v) { }
1332 
1334 
1335  friend class dvar_vector_iterator;
1336  friend class dvar_vector;
1337  friend class dvar_matrix;
1338  friend class dvar3_array;
1339  //shclass sc;
1340  friend class indvar_offset_list;
1341  friend class gradient_structure;
1342  friend double_and_int *gradnew();
1343  friend void make_indvar_list(int, dvariable *);
1344 
1347  friend double &value(const prevariable & v1);
1348 
1349  friend double *address(const prevariable & v1);
1350 
1351  //void gradfree(dlink * v)
1352 
1353  friend prevariable & operator*(const prevariable& v1, const prevariable& v2);
1354 
1355  friend prevariable & operator*(double v1, const prevariable & v2);
1356 
1357  friend prevariable & operator*(const prevariable & v1, double v2);
1358 
1359  friend prevariable & operator/(const prevariable& t1, const prevariable& t2);
1360 
1361  friend prevariable & operator/(double t1, const prevariable & t2);
1362 
1363  friend prevariable & operator/(const prevariable & t1, double t2);
1364 
1365  friend prevariable & sin(const prevariable & t1);
1366 
1367  friend prevariable & fabs(const prevariable & t1);
1368  friend prevariable & sigmoid(const prevariable & t1);
1369 
1370  //"smoothed absolute value function
1371  friend prevariable & sfabs(const prevariable & t1);
1372 
1373  friend prevariable & sqrt(const prevariable & t1);
1374  friend prevariable & sqr(const prevariable & t1);
1375 
1376  friend prevariable & exp(const prevariable & t1);
1377 
1378  friend prevariable & atan(const prevariable & t1);
1379 
1380  friend prevariable & tan(const prevariable & t1);
1381  friend prevariable & tanh(const prevariable & t1);
1382 
1383  friend prevariable & atan2(const prevariable & t1,
1384  const prevariable & t2);
1385  friend prevariable & atan2(const prevariable & t1, double t2);
1386  friend prevariable & atan2(double t1, const prevariable & t2);
1387 
1388  friend prevariable & acos(const prevariable & t1);
1389 
1390  friend prevariable & asin(const prevariable & t1);
1391 
1392  friend prevariable & cos(const prevariable & t1);
1393  friend prevariable & sinh(const prevariable & t1);
1394  friend prevariable & cosh(const prevariable & t1);
1395 
1396  friend prevariable & log(const prevariable & t1);
1397  friend prevariable & log10(const prevariable & t1);
1398 
1399  friend prevariable & ldexp(const prevariable &, const int &);
1400 
1401 
1402  public:
1403  void save_prevariable_position() const;
1405  void save_prevariable_value() const;
1406  double restore_prevariable_value(void);
1407  double restore_prevariable_derivative(void);
1408 
1409 
1410  inline double *xadr()
1411  {
1412  return (&(v->x));
1413  }
1414  inline double &xval()
1415  {
1416  return ((v->x));
1417  }
1418 
1420  {
1421  return v;
1422  }
1423  inline double_and_int *get_v() const
1424  {
1425  return v;
1426  }
1427 
1429  prevariable & operator=(double);
1430 #if (__BORLANDC__ >= 0x0540)
1431  prevariable & operator=(const prevariable &) const;
1432  prevariable & operator=(double) const;
1433 #endif
1434 
1435  int operator==(const prevariable & v1) const;
1436  int operator<=(const prevariable & v1) const;
1437  int operator>=(const prevariable & v1) const;
1438  int operator>(const prevariable & v1) const;
1439  int operator<(const prevariable & v1) const;
1440  int operator!=(const prevariable & v1) const;
1441 
1442  int operator==(double v1) const;
1443  int operator<=(double v1) const;
1444  int operator>=(double v1) const;
1445  int operator>(double v1) const;
1446  int operator<(double v1) const;
1447  int operator!=(double v1) const;
1448 #if defined(USE_DDOUBLE)
1449  int operator==(int v1) const;
1450  int operator<=(int v1) const;
1451  int operator>=(int v1) const;
1452  int operator>(int v1) const;
1453  int operator<(int v1) const;
1454  int operator!=(int v1) const;
1455 #endif
1456 
1457  public:
1458  void initialize(void);
1459 
1460  friend char *fform(const char *, const prevariable &);
1461 
1463  void operator +=(double t1);
1464 
1465  void operator-=(const prevariable & t1);
1466  void operator -=(double t1);
1467 
1468  void operator/=(const prevariable & v1);
1469  void operator /=(double v1);
1470 
1471  void operator*=(const prevariable & v1);
1472  void operator *=(double v1);
1473 
1474  friend prevariable& operator+(const prevariable& v1, const prevariable& v2);
1475 
1476  friend prevariable & operator+(double v1, const prevariable & v2);
1477 
1478  friend prevariable & operator+(const prevariable & v1, double v2);
1479 
1480  friend prevariable & operator-(const prevariable & v1);
1481 
1482  friend prevariable & operator-(const prevariable& v1, const prevariable& v2);
1483 
1484  friend prevariable & operator-(double v1, const prevariable & v2);
1485 
1486  friend prevariable & operator-(const prevariable & v1, double v2);
1487 
1488  friend prevariable & pow(const prevariable & t1, const prevariable & t2);
1489 
1490  friend prevariable & pow(const prevariable & t1, double t2);
1491 
1492  friend prevariable & pow(double t1, const prevariable & t2);
1493 };
1494 
1495 inline double &value(const prevariable & v1)
1496 {
1497  return v1.v->x;
1498 }
1499 
1500 inline double *address(const prevariable & v1)
1501 {
1502  return (&(v1.v->x));
1503 }
1504 
1505 
1506 prevariable & operator<<(const prevariable & v1, const prevariable & v2);
1507 dvar_vector & operator<<(const dvar_vector & v1, const dvar_vector & v2);
1508 dvar_matrix & operator<<(const dvar_matrix & v1, const dvar_matrix & v2);
1509 
1510 class df1_one_variable;
1511 class df1_two_variable;
1512 class df1_three_variable;
1513 
1518 class dvariable: public prevariable
1519 {
1520 public:
1527  {
1528  (*v).x = 0.0;
1529 
1530 #ifdef SAFE_INITIALIZE
1532  default_evaluation0,&((*v).x));
1533 #endif
1534  }
1541  {
1542  v->x = t.v->x;
1544  set_gradient_stack(default_evaluation1,&(v->x),&(t.v->x));
1545  }
1552  dvariable(const double t): prevariable(gradnew())
1553  {
1554  v->x = t;
1555  //(*v).nc=0;
1557  &(v->x));
1558  }
1565  dvariable(const int &t): dvariable(static_cast<double>(t)) {}
1571  {
1572  //(*v).nc=0;
1573  }
1580  {
1581  //(*v).nc=0;
1582  v->x = t.v->x;
1584  set_gradient_stack(default_evaluation1,&(v->x),&(t.v->x));
1585  }
1587  virtual ~dvariable() { gradfree((dlink*)v); }
1588 
1589  //dvariable& operator=(const dvariable&);
1595  dvariable& operator=(const double x)
1596  {
1598  return *this;
1599  }
1600 
1607  {
1608  prevariable::operator=(other);
1609  return *this;
1610  }
1612  {
1613  prevariable::operator=(other);
1614  return *this;
1615  }
1619 
1620 #if defined(USE_DDOUBLE)
1621 # undef double
1622 # define double dd_real
1623 #endif
1624 
1625 //# if (__BORLANDC__ > 0x0520)
1626 // dvariable& operator+=(const prevariable&);
1627 //# endif
1628 };
1629 
1630 #if defined(max)
1631 #undef max
1632 #endif
1633 #if defined(min)
1634 #undef min
1635 #endif
1636 
1642 {
1643  public:
1644  dvariable & operator=(const prevariable &);
1645 };
1646 
1647 dvar_vector operator*(const dvar_vector & t1, double x);
1648 dvar_vector operator/(double x, const dvar_vector & t1);
1649 dvar_vector operator/(const dvar_vector & t1, double x);
1650 dvar_vector operator+(double x, const dvar_vector & t1);
1651 dvar_vector operator+(const dvar_vector & t1, double x);
1652 dvar_vector operator-(double x, const dvar_vector & t1);
1653 dvar_vector operator-(const dvar_vector & t1, double x);
1654 dvar_vector operator-(const dvar_vector & t1);
1655 dvar_vector operator*(const dvar_vector & t1, const prevariable & x);
1656 dvar_vector operator/(const prevariable & x, const dvar_vector & t1);
1657 dvar_vector operator/(const dvar_vector & t1, const prevariable & x);
1658 dvar_vector operator+(const prevariable & x, const dvar_vector & t1);
1659 dvar_vector operator+(const dvar_vector & t1, const prevariable & x);
1660 dvar_vector operator-(const prevariable & x, const dvar_vector & t1);
1661 dvar_vector operator-(const dvar_vector & t1, const prevariable & x);
1662 dvar_vector operator-(const dvector & t1, const prevariable & x);
1663 dvar_vector operator*(const dvector & t1, const prevariable & x);
1664 dvar_vector operator*(const prevariable & x, const dvector & t1);
1665 
1666 dvector operator*(const dvector & t1, double x);
1667 dvector operator/(double x, const dvector & t1);
1668 dvector operator/(const dvector & t1, double x);
1669 dvector operator+(double x, const dvector & t1);
1670 dvector operator+(const dvector & t1, double x);
1671 dvector operator-(double x, const dvector & t1);
1672 dvector operator-(const dvector & t1, double x);
1673 dvector operator-(const dvector & t1);
1674 
1675 double min(const dmatrix &);
1676 double max(const dmatrix &);
1677 int max(const imatrix &);
1678 double max(const dvector &);
1679 dvariable max(const dvar_vector &);
1680 dvariable min(const dvar_vector &);
1681 
1682 dmatrix symmetrize(const dmatrix & m1);
1683 dvector eigenvalues(const dmatrix & m1);
1684 dmatrix eigenvectors(const dmatrix & m1);
1685 dmatrix eigenvectors(const dmatrix & m1, const dvector & eigenvalues);
1686 
1687 dvar_matrix symmetrize(const dvar_matrix & m1);
1688 dvar_vector eigenvalues(const dvar_matrix & m1);
1690 
1691 dmatrix outer_prod(const dvector & t1, const dvector & t2);
1692 dvar_matrix outer_prod(const dvar_vector & t1, const dvar_vector & t2);
1693 dvar_matrix outer_prod(const dvector & t1, const dvar_vector & t2);
1694 dvar_matrix outer_prod(const dvar_vector & t1, const dvector & t2);
1695 dmatrix operator*(double x, const dmatrix & m);
1696 dmatrix operator*(const dmatrix & m, double d);
1697 dmatrix operator/(const dmatrix & m, double d);
1698 dmatrix operator/(double d, const dmatrix & m);
1699 dmatrix operator+(double x, const dmatrix & m);
1700 dvar_matrix operator +(const dvariable & x, const dmatrix & m);
1701 dvar_matrix operator -(const dvariable & x, const dmatrix & m);
1702 dmatrix operator+(const dmatrix & m, double d);
1703 dmatrix operator-(double x, const dmatrix & m);
1704 dmatrix operator-(const dmatrix & m, double d);
1705 dvar_matrix operator/(const dvar_matrix & m, const prevariable & x);
1706 dvar_matrix operator/(const dmatrix & m, const prevariable & x);
1707 dvar_matrix operator/(const dvar_matrix & m, double x);
1708 dvar_matrix operator/(double x, const dvar_matrix & m);
1709 dvar_matrix operator/(const prevariable & x, const dvar_matrix & m);
1710 
1711 dvar_matrix operator*(const prevariable & x, const dmatrix & m);
1712 dvar_matrix operator*(const dvar_matrix & m, const prevariable & x);
1713 dvar_matrix operator*(const prevariable & x, const dvar_matrix & m);
1714 dvar_matrix operator*(double x, const dvar_matrix & m);
1715 
1716 dvector operator&(const dvector & t1, const dvector & t2);
1717 dvar_vector operator&(const dvar_vector & t1, const dvar_vector & t2);
1718 
1719 ivector column(const imatrix& m, int i);
1720 dvector extract_column(const dmatrix & m, int i);
1721 dvector column(const dmatrix & m, int i);
1722 dvector extract_row(const dmatrix & m, int j);
1723 dvector row(const dmatrix & m, int j);
1724 dvar_vector extract_column(const dvar_matrix & m, int i);
1725 dvar_vector column(const dvar_matrix & m, int i);
1726 dvector column_value(const dvar_matrix & m, int i);
1727 dvar_vector extract_row(const dvar_matrix & m, int j);
1728 dvar_vector row(const dvar_matrix & m, int j);
1729 
1730 // dvector mathematical functions
1731 dvector sin(const dvector & t1);
1732 dvector sqrt(const dvector & t1);
1733 dvector sqr(const dvector & t1);
1734 dvector exp(const dvector & t1);
1735 dvector mfexp(const dvector & t1);
1736 dvector mfexp(const dvector & t1, double d);
1737 dvector atan(const dvector & t1);
1738 dvector tan(const dvector & t1);
1739 dvector tanh(const dvector & t1);
1740 dvector atan2(const dvector & t1, const dvector & t2);
1741 dvector atan2(const dvector & t1, double t2);
1742 dvector atan2(double t1, const dvector & t2);
1743 dvector acos(const dvector & t1);
1744 dvector asin(const dvector & t1);
1745 dvector cos(const dvector & t1);
1746 dvector sinh(const dvector & t1);
1747 dvector cosh(const dvector & t1);
1748 dvector log(const dvector & t1);
1749 dvector log10(const dvector & t1);
1750 dvector pow(const dvector & t1, double);
1751 dvector pow(const dvector & t1, int);
1752 dvector pow(double, const dvector & t1);
1753 ivector pow(const ivector & v1, int x);
1754 ivector pow(int x, const ivector & v1);
1755 // end of dvector mathematical functions
1756 
1757 // dvar_vector mathematical functions
1758 dvar_vector sin(const dvar_vector & t1);
1759 dvar_vector sqrt(const dvar_vector & t1);
1760 dvar_vector sqr(const dvar_vector & t1);
1761 dvar_vector exp(const dvar_vector & t1);
1762 dvar_vector mfexp(const dvar_vector & t1);
1763 dvar_vector mfexp(const dvar_vector & t1, double d);
1764 dvar_vector atan(const dvar_vector & t1);
1765 dvar_vector tan(const dvar_vector & t1);
1766 dvar_vector tanh(const dvar_vector & t1);
1767 dvar_vector atan2(const dvar_vector & t1, const dvar_vector & t2);
1768 dvar_vector atan2(const dvar_vector & t1, double t2);
1769 dvar_vector atan2(double t1, const dvar_vector & t2);
1770 dvar_vector acos(const dvar_vector & t1);
1771 dvar_vector asin(const dvar_vector & t1);
1772 dvar_vector cos(const dvar_vector & t1);
1773 dvar_vector sinh(const dvar_vector & t1);
1774 dvar_vector cosh(const dvar_vector & t1);
1775 dvar_vector log(const dvar_vector & t1);
1776 dvar_vector log10(const dvar_vector & t1);
1777 dvar_vector pow(const dvar_vector &, const dvar_vector & t1);
1778 dvar_vector pow(const dvar_vector &, const dvector & t1);
1779 dvar_vector pow(const dvector &, const dvar_vector & t1);
1780 dvector pow(const dvector &, const dvector & t1);
1781 dvar_vector pow(const dvar_vector & t1, double);
1782 dvar_vector pow(const dvar_vector & t1, int);
1783 dvar_vector pow(const dvar_vector & t1, const prevariable &);
1784 dvar_vector pow(const dvector & t1, const prevariable &);
1785 dvar_vector pow(const prevariable &, const dvar_vector & t1);
1786 dvar_vector pow(const dvector & x, const dvar_vector & a);
1787 // end of dvar_vector mathematical functions
1788 
1789 // dmatrix mathematical functions
1790 dmatrix exp(const dmatrix & m);
1791 dmatrix mfexp(const dmatrix & m);
1792 dmatrix mfexp(const dmatrix & m, double d);
1793 dmatrix sqrt(const dmatrix & m);
1794 dmatrix sqr(const dmatrix & m);
1795 dmatrix pow(const dmatrix & m, double e);
1796 dmatrix pow(const dmatrix & m, int e);
1797 dmatrix log(const dmatrix & m);
1798 dmatrix sin(const dmatrix & m);
1799 dmatrix cos(const dmatrix & m);
1800 dmatrix tan(const dmatrix & m);
1801 dmatrix elem_div(const dmatrix & m, const dmatrix & m2);
1802 dmatrix elem_prod(const dmatrix & m, const dmatrix & m2);
1803 // end of dmatrix mathematical functions
1804 
1805 // dvar_matrix mathematical functions
1806 dvar_matrix exp(const dvar_matrix & m);
1807 dvar_matrix mfexp(const dvar_matrix & m);
1808 dvar_matrix mfexp(const dvar_matrix & m, double d);
1809 dvar_matrix sqrt(const dvar_matrix & m);
1810 dvar_matrix sqr(const dvar_matrix & m);
1811 dvar_matrix log(const dvar_matrix & m);
1812 dvar_matrix sin(const dvar_matrix & m);
1813 dvar_matrix cos(const dvar_matrix & m);
1814 dvar_matrix tan(const dvar_matrix & m);
1815 dvar_matrix pow(const dvar_matrix & m, double e);
1816 dvar_matrix pow(const dvar_matrix & m, const prevariable & e);
1817 dvar_matrix pow(const dmatrix & m, const prevariable & e);
1818 dvar_matrix pow(const dvar_matrix & m, int e);
1819 dvar_matrix elem_prod(const dvar_matrix & m, const dvar_matrix & m2);
1820 dvar_matrix elem_prod(const dvar_matrix & m, const dmatrix & m2);
1821 dvar_matrix elem_prod(const dmatrix & m, const dvar_matrix & m2);
1822 dvar_matrix elem_div(const dvar_matrix & m, const dvar_matrix & m2);
1823 dvar_matrix elem_div(const dvar_matrix & m, const dmatrix & m2);
1824 dvar_matrix elem_div(const dmatrix & m, const dvar_matrix & m2);
1825 // end of dvar_matrix mathematical functions
1826 
1827 int min(const ivector & t1);
1828 int max(const ivector & t1);
1829 int Max(const ivector & t1);
1830 
1831 double mfexp(double);
1832 double mfexp(double, double bound);
1833 dvariable mfexp(const prevariable &);
1834 dvariable mfexp(const prevariable &, double bound);
1835 
1836 #if defined(THREAD_SAFE)
1837 
1840 class ts_vector_shapex
1841 {
1842  public:
1843  void *trueptr;
1844  ts_vector_shapex(int lb, int ub, void *p):index_min(lb),
1845  index_max(ub), ncopies(0), trueptr(p)
1846  {
1847  }
1848  void *get_truepointer(void)
1849  {
1850  return trueptr;
1851  }
1852  //friend class dvector;
1853  friend class ivector;
1854  //friend class tdvector;
1855  friend class dvar_vector;
1856 
1857 # if defined(USE_VECTOR_SHAPE_POOL)
1858  static ts_vector_shape_pool** xpool;
1859  void *operator new(size_t);
1860  void operator delete(void *ptr, size_t n);
1861 # endif
1862 
1863  unsigned int ncopies;
1864  void shift(int min);
1865  int index_min;
1866  int index_max;
1867  private:
1868  friend class subdvector;
1869  friend class lvector;
1870  friend class ptr_vector;
1871  public:
1872  int decr_ncopies(void)
1873  {
1874  return --ncopies;
1875  }
1876  int get_ncopies(void)
1877  {
1878  return ncopies;
1879  }
1880  int incr_ncopies(void)
1881  {
1882  return ++ncopies;
1883  }
1884  int indexmin()
1885  {
1886  return index_min;
1887  }
1888  int indexmax()
1889  {
1890  return index_max;
1891  }
1892 };
1893 #endif
1894 
1895 #include "vector_shapex.h"
1896 
1902 {
1904  int lb;
1905  int ub;
1906  inline predvector(dvector * _p, int _lb, int _ub)
1907  {
1908  p = _p;
1909  lb = _lb, ub = _ub;
1910  }
1911  friend class dvector;
1912 };
1913 
1919 {
1921  int lb;
1922  int ub;
1923  inline predvar_vector(dvar_vector * _p, int _lb, int _ub)
1924  {
1925  p = _p;
1926  lb = _lb, ub = _ub;
1927  }
1928  friend class dvar_vector;
1929 };
1930 
1931 #include "dvector.h"
1932 
1938 {
1939 public:
1942 
1944  independent_variables(other.indexmin(), other.indexmax())
1945  {
1947  }
1948 
1949  independent_variables(int ncl, int ncu): dvector(ncl, ncu)
1950  {
1951  }
1952  // makes an array [ncl..ncu]
1953 
1954  independent_variables(unsigned int sz, double* x): dvector(sz, x)
1955  {
1956  }
1957 
1960  {
1961  if (get_v() == nullptr)
1962  {
1963  int min = other.indexmin();
1964  int max = other.indexmax();
1965  dvector::allocate(min, max);
1966  }
1967  return independent_variables::operator=(static_cast<const dvector&>(other));
1968  }
1969 };
1970 
1971 dvariable dfatan1(dvariable, double, double, const prevariable & fpen);
1972 
1973 double boundp(double x, double fmin, double fmax, const double &fpen);
1974 double boundp(double x, double fmin, double fmax);
1975 
1976 dvariable boundp(const prevariable & x, double fmin, double fmax,
1977  const prevariable & fpen);
1978 dvariable boundp(const prevariable & x, double fmin, double fmax,
1979  const prevariable & fpen, double s);
1980 
1981 double nd2fboundp(double x, double minb, double maxb, const double &pen);
1982 double boundpin(double x, double fmin, double fmax);
1983 double boundpin(const prevariable & x, double fmin, double fmax);
1984 double boundpin(const prevariable & x, double fmin, double fmax, double s);
1985 
1986 double dmin(double, double);
1987 
1988 double dmax(double i, double j);
1989 
1990 #include <stdlib.h>
1991 #ifdef __TURBOC__
1992  #include <alloc.h>
1993 #endif
1994 
1995 double sigmoid(double t1);
1996 
2002 {
2003  unsigned int ncopies;
2004  unsigned int nrows;
2005  unsigned int ncols;
2006  int row_min;
2007  int row_max;
2008  int col_min;
2009  int col_max;
2010  mat_shape(int rl, int ru, int cl = 0, int cu = -1);
2012  {
2013  };
2014  void colshift(int min);
2015  void rowshift(int min);
2016 
2017  //friend class const_dmatrix;
2018  friend class dmatrix;
2019  friend class sdmatrix;
2020  friend class dvar_matrix;
2021  friend class imatrix;
2022  friend class lmatrix;
2023  friend class i3_array;
2024 };
2025 
2031 {
2032  public:
2033  void *trueptr;
2034  unsigned int ncopies;
2035  mat_shapex(const void *m)
2036  {
2037  trueptr = (void *) m;
2038  ncopies = 0;
2039  }
2041  {
2042  trueptr = NULL;
2043  ncopies = 0;
2044  };
2045 
2046  void *get_pointer(void)
2047  {
2048  return trueptr;
2049  }
2050  friend class dmatrix;
2051  friend class sdmatrix;
2052  friend class dvar_matrix;
2053  friend class imatrix;
2054  friend class i3_array;
2055  friend class lmatrix;
2056 };
2057 
2058 class arr_link;
2059 
2065 {
2068  unsigned long int last_offset;
2069  unsigned long int max_last_offset;
2070  public:
2071  unsigned long int number_arr_links;
2072  friend class arr_link;
2073 
2076 
2077  public:
2079  {
2080  last = 0;
2081  free_last = 0;
2082  last_offset = 0;
2083  max_last_offset = 0;
2084  number_arr_links = 0;
2085  }
2086  virtual ~arr_list()
2087  {
2090  }
2091 
2093  { return last; }
2094 
2095  unsigned long int get_last_offset()
2096  {
2097  return last_offset;
2098  }
2099  unsigned long int get_number_arr_links()
2100  {
2101  return number_arr_links;
2102  }
2103  unsigned long int get_max_last_offset()
2104  {
2105  return max_last_offset;
2106  }
2108  {
2109  max_last_offset = 0;
2110  }
2111 
2112  double_and_int* arr_new(unsigned int sz);
2113  void arr_free(double_and_int* varr);
2114  void arr_free_add(arr_link* tmp);
2115  void arr_free_remove(arr_link* tmp);
2116  void arr_remove(arr_link** pptr);
2117 };
2118 
2124 {
2129  unsigned int status;
2130  // unsigned int free_list_status;
2131  unsigned int size;
2132  unsigned long int offset;
2133 
2134 #if defined(USE_VECTOR_SHAPE_POOL)
2135 public:
2137 
2138  void* operator new(size_t);
2139  void operator delete(void* ptr, size_t);
2140  arr_link(const arr_link&) = delete;
2141  arr_link& operator=(const arr_link&) = delete;
2142 #endif
2143 
2144 public:
2145  arr_link();
2146 
2148  { return prev; }
2150  { return next; }
2151  unsigned int get_size() const
2152  { return size; }
2153  unsigned long get_offset() const
2154  { return offset; }
2155  unsigned int get_status() const
2156  { return status; }
2157 
2158  friend class arr_list;
2159 };
2160 
2161 #if defined(__NUMBERVECTOR__)
2167 #endif
2168 
2173 {
2174 public:
2180 
2181  public:
2183 
2185  {
2186  index_min--;
2187  index_max--;
2188  va++;
2189  return *this;
2190  }
2192  {
2193  index_min++;
2194  index_max++;
2195  va--;
2196  return *this;
2197  }
2198  dvar_vector sub(int lb, int ub)
2199  {
2200  return predvar_vector(this, lb, ub);
2201  }
2202  dvar_vector operator () (int lb, int ub)
2203  {
2204  return predvar_vector(this, lb, ub);
2205  }
2206  void shallow_copy(const dvar_vector &);
2207  int operator!(void) const
2208  {
2209  return (shape == NULL);
2210  }
2211  friend class dvar_matrix;
2212  friend class dvar3_array;
2217 
2218  void fill_randpoisson(double lambda, const random_number_generator & rng);
2219  void fill_randnegbinomial(double lambda, double tau,
2220  const random_number_generator & rng);
2222  {
2223  return (va + i);
2224  }
2225 
2226  double &elem_value(int i)
2227  {
2228  return (va[i].x);
2229  }
2230 
2232  {
2233  return va;
2234  }
2235 
2236  prevariable elem(int i) const
2237  {
2238  return (va + i);
2239  }
2240 
2241  double &elem_value(int i) const
2242  {
2243  return (va[i].x);
2244  }
2245 
2247  {
2248  return va;
2249  }
2250 
2251  friend dvar_matrix operator*(const dvar_matrix & m1, const dmatrix & m2);
2252 
2253  void deallocate();
2254  dvar_vector(const dvar_vector &);
2255  dvar_vector(const predvar_vector &);
2256  dvar_vector();
2257  dvar_vector(int ncl, int ncu); // makes an array [ncl..ncu]
2258  dvar_vector(int ncl, int ncu, kkludge_object);
2259 
2260  //dvar_vector(const ad_integer&,const ad_integer&);
2261  dvar_vector(unsigned int sz, double *x);
2263  friend char *fform(const char *, const dvar_vector &);
2264 # if defined(__NUMBERVECTOR__)
2267 # endif
2268  dvar_vector(const dvector &);
2269  dvar_vector(const char *);
2270  ~dvar_vector();
2271  void allocate(int, int);
2272  void allocate(void);
2273  void allocate(const dvector &);
2274  void allocatec(const dvar_vector &);
2275  void allocate(const dvar_vector &);
2276 
2277  void allocate(const ad_integer &, const ad_integer &);
2278  void initialize(const dvector & ww);
2279  void initialize(void);
2280  void save_dvar_vector_position() const;
2281  void save_dvar_vector_value() const;
2282  void write_on(const ostream &) const;
2283  void write_on(const uostream &) const;
2284  void read_from(const istream &);
2285  void read_from(const uistream &);
2286  // returns the minimum allowable index
2287  int indexmin() const
2288  {
2289  return index_min;
2290  }
2291  // returns the maximum allowable index
2292  int indexmax() const
2293  {
2294  return index_max;
2295  }
2296  // returns the number of elements
2297  unsigned int size() const
2298  {
2299  return static_cast<unsigned int>(
2300  index_max < index_min ? 0 : index_max - index_min + 1);
2301  }
2302  dvar_vector & shift(int min);
2303 
2304 #ifdef OPT_LIB
2305  #if defined(__NDPX__) || defined(__SUN__)
2306  inline prevariable operator() (register int i)
2307  {
2308  return (va + i);
2309  }
2310  inline prevariable operator[] (register int i)
2311  {
2312  return (va + i);
2313  }
2314  inline const prevariable operator() (int i) const
2315  {
2316  return (va + i);
2317  }
2318  inline const prevariable operator[] (int i) const
2319  {
2320  return (va + i);
2321  }
2322  #else
2323  inline prevariable operator() (int i)
2324  {
2325  return (va + i);
2326  }
2327  inline prevariable operator[] (int i)
2328  {
2329  return (va + i);
2330  }
2331  inline const prevariable operator() (int i) const
2332  {
2333  return (va + i);
2334  }
2335  inline const prevariable operator[] (int i) const
2336  {
2337  return (va + i);
2338  }
2339  #endif
2340 #else
2341  prevariable operator[] (int i);
2342  prevariable operator() (int i);
2343  const prevariable operator[] (int i) const;
2344  const prevariable operator() (int i) const;
2345 #endif
2346 
2347  double *initpointer(void)
2348  {
2349  return ((double *) (va + indexmin()));
2350  }
2351  const double *initpointer(void) const
2352  {
2353  return ((double *) (va + indexmin()));
2354  }
2355  dvar_vector operator() (const lvector &);
2356  //dvar_vector operator()(int,int);
2357  dvar_vector operator () (const ivector & u);
2358  dvar_vector & operator+=(const prevariable & d);
2359  dvar_vector & operator+=(double d);
2360  dvar_vector & operator/=(const prevariable & d);
2361  //dvar_vector& operator*=(const dvariable& d);
2362  dvar_vector & operator*=(const prevariable & d);
2363  dvar_vector & operator*=(double d);
2364  dvar_vector & operator/=(double d);
2365  dvar_vector & operator-=(const prevariable & d);
2366  dvar_vector & operator-=(double d);
2367  dvar_vector & operator+=(const dvector & v1);
2368  dvar_vector & operator-=(const dvector & v1);
2369  dvar_vector & operator+=(const dvar_vector & v1);
2370  dvar_vector & operator-=(const dvar_vector & v1);
2371  dvar_vector & operator=(const dvar_vector & t);
2372  dvar_vector & operator=(const dvector & t);
2373  dvar_vector & operator =(double t);
2374  dvar_vector & operator=(const prevariable & t);
2375  void fill(const char *);
2376  void fill_randu(long int &n);
2377  void fill_randn(long int &n);
2378  void fill_randbi(long int &n, double);
2379 
2380  void fill_randu_ni(long int &n);
2381  void fill_randn_ni(long int &n);
2382  void fill_randbi_ni(long int &n, double);
2383 
2384  void fill_seqadd(double, double);
2385  void fill_multinomial(const int &seed, const dvector & p);
2386  void fill_multinomial(const random_number_generator& rng, const dvector& p);
2387  friend dvar_vector operator+(const dvar_vector &, const dvar_vector &);
2388  friend dvar_vector operator+(const dvar_vector &, const dvector &);
2389  friend dvar_vector operator+(const dvector &, const dvar_vector &);
2390  friend dvar_vector operator-(const dvar_vector &, const dvar_vector &);
2391 
2392  friend dvar_vector operator-(const dvector &, const dvar_vector &);
2393 
2394  friend dvar_vector operator-(const dvar_vector &, const dvector &);
2395 
2396  friend dvar_vector sigmoid(const dvar_vector & t1);
2397 
2398  friend dvariable operator*(const dvar_vector &, const dvar_vector &);
2399 
2400  friend dvar_vector elem_div(const dvar_vector &, const dvar_vector &);
2401 
2402  friend dvariable operator*(const dvector &, const dvar_vector &);
2403 
2404  friend dvariable operator*(const dvar_vector &, const dvector &);
2405 
2406  friend dvar_vector operator*(const prevariable &, const dvar_vector &);
2407 
2408  friend dvar_vector operator*(const prevariable &, const dvector &);
2409 
2410  friend dvar_vector operator*(double, const dvar_vector &);
2411 
2412  friend dvar_vector operator*(const dvar_vector &, const dmatrix &);
2413 
2414  friend dvar_vector operator*(const dmatrix &, const dvar_vector &);
2415 
2416  friend dvar_vector operator*(const dvar_vector &, const dvar_matrix &);
2417 
2418  friend dvar_vector operator*(const dvar_matrix &, const dvar_vector &);
2419 
2420  friend dvar_matrix operator*(const dvar_matrix &, const dvar_matrix &);
2421 
2422  friend dvar_matrix operator*(const dmatrix &, const dvar_matrix &);
2423 
2424  friend dvar_vector elem_prod(const dvar_vector &, const dvar_vector &);
2425 
2426  friend dvar_vector first_difference(const dvar_vector &);
2427  friend dvar_vector second_difference(const dvar_vector &);
2428 
2429  // js, see above
2430  //friend dvar_vector elem_div(const dvar_vector&, const dvar_vector&);
2431 
2432  friend dvar_vector elem_prod(const dvector &, const dvar_vector &);
2433 
2434  friend dvar_vector elem_div(const dvector &, const dvar_vector &);
2435 
2436  friend dvar_vector elem_prod(const dvar_vector &, const dvector &);
2437 
2438  friend dvar_vector elem_div(const dvar_vector &, const dvector &);
2439 
2440  friend dvariable norm(const dvar_vector &);
2441  friend dvariable norm2(const dvar_vector &);
2442  friend dvariable sumsq(const dvar_vector &);
2443 
2444  friend void copy_status(const ostream & s, const dvar_vector & v);
2445 
2446  friend dvar_vector exp(const dvar_vector &);
2447 
2448  friend dvar_vector log(const dvar_vector &);
2449 
2450  friend dvar_vector sin(const dvar_vector &);
2451 
2452  friend dvar_vector fabs(const dvar_vector &);
2453 
2454  friend dvector value(const dvar_vector & v1);
2455 
2456  friend dvar_vector sfabs(const dvar_vector &);
2457 
2458  friend void make_indvar_list(const dvar_vector &);
2459  friend class array_size;
2460 
2461  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
2462 };
2463 
2464  /*
2465  class funnel_dvar_vector : public dvar_vector
2466  {
2467  public:
2468  funnel_dvar_vector(int l,int u);
2469  dvar_vector& operator=(const dvar_vector&);
2470  };
2471  */
2472 
2473 //class fvar_ptr { dvar_vector *p; };
2474 
2481 {
2486 
2487  public:
2489  {
2490  index_min--;
2491  index_max--;
2492  m++;
2493  return *this;
2494  }
2496  {
2497  index_min++;
2498  index_max++;
2499  m--;
2500  return *this;
2501  }
2502 
2503  int operator!(void) const
2504  {
2505  return (shape == NULL);
2506  }
2507  inline dvar_vector & elem(int i)
2508  {
2509  return (m[i]);
2510  }
2511  inline prevariable elem(int i, int j)
2512  {
2513  return (elem(i).elem(j));
2514  }
2515  inline dvar_vector & elem(int i) const
2516  {
2517  return (m[i]);
2518  }
2519  inline prevariable elem(int i, int j) const
2520  {
2521  return (elem(i).elem(j));
2522  }
2523 
2528  friend class dvar3_array;
2529  void shallow_copy(const dvar_matrix&);
2530  dvar_matrix();
2531  void allocate(int nrl, int nrh, int ncl, int nch);
2532  void allocate(int nrl, int nrh);
2533  void allocate(ad_integer nrl, ad_integer nrh);
2534  void allocate(const dmatrix & m1);
2535  void allocate(const dvar_matrix & m1);
2536  void allocate(int nrl, int nrh, const ivector & ncl, const ivector & nch);
2537  void allocate(int nrl, int nrh, int ncl, const ivector & nch);
2538  void allocate(int nrl, int nrh, const ivector & ncl, int nch);
2539  void allocate(void);
2540  void deallocate();
2543 # if defined(__NUMBERVECTOR__)
2547 # endif
2548  dvar_matrix sub(int, int);
2549 
2550  double fill_seqadd(double, double);
2551 
2552  int colmin(void) const
2553  {
2554  return ((*this) (indexmin()).indexmin());
2555  }
2556  int colmax(void) const
2557  {
2558  return ((*this) (indexmin()).indexmax());
2559  }
2560  int rowmin(void) const
2561  {
2562  return (index_min);
2563  }
2564  int rowmax(void) const
2565  {
2566  return (index_max);
2567  }
2568  int indexmin(void) const
2569  {
2570  return (index_min);
2571  }
2572  int indexmax(void) const
2573  {
2574  return (index_max);
2575  }
2576 
2577  // returns the number of rows
2578  unsigned int rowsize() const
2579  {
2580  int size = rowmax() - rowmin() + 1;
2581  return static_cast<unsigned int>(size < 0 ? 0 : size);
2582  }
2583  // returns the number of columns
2584  unsigned int colsize() const
2585  {
2586  int size = rowsize() > 0 ? colmax() - colmin() + 1 : 0;
2587  return static_cast<unsigned int>(size < 0 ? 0 : size);
2588  }
2589  void colshift(int min);
2590  void rowshift(int min);
2591 
2592  friend char *fform(const char *, const dvar_matrix &);
2593 
2594  friend class dvar_vector;
2595 
2596  dvar_matrix(const ad_integer & nrl, const ad_integer & nrh,
2597  const index_type & ncl, const index_type & nch);
2598 
2599  void allocate(const ad_integer & nrl, const ad_integer & nrh,
2600  const index_type & ncl, const index_type & nch);
2601 
2602  dvar_matrix(int, int, int, int);
2603  dvar_matrix(int, int);
2604  dvar_matrix(int, int, kkludge_object kk);
2605  // makes a matrix [nrl..nrh][ncl..nch]
2606 
2607  dvar_matrix(int, int, const ivector &, const ivector &);
2608  // makes a ragged dvar_matrix [nrl..nrh][ncl..nch]
2609 
2610  dvar_matrix(int, int, int, const ivector &);
2611  // makes a ragged dvar_matrix [nrl..nrh][ncl..nch]
2612 
2613  dvar_matrix(const dvar_matrix &);
2614  // copy initializer
2615  void initialize(void);
2616 
2617  dvar_matrix(const dmatrix &);
2618 
2619  //dvar_matrix(char *);
2620 
2621  ~dvar_matrix();
2622 
2623  void save_dvar_matrix_position() const;
2624  void save_dvar_matrix_value() const;
2625 
2626  void fill(const char *);
2627  //void colfill(const int&n,...);
2628  //void rowfill(const int&n,...);
2629 
2630  void colfill_randu(const int &j, long int &n);
2631  void rowfill_randu(const int &i, long int &n);
2632  void colfill_randn(const int &j, long int &n);
2633  void rowfill_randn(const int &i, long int &n);
2634  void fill_randn(long int &n);
2635  void fill_randu(long int &n);
2636 
2637  void colfill_seqadd_ni(const int &, double, double);
2638  void colfill_randu_ni(const int &j, long int &n);
2639  void rowfill_randu_ni(const int &i, long int &n);
2640  void colfill_randn_ni(const int &j, long int &n);
2641  void rowfill_randn_ni(const int &i, long int &n);
2642  void fill_randn_ni(long int &n);
2643  void fill_randu_ni(long int &n);
2644 
2645  void colfill_seqadd(const int &, double, double);
2646  void rowfill_seqadd(const int &, double, double);
2647  void colfill(int j, const dvar_vector & v);
2648  void rowfill(int j, const dvar_vector & v);
2649 
2650  void write_on(const ostream &) const;
2651  void write_on(const uostream &) const;
2652  void read_from(const istream &);
2653  void read_from(const uistream &);
2654 
2655  dvar_vector& operator ()(int i);
2656  dvar_vector& operator[](int);
2657  const dvar_vector& operator()(int i) const;
2658  const dvar_vector& operator[](int) const;
2659 
2660 #ifdef OPT_LIB
2661 #ifdef __NDPX__
2662  prevariable operator () (register int i, register int j)
2663  {
2664  return (prevariable((m[i]).va + j));
2665  }
2666 #else
2667  inline prevariable operator()(int i, int j)
2668  {
2669  return ((m[i]).va + j);
2670  }
2671 #endif
2672 #else
2673  prevariable operator () (int i, int j);
2674 #endif
2675 
2676  inline double &elem_value(int i, int j)
2677  {
2678  return *(double *) ((m[i]).va + j);
2679  }
2680 
2681  inline const double &elem_value(int i, int j) const
2682  {
2683  return *(double *) ((m[i]).va + j);
2684  }
2685 #ifdef OPT_LIB
2686 #ifdef __NDPX__
2687  prevariable operator() (register int i, register int j) const
2688  {
2689  return (prevariable((m[i]).va + j));
2690  }
2691 #else
2692  inline prevariable operator()(int i, int j) const
2693  {
2694  return ((m[i]).va + j);
2695  }
2696 #endif
2697 #else
2698  const prevariable operator() (int i, int j) const;
2699 #endif
2700 
2701  dvar_matrix & operator+=(const dvar_matrix & x);
2702  dvar_matrix & operator-=(const dvar_matrix & x);
2703  dvar_matrix & operator+=(const dmatrix & x);
2704  dvar_matrix & operator-=(const dmatrix & x);
2705 
2706 
2707  dvar_matrix & operator=(const dvar_matrix &);
2708 
2709  dvar_matrix & operator=(const dmatrix &);
2710  dvar_matrix & operator =(double t);
2711  dvar_matrix & operator=(const prevariable & t);
2712 
2713  dvar_matrix & operator*=(const prevariable & t);
2714  dvar_matrix & operator *=(double t);
2715  dvar_matrix & operator/=(const prevariable & t);
2716  dvar_matrix & operator /=(double t);
2717 
2718  friend dvar_vector operator*(const dvar_vector &, const dvar_matrix &);
2719 
2720  friend dvar_vector operator*(const dvar_matrix &, const dvar_vector &);
2721 
2722  friend dvar_vector operator*(const dvector &, const dvar_matrix &);
2723 
2724  friend dvar_vector operator*(const dvar_matrix &, const dvector &);
2725 
2726  friend dvar_matrix operator*(const dvar_matrix &, const dvar_matrix &);
2727 
2728  friend dvar_matrix operator*(const dvar_matrix &, const dmatrix &);
2729 
2730  friend dvar_matrix operator*(const dmatrix &, const dvar_matrix &);
2731 
2732  friend dvar_matrix operator+(const dvar_matrix &, const dvar_matrix &);
2733  friend dvar_matrix operator+(const dvar_matrix &, const dmatrix &);
2734  friend dvar_matrix operator+(const dmatrix &, const dvar_matrix &);
2735 
2736  friend dvar_matrix operator+(double, const dvar_matrix &);
2737  friend dvar_matrix operator+(const dvar_matrix &, double);
2738  friend dvar_matrix operator-(double, const dvar_matrix &);
2739  friend dvar_matrix operator-(const dvar_matrix &, double);
2740 
2741  friend dvar_matrix operator+(const dvariable &, const dvar_matrix &);
2742  friend dvar_matrix operator+(const dvar_matrix &, const dvariable &);
2743  friend dvar_matrix operator-(const dvariable &, const dvar_matrix &);
2744  friend dvar_matrix operator-(const dvar_matrix &, const dvariable &);
2745 
2746  friend dvar_matrix operator-(const dvar_matrix &, const dvar_matrix &);
2747  friend dvar_matrix operator-(const dvar_matrix &, const dmatrix &);
2748  friend dvar_matrix operator-(const dmatrix &, const dvar_matrix &);
2749 
2750  friend dvar_matrix inv(const dvar_matrix &);
2751 
2752  friend dvariable det(const dvar_matrix &);
2753  friend dvariable ln_det(const dvar_matrix &, int& sgn);
2754 
2755  //friend dvar_matrix testsub(dvar_matrix);
2756 
2757  friend dvar_matrix trans(const dvar_matrix &);
2758 
2759  friend dvariable norm(const dvar_matrix &);
2760  friend dvariable norm2(const dvar_matrix &);
2761  friend dvariable sumsq(const dvar_matrix &);
2762 
2763  friend void copy_status(const ostream & s, const dvar_matrix & m1);
2764 
2765  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
2766 };
2767 
2768 #ifdef OPT_LIB
2770 {
2771  if (!m)
2772  throw std::bad_alloc();
2773  else
2774  return m[i];
2775 }
2777 {
2778  if (!m)
2779  throw std::bad_alloc();
2780  else
2781  return m[i];
2782 }
2783 inline const dvar_vector& dvar_matrix::operator[](int i) const
2784 {
2785  return m[i];
2786 }
2787 inline const dvar_vector& dvar_matrix::operator()(int i) const
2788 {
2789  return m[i];
2790 }
2791 #endif
2792 
2793 dvariable ln_det(const dvar_matrix &);
2794 dvar_matrix operator *(const dvar_matrix & t1, double x);
2795 dmatrix value(const dvar_matrix & m);
2796 d3_array value(const dvar3_array & a);
2797 dvar_vector sort(const dvar_vector &, int NSTACK = 60);
2798 dvector sort(const dvector &, int NSTACK = 60);
2799 ivector sort(const ivector &, int NSTACK = 60);
2800 dvector sort(const dvector &, const ivector & index, int NSTACK = 60);
2801 ivector sort(const ivector &, const ivector & index, int NSTACK = 60);
2802 dmatrix sort(const dmatrix &, int column, int NSTACK = 60);
2803 imatrix sort(const imatrix &, int column, int NSTACK = 60);
2804 
2805 
2806 #include "factors.h"
2807 int count_factor(const dvector & v, const double &eps);
2808 ivector as_factor(const dvector & v, const double eps = 1.0e-6);
2809 int count_factor(const ivector & v);
2810 
2811  //void gradcalc( int , double *);
2812 void gradcalc(int nvar, const dvector & g);
2813 void slave_gradcalc(void);
2814 
2819 class dmatrix
2820 {
2821  protected:
2826  friend char *fform(const char *, const dmatrix &);
2827  friend class dvar_matrix;
2828  public:
2830  {
2831  index_min--;
2832  index_max--;
2833  m++;
2834  return *this;
2835  }
2837  {
2838  index_min++;
2839  index_max++;
2840  m--;
2841  return *this;
2842  }
2843  void shallow_copy(const dmatrix &);
2844 
2846  bool operator!() const
2847  {
2848  return shape == nullptr;
2849  }
2850 
2851  dmatrix sub(int, int);
2852  dmatrix(void);
2853  dmatrix(int, int, kkludge_object);
2854  dmatrix(int, int);
2855  void allocate(void);
2856  void allocate(const dmatrix & dm);
2857  void allocate(const dvar_matrix &);
2858  void allocate(int nrl, int nrh, int ncl, int nch);
2859  void allocate(int nrl, int nrh);
2860  void allocate(ad_integer nrl, ad_integer nrh);
2861  void allocate(int nrl, int nrh, int ncl, const ivector & nch);
2862  //void allocate(int nrl,int nrh,
2863  // const index_type& ncl,const index_type& nch);
2864  void allocate(int nrl, int nrh, const ivector & ncl, int nch);
2865  void deallocate();
2866  void allocate(const ad_integer & nrl, const ad_integer & nrh,
2867  const index_type & ncl, const index_type & nch);
2868  void allocate(int nrl, int nrh, const ivector & ncl,
2869  const ivector & nch);
2872 
2873  dmatrix(int, int, int, int);
2874  // makes a matrix [nrl..nrh][ncl..nch]
2875 
2876  dmatrix(const ad_integer & nrl, const ad_integer & nrh,
2877  const index_type & ncl, const index_type & nch);
2878 
2879  dmatrix(int, int, const ivector & coll, const ivector & colh);
2880  // makes a ragged dmatrix[nrl..nrh][ncl..nch]
2881 
2882  dmatrix(int, int, int coll, const ivector & colh);
2883  // makes a ragged dmatrix[nrl..nrh][ncl..nch]
2884 
2885  dmatrix(const dvar_matrix_position &);
2886 
2887  dmatrix(const dmatrix_position &);
2888 
2889  dmatrix(const dmatrix &);
2892  dmatrix(char *);
2893  void fill(const char *);
2894  double fill_seqadd(double, double);
2895  void initialize(void);
2896  // copy initializer
2897 
2898  ~dmatrix();
2899 
2900  dvector* begin() const
2901  {
2902  return m ? &m[rowmin()] : nullptr;
2903  }
2904  dvector* end() const
2905  {
2906  return m ? begin() + rowsize() : nullptr;
2907  }
2908 
2911 
2912  void save_dmatrix_value() const;
2913  void save_dmatrix_position() const;
2914 
2915  //void save_dmatrix_derivatives(void);
2916 
2917  int indexmin() const
2918  {
2919  return rowmin();
2920  }
2921  int indexmax() const
2922  {
2923  return rowmax();
2924  }
2925  int rowmin() const
2926  {
2927  return index_min;
2928  }
2929  int rowmax() const
2930  {
2931  return index_max;
2932  }
2933  // returns the number of rows
2934  unsigned int rowsize() const
2935  {
2936  return static_cast<unsigned int>(rowmax() - rowmin() + 1);
2937  }
2938 
2939  int colmin(void) const
2940  {
2941  return ((*this) (indexmin()).indexmin());
2942  }
2943  int colmax(void) const
2944  {
2945  return ((*this) (indexmin()).indexmax());
2946  }
2947  // returns the number of columns
2948  unsigned int colsize() const
2949  {
2950  int size = rowsize() > 0 ? colmax() - colmin() + 1 : 0;
2951  return static_cast<unsigned int>(size < 0 ? 0 : size);
2952  }
2953  void rowshift(int min);
2954  void colshift(int min);
2955 
2956  void write_on(const ostream &) const;
2957  uostream& write_on(const uostream&) const;
2958  void read_from(const istream &);
2959  uistream& read_from(const uistream&);
2960 
2961  //void colfill(const int&n,...);
2962  //void rowfill(const int&n,...);
2963 
2964  void colfill_randu(const int &j, long int &n);
2965  void rowfill_randu(const int &i, long int &n);
2966  void colfill_randn(const int &j, long int &n);
2967  void fill_randn(long int &n);
2968  void fill_randu(long int &n);
2969  void rowfill_randn(const int &i, long int &n);
2970 
2971  void colfill_randu(const int &j, const random_number_generator & rng);
2972  void rowfill_randu(const int &i, const random_number_generator & rng);
2973  void fill_randn(const random_number_generator & rng);
2974  void fill_randcau(const random_number_generator & rng);
2975  void fill_randu(const random_number_generator & rng);
2976  void colfill_randn(const int &j, const random_number_generator & rng);
2977  void rowfill_randn(const int &i, const random_number_generator & rng);
2978 
2979  void colfill_randu_ni(const int &j, long int &n);
2980  void rowfill_randu_ni(const int &i, long int &n);
2981  void colfill_randn_ni(const int &j, long int &n);
2982  void fill_randn_ni(long int &n);
2983  void fill_randu_ni(long int &n);
2984  void rowfill_randn_ni(const int &i, long int &n);
2985 
2986  void colfill_seqadd(const int &, const int &, const int &);
2987  void colfill_seqadd(const int &, double, double);
2988  void rowfill_seqadd(const int &, double, double);
2989  void colfill(int j, const dvector & v);
2990  void rowfill(int j, const dvector & v);
2991 
2992  dvector& operator()(int i);
2993  dvector& operator[](int);
2994  const dvector& operator()(int i) const;
2995  const dvector& operator[](int) const;
2996 
2997 #if defined(OPT_LIB) && !defined(__INTEL_COMPILER)
2998  inline double& operator()(int i, int j)
2999  {
3000  return (*(m[i].v + j));
3001  }
3002  inline const double& operator()(int i, int j) const
3003  {
3004  return (*(m[i].v + j));
3005  }
3006 #else
3007  double &operator() (int i, int j);
3008  const double &operator() (int i, int j) const;
3009 #endif
3010 
3011  inline dvector & elem(int i)
3012  {
3013  return (*(m + i));
3014  }
3015  inline double &elem(int i, int j)
3016  {
3017  return (*((*(m + i)).v + j));
3018  }
3019  inline const dvector & elem(int i) const
3020  {
3021  return (*(m + i));
3022  }
3023  inline const double &elem(int i, int j) const
3024  {
3025  return (*((*(m + i)).v + j));
3026  }
3027  friend class d3_array;
3028  friend dvector operator*(const dvector &, const dmatrix &);
3029 
3030  friend dvector operator*(const dmatrix &, const dvector &);
3031 
3032  friend dvar_vector operator*(const dvar_vector &, const dmatrix &);
3033 
3034  friend dvar_vector operator*(const dmatrix &, const dvar_vector &);
3035 
3036  friend dmatrix operator*(const dmatrix &, const dmatrix &);
3037 
3038  friend dvar_matrix operator*(const dvar_matrix &, const dmatrix &);
3039 
3040  friend dvar_matrix operator*(const dmatrix &, const dvar_matrix &);
3041 
3042  friend dvar_matrix::dvar_matrix(const dmatrix &);
3043 
3044  friend dmatrix operator-(const dmatrix &, const dmatrix &);
3045  friend dmatrix operator+(const dmatrix &, const dmatrix &);
3046 
3047  friend dvar_matrix operator+(const dvar_matrix &, const dmatrix &);
3048 
3049  friend dvar_matrix operator+(const dmatrix &, const dvar_matrix &);
3050 
3051  friend dmatrix trans(const dmatrix & m1);
3052 
3053  friend dmatrix inv(const dmatrix &);
3054  friend dmatrix inv(const dmatrix & m1, const double &_ln_det,
3055  const int &_sgn);
3056 
3057  friend double det(const dmatrix &);
3058  friend double ln_det(const dmatrix & m1, int& sgn);
3059 
3060  friend double norm(const dmatrix &);
3061  friend double norm2(const dmatrix &);
3062  friend double sumsq(const dmatrix &);
3063 
3064  dmatrix & operator+=(const dmatrix & t);
3065  dmatrix & operator-=(const dmatrix & t);
3066 
3067  dmatrix & operator =(const dmatrix & t);
3068  dmatrix & operator =(double t);
3069 
3070  dmatrix operator() (const ivector & t);
3071 
3072  friend dvar_matrix & dvar_matrix::operator=(const dmatrix &);
3073 
3074  dmatrix(const tdmatrix & t);
3075 
3076  dmatrix & operator /=(double d);
3077  dmatrix & operator *=(double d);
3078 
3079  bool is_valid_row(const int i) const;
3080 };
3081 
3082 #if defined(OPT_LIB)
3084 {
3085  return m[i];
3086 }
3088 {
3089  return m[i];
3090 }
3091 inline const dvector& dmatrix::operator()(int i) const
3092 {
3093  return m[i];
3094 }
3095 inline const dvector& dmatrix::operator[](int i) const
3096 {
3097  return m[i];
3098 }
3099 #endif
3100 
3101 imatrix operator*(const imatrix &, const imatrix &);
3102 
3103 dmatrix trans(const dmatrix & m1);
3104 
3105 imatrix trans(const imatrix & m1);
3106 
3107 dvariable dfatan1(dvariable, double, double, double *);
3108 
3109 double dftinv(double, double, double);
3110 
3111 dvariable boundp(double, double, double, double *);
3112 
3113 dvariable dfboundp(double, double, double, double *);
3114 dvariable dfboundp(const prevariable &, double, double);
3115 
3116 double mean(const dvector &);
3117 double mean(const dmatrix &);
3118 double mean(const d3_array &);
3119 
3120 double std_dev(const dvector &);
3121 double var(const dvector &);
3122 
3123 dvariable mean(const dvar_vector &);
3124 dvariable mean(const dvar_matrix &);
3125 dvariable mean(const dvar3_array &);
3126 
3127 dvariable std_dev(const dvar_vector &);
3128 dvariable var(const dvar_vector &);
3129 
3130 dvariable sum(const dvar_vector &);
3131 double sum(const dvector &);
3132 int sum(const ivector &);
3133 
3134 dvar_vector rowsum(const dvar_matrix &);
3135 dvar_vector colsum(const dvar_matrix &);
3136 
3137 dvector colsum(const dmatrix &);
3138 dvector rowsum(const dmatrix &);
3139 
3140 ivector colsum(const imatrix &);
3141 ivector rowsum(const imatrix &);
3142 
3143 int colsum(const imatrix &, int column);
3144 double colsum(const dmatrix &, int column);
3145 dvariable colsum(const dvar_matrix &, int column);
3146 
3147 double sfabs(double t1); //"smoothed absolute value function
3148 
3149 dvector sfabs(const dvector & t1); //"smoothed absolute value function
3150 
3151 #include <imatrix.h>
3152 
3153 dvariable regression(const dvector & obs, const dvar_vector & pred);
3154 double regression(const dvector & obs, const dvector & pred);
3155 
3156 dvariable robust_regression_fixed(const dvector& obs, const dvar_vector& pred,
3157  double a = 0.7);
3158 dvariable robust_regression(const dvector & obs, const dvar_vector & pred,
3159  double a = 0.7);
3160 
3161 dvariable robust_regression(const dvector & obs, const dvar_vector & pred,
3162  const dvariable & cutoff);
3163 
3164 dmatrix column_vector(const dvector &);
3165 dmatrix row_vector(const dvector &);
3166 
3169 
3170 dmatrix identity_matrix(int min, int max);
3171 
3172 istream & operator>>(const istream & s, const ptr_vector & v);
3173 ostream & operator<<(const ostream & s, const ptr_vector & v);
3174 
3179 {
3180  public:
3182  long maxfn;
3183  long iprint;
3184  double crit;
3185  double fringe;
3186  long imax;
3187  double dfn;
3188  long ifn;
3189  long iexit;
3190  long ialph;
3191  long ihflag;
3192  long ihang;
3196  double min_improve;
3197  int ireturn;
3200 
3201  void set_defaults();
3202  fmm_control();
3203  fmm_control(const fmm_control &);
3204  fmm_control(const lvector & ipar);
3205  void writeon(const ostream & s) const;
3206 };
3207 
3212 class sdmatrix:public dmatrix
3213 {
3214  public:
3215  void allocate(int);
3216  void allocate();
3217  sdmatrix(int);
3218  sdmatrix();
3219  ~sdmatrix();
3220  void deallocate();
3221 };
3222 
3223 class dfsdmat;
3224 
3225 uistream & operator>>(const uistream &, const dfsdmat &);
3226 uostream & operator<<(const uostream &, const dfsdmat &);
3227 
3232 class dfsdmat
3233 {
3236  double *ptr;
3237  double **m;
3238  double *minp;
3239  double *maxp;
3241  int n;
3242  public:
3243  int disk_save(void)
3244  {
3245  return disk_save_flag;
3246  }
3247  void save(void);
3248  void restore(void);
3249  double *getminp(void)
3250  {
3251  return minp;
3252  }
3253  int operator!(void) const
3254  {
3255  return (ptr == NULL);
3256  }
3257  int size(void)
3258  {
3259  return n;
3260  }
3261  dfsdmat(int n);
3262  dfsdmat();
3263  dfsdmat(int n, const gradient_structure & gs);
3264  void allocate(int n);
3265  void allocate(int n, const gradient_structure & gs);
3266  void allocate(void);
3267  ~dfsdmat();
3268  void deallocate(void);
3269  friend uistream & operator>>(const uistream &, const dfsdmat &);
3270  friend uostream & operator<<(const uostream &, const dfsdmat &);
3271 
3272  double &elem(int i, int j);
3273  double &operator () (int i, int j);
3274 };
3275 
3276 #if defined(OPT_LIB) && !defined(__INTEL_COMPILER)
3277 inline double& dfsdmat::elem(int i, int j)
3278 {
3279  return *(m[i] + j);
3280 }
3281 inline double& dfsdmat::operator()(int i, int j)
3282 {
3283  return *(m[i] + j);
3284 }
3285 #endif
3286 
3290 class fmm:public fmm_control
3291 {
3292  private:
3296  public:
3297  double dmin, fbest, df;
3298 
3299  long int llog, n1, ic, iconv, i1, xxlink;
3300  double z, zz, gys, gs, sig, gso, alpha, tot, fy, dgs;
3301  long int itn, icc, nn;
3302  int i, j, is, iu, iv, np, ib;
3303  double gmax;
3304  double fsave;
3309 
3310  int n;
3312 
3313  public:
3314  fmm(int nvar, int disk_save = 0);
3315  fmm(int nvar, const lvector & ipar, int disk_save = 0);
3316  double minimize(const independent_variables & x,
3317  double (*pf) (const dvar_vector &));
3318 
3320  double minimize(const independent_variables & x, const dvector & c,
3321  double (*pf) (const dvar_vector &, const dvector &));
3322 
3323  //void fmin(const double& f, const independent_variables &x, const dvector& g);
3324  void fmin(const double &f, const dvector & x, const dvector & g);
3325 
3326  dmatrix & hessian();
3327 };
3328 
3329 class function_minimizer;
3330 
3335 class fmmt1:public fmm_control
3336 {
3337  private:
3340  int xm;
3347  public:
3348  double dmin, fbest, df;
3349 
3350  long int llog, n1, ic, iconv, i1, link;
3351  double z, zz, gys, gs, sig, gso, alpha, tot, fy, dgs;
3352  long int icc, np, nn, iv, ib;
3353  int i, j, iu, is, itn;
3354  double gmax;
3355  double fsave;
3360 
3361  int n;
3362 
3363  public:
3364  fmmt1(int nvar, int _xm = 7);
3365  fmmt1(int nvar, const lvector & ipar);
3366  double minimize(const independent_variables & x,
3367  double (*pf) (const dvar_vector &));
3368 
3369  double minimize(const independent_variables & x, const dvector & c,
3370  double (*pf) (const dvar_vector &, const dvector &));
3371 
3372  void fmin2(const double &f, const independent_variables & x,
3373  const dvector & g, function_minimizer *);
3374 
3375  void fmin(const double &f, const dvector & x, const dvector & g);
3376 
3377 // dmatrix& hessian();
3378 };
3379 
3380 void derch(const double &f, const independent_variables & x,
3381  const dvector & g, int n, const int &ireturn);
3382 
3383 void fmin(double f, const independent_variables & x, const dvector & g,
3384  const int &n, const dvector & w, const dvector & h, const fmm_control & fmc);
3385 
3386 void fmmdisp(const dvector & x, const dvector & g, const int &nvar,
3387  int scroll_flag, int noprintx = 0);
3388 
3389 void fmmdisp(const double *x, const double *g, const int &nvar,
3390  int scroll_flag, int noprintx = 0);
3391 
3392 ostream & operator<<(const ostream & s, const fmm_control & fmc);
3393 
3398 class uostream:public ofstream
3399 {
3400  public:
3401 #if defined(__TURBOC__) && (__BORLANDC__ <= 0x0520)
3402  uostream(const char*, int = ios::out | ios::binary, int = filebuf::openprot);
3403  void open(const char*, int = ios::out | ios::binary, int = filebuf::openprot);
3404 #endif
3405 #if (__BORLANDC__ >= 0x0540)
3406  uostream(const char *, int = ios::out | ios::binary, int protection = 666);
3407  void open(const char *, int = ios::out | ios::binary, int protection = 666);
3408 #endif
3409 #if defined (_MSC_VER) || defined (__WAT32__)
3410  #if (_MSC_VER < 1300)
3411  uostream(const char*, int = ios::out | ios::binary, int = filebuf::openprot);
3412  void open(const char*, int = ios::out | ios::binary, int = filebuf::openprot);
3413  #else
3414  uostream(const char *, int = ios::out | ios::binary, int prot = 0664);
3415  void open(const char *, int = ios::out | ios::binary, int prot = 0664);
3416  #endif
3417 #endif
3418 
3419 #ifdef __ZTC__
3420  uostream(const char *, int = ios::out, int = filebuf::openprot);
3421  void open(const char *, int = ios::out, int = filebuf::openprot);
3422 #endif
3423 
3424 #ifdef __NDPX__
3425  uostream(const char *, int = ios::out, int = filebuf::openprot);
3426  void open(const char *, int = ios::out, int = filebuf::openprot);
3427 #endif
3428 
3429 #ifdef __SUN__
3430  //uostream(const char*, int = ios::out, int = openprot);
3431  //void open(const char*, int = ios::out, int = openprot);
3432 #endif
3433 
3434 #if !defined(_MSC_VER)
3435  #if defined(__ADSGI__)
3436  uostream(const char *name, int mode = ios::out, int prot = 0664);
3437  void open(const char *name, int mode = ios::out, int prot = 0664);
3438  #else
3439  uostream(const char *name, int mode = ios::out | ios::binary,
3440  int prot = 0664);
3441  void open(const char *name, int mode = ios::out | ios::binary,
3442  int prot = 0664);
3443  #endif
3444 #endif
3445 
3446  // insert character
3447 #ifndef __SUN__
3448  uostream & operator<<(signed char);
3449 #endif
3450  uostream & operator<<(unsigned char);
3451 
3452  // insert numeric value
3453  uostream & operator<<(short);
3454  uostream & operator<<(unsigned short);
3455  uostream & operator<<(int);
3456  uostream & operator<<(unsigned int);
3457  uostream & operator<<(long);
3458  uostream & operator<<(unsigned long);
3459  uostream & operator<<(float);
3460  uostream & operator<<(double);
3461  uostream & operator<<(const char *)
3462  {
3463  return *this;
3464  };
3465 #ifdef __TURBOC__
3466  uostream & operator<<(long double);
3467 #endif
3468 
3469  // insert pointer
3470  uostream & operator<<(void *);
3471 };
3472 
3473 
3474  // inline void uostream::open(const char* name, int m, int prot)
3475  // {
3476  // #if defined (__TURBOC__) && (__BORLANDC__ <= 0x0520)
3477  // fstreambase::open(name, m, prot);
3478  // #endif
3479  // #if (__BORLANDC__ >= 0x0540 && __BORLANDC__ <= 0x0550)
3480  // ofstream::open(name, m, prot);
3481  // #else
3482  // # if defined(linux)
3483  // # if (__GNUC__ >= 3)
3484  // ofstream::open(name, std::_Ios_Openmode(m));
3485  // # else
3486  // ofstream::open(name, m);
3487  // # endif
3488  // # else
3489  // ofstream::open(name, m);
3490  // # endif
3491  // #endif
3492  //
3493  // #ifdef _MSC_VER
3494  // # if (_MSC_VER >= 1400)
3495  // ofstream::open(name, m);
3496  // # else
3497  // //fstreambase::open(name, m, prot);
3498  // ofstream::open(name, m, prot);
3499  // # endif
3500  // #endif
3501  // #ifdef __ZTC__
3502  // fstream_common::open(name, m, prot);
3503  // #endif
3504  // #ifdef __NDPX__
3505  // ofstream::open(name, m, prot);
3506  // #endif
3507  // #ifdef __SUN__
3508  // ofstream::open(name, m, prot);
3509  // #endif
3510  // }
3511 
3516 class uistream:public ifstream
3517 {
3518  public:
3519 #if defined (__TURBOC__) && (__BORLANDC__ <= 0x0520)
3520  uistream(const char *, int = ios::in | ios::binary, int = filebuf::openprot);
3521  void open(const char *, int = ios::in | ios::binary, int = filebuf::openprot);
3522 #endif
3523 #if (__BORLANDC__ >= 0x0540)
3524  uistream(const char *, int = ios::in | ios::binary, int protection = 666);
3525  void open(const char *, int = ios::in | ios::binary, int protection = 666);
3526 #endif
3527 #if defined (_MSC_VER) || defined (__WAT32__)
3528  #if (_MSC_VER < 1300)
3529  uistream(const char *, int = ios::in | ios::binary, int = filebuf::openprot);
3530  void open(const char *, int = ios::in | ios::binary, int = filebuf::openprot);
3531  #else
3532  uistream(const char *, int = ios::in | ios::binary, int prot = 0664);
3533  void open(const char *, int = ios::in | ios::binary, int prot = 0664);
3534  #endif
3535 #endif
3536 #ifdef __ZTC__
3537  uistream(const char *, int = ios::in, int = filebuf::openprot);
3538  void open(const char *, int = ios::in, int = filebuf::openprot);
3539 #endif
3540 
3541 #ifdef __NDPX__
3542  uistream(const char *, int = ios::in, int = filebuf::openprot);
3543  void open(const char *, int = ios::in, int = filebuf::openprot);
3544 #endif
3545 
3546 #ifdef __SUN__
3547  // uistream(const char* name, int mode = ios::in, int prot=0664);
3548  // void open(const char* name, int mode = ios::in, int prot=0664);
3549 #endif
3550 
3551 #if !defined(_MSC_VER)
3552  #if defined(__ADSGI__)
3553  uistream(const char *name, int mode = ios::in, int prot = 0664);
3554  void open(const char *name, int mode = ios::in, int prot = 0664);
3555  #else
3556  uistream(const char *name, int mode = ios::in | ios::binary,
3557  int prot = 0664);
3558  void open(const char *name, int mode = ios::in | ios::binary,
3559  int prot = 0664);
3560  #endif
3561 #endif
3562 
3563  // extract characters into an array
3564 #ifndef __SUN__
3565  uistream & get(signed char *, int, char = '\n');
3566 #endif
3567  uistream & get(unsigned char *, int, char = '\n');
3568 
3569  // extract a single character
3570  uistream & get(unsigned char &);
3571 #ifndef __SUN__
3572  uistream & get(signed char &);
3573 #endif
3574  int get();
3575 
3576  // extract and discard chars but stop at delim
3577  uistream & ignore(int = 1, int = EOF);
3578 
3579  uistream& operator>>(int&);
3580 
3581 #ifndef __SUN__
3582  uistream & operator>>(const signed char *);
3583 #endif
3584  uistream & operator>>(const unsigned char *);
3585  uistream & operator>>(const unsigned char &);
3586 #ifndef __SUN__
3587  uistream & operator>>(const signed char &);
3588 #endif
3589  uistream & operator>>(const short &);
3590  uistream & operator>>(const int &);
3591  uistream & operator>>(const long &);
3592  uistream & operator>>(const unsigned short &);
3593  uistream & operator>>(const unsigned int &);
3594  uistream & operator>>(const unsigned long &);
3595  uistream & operator>>(const float &);
3596  uistream & operator>>(const double &);
3597  uistream & operator>>(const char &);
3598 #if defined(__TURBOC__) || defined (_MSC_VER)
3599  uistream & operator>>(const long double &);
3600 #endif
3601 };
3602 
3603  // inline void uistream::open(const char* name, int m, int prot)
3604  // {
3605  // #if defined(__TURBOC__) && (__BORLANDC__ <= 0x0520)
3606  // fstreambase::open(name, m, prot);
3607  // #endif
3608  // #ifdef __ZTC__
3609  // fstream_common::open(name, m, prot);
3610  // #endif
3611  // #ifdef __NDPX__
3612  // ifstream::open(name, m, prot);
3613  // #endif
3614  // #ifdef __SUN__
3615  // ifstream::open(name, m, prot);
3616  // #endif
3617  // }
3618 
3619 class fmmc;
3620 
3621 void derch(const double &f, const dvector & x, const dvector & gg, int n,
3622  const int &ireturn);
3623 
3628 class fmmc
3629 {
3630  public:
3631  int maxfn;
3632  double crit;
3633  double min_improve;
3634  int iprint;
3636  int j;
3637  int J;
3638  long int ifn;
3639  long int iter;
3640  int imax;
3641  long ihang;
3660  int ifnex;
3661  int ireturn;
3663  double gg;
3664  double gam;
3665  double fp;
3666  double dgg;
3667  double rho_min;
3669  double gamma;
3670  double Psi_0;
3671  double extf;
3672  double crit1;
3673  double rho_1;
3674  double Psi_1;
3675  double dir_deriv;
3676  double rho_i;
3681  double rho_0;
3682  double fbest;
3683  fmmc(const int &n);
3684  ~fmmc();
3685  void fmin(const double &f, const dvector & p, const dvector & gg);
3686  double dfn;
3688  long iexit;
3689  long ihflag;
3690 };
3691 
3692 class dd3_array;
3693 
3699 {
3700  //unsigned int nslices;
3701  unsigned int ncopies;
3702  //unsigned int nrows;
3703  //unsigned int ncols;
3706  // int row_min;
3707  // int row_max;
3708  //int col_min;
3709  //int col_max;
3710  three_array_shape(int sl, int sh);
3711  //mat_shape(){};
3712 
3713  friend class i3_array;
3714  friend class d3_array;
3715  friend class dd3_array;
3716  friend class qd3_array;
3717  friend class dvar3_array;
3718 };
3719 
3720 //class dmatrix_ptr { dmatrix *p; };
3721 //class dvar_matrix_ptr { dvar_matrix *p; };
3722 
3728 {
3731  friend class d4_array;
3732  public:
3733  int operator!(void) const
3734  {
3735  return (shape == NULL);
3736  }
3737  // conclass cgors
3738  d3_array(void);
3739  void save_d3_array_value() const;
3740  void shallow_copy(const d3_array &);
3741  d3_array sub(int, int);
3742  d3_array(int sl, int sh, int nrl, int nrh, int ncl, int nch);
3743  d3_array(int sl, int sh, int nrl, int nrh);
3744  d3_array(int sl, int sh, const index_type & nrl, const index_type & nrh);
3745  d3_array(int sl, int sh);
3746  d3_array(const d3_array_position &);
3747 
3748  void save_d3_array_position() const;
3749 
3750  d3_array(int sl, int sh, int nrl, int nrh, const ivector & ncl, int nch);
3751 
3752  d3_array(const ad_integer & sl, const ad_integer & sh,
3753  const index_type & nrl, const index_type & nrh,
3754  const index_type & ncl, const index_type & nch);
3755 
3756  void allocate(const ad_integer & sl, const ad_integer & sh,
3757  const index_type & nrl, const index_type & nrh,
3758  const index_type & ncl, const index_type & nch);
3759 
3760  d3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
3761  const imatrix & ncl, const imatrix & nch);
3762  d3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
3763  int ncl, const imatrix & nch);
3764  d3_array(int sl, int sh, int nrl, const ivector & nrh,
3765  int ncl, const imatrix & nch);
3766  d3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
3767  const ivector & ncl, const ivector & nch);
3768  d3_array(int sl, int sh, int nrl, int nrh, const ivector & ncl,
3769  const ivector & nch);
3770  d3_array(int sl, int sh, int nrl, const ivector & nrh,
3771  int ncl, const ivector & nch);
3772  d3_array(int sl, int sh, int nrl, const ivector & nrh,
3773  int ncl, int nch);
3774  d3_array(const d3_array & m2);
3775  ~d3_array();
3776 
3777  void allocate(const dvar3_array &);
3778  void allocate(const d3_array & d3v);
3779  void allocate(int sl, int sh, int nrl, int nrh, int ncl, int nch);
3780  void allocate(int sl, int sh, int nrl, int nrh);
3781  void allocate(int sl, int sh, const index_type & nrl,
3782  const index_type & nrh);
3783  void allocate(int sl, int sh);
3784 
3785  void allocate(int sl, int sh, int nrl, int nrh, const ivector& ncl, int nch);
3786  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
3787  const imatrix & ncl, const imatrix & nch);
3788  void allocate(int sl, int sh, int nrl, const ivector & nrh, int ncl,
3789  const imatrix & nch);
3790  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
3791  int ncl, const imatrix & nch);
3792  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
3793  int ncl, int nch);
3794  void allocate(int sl, int sh, const ivector& nrl, int nrh, int ncl, int nch);
3795  void allocate(int sl, int sh, int nrl, const ivector& nrh, int ncl, int nch);
3796  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
3797  const ivector & ncl, const ivector & nch);
3798  void allocate(int sl, int sh, int nrl, const ivector & nrh, int ncl,
3799  const ivector & nch);
3800  void allocate(int sl, int sh, int nrl, int nrh, const ivector & ncl,
3801  const ivector & nch);
3802  void allocate(int sl, int sh, int nrl, int nrh, int ncl,
3803  const ivector & nch);
3804  void allocate(void);
3805  void deallocate(void);
3806  void initialize(int sl, int sh, int nrl, const ivector & nrh,
3807  int ncl, const ivector & nch);
3808 
3809  dmatrix* begin() const
3810  {
3811  return t ? &t[slicemin()] : nullptr;
3812  }
3813  dmatrix* end() const
3814  {
3815  return t ? begin() + slicesize() : nullptr;
3816  }
3817  //access functions
3818  int indexmin() const
3819  {
3820  return slicemin();
3821  }
3822  int indexmax() const
3823  {
3824  return slicemax();
3825  }
3826  int slicemin() const
3827  {
3828  return shape ? shape->slice_min : 1;
3829  }
3830  int slicemax() const
3831  {
3832  return shape ? shape->slice_max : 0;
3833  }
3834 
3835  int colmin(void) const
3836  {
3837  return ((*this) (slicemin()).colmin());
3838  }
3839  int colmax(void) const
3840  {
3841  return ((*this) (slicemin()).colmax());
3842  }
3843  int rowmin(void) const
3844  {
3845  return ((*this) (slicemin()).rowmin());
3846  }
3847  int rowmax(void) const
3848  {
3849  return ((*this) (slicemin()).rowmax());
3850  }
3851 
3852  // returns the number of rows
3853  unsigned int slicesize() const
3854  {
3855  return static_cast<unsigned int>(slicemax() - slicemin() + 1);
3856  }
3857 
3858  // returns the number of rows
3859  int rowsize(void) const
3860  {
3861  return (rowmax() - rowmin() + 1);
3862  }
3863  // returns the number of columns
3864  int colsize(void) const
3865  {
3866  return (colmax() - colmin() + 1);
3867  }
3868  void initialize(void);
3869 
3870  dmatrix & elem(int k)
3871  {
3872  return (t[k]);
3873  }
3874  const dmatrix & elem(int k) const
3875  {
3876  return t[k];
3877  }
3878  double &operator () (int k, int i, int j);
3879  dvector & operator ()(int k, int i);
3880  dmatrix & operator[](int i);
3881  dmatrix & operator()(int i);
3882  const double &operator() (int k, int i, int j) const;
3883  const dvector & operator() (int k, int i) const;
3884  const dmatrix & operator[] (int i) const;
3885  const dmatrix & operator() (int i) const;
3886 
3887  d3_array & operator=(const d3_array & m1);
3888  d3_array & operator=(double x);
3889  friend d3_array value(const dvar3_array & ar);
3890 
3891  void fill_randn(const random_number_generator & rng);
3892  void fill_randcau(const random_number_generator & rng);
3893  void fill_randu(const random_number_generator & rng);
3894 
3895  void fill_randu(long int &n);
3896  void fill_randn(long int &n);
3897 
3898  void fill_randu_ni(long int &n);
3899  void fill_randn_ni(long int &n);
3900  double fill_seqadd(double, double);
3901  void operator /=(double d);
3902 
3903  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
3904 };
3905 #ifdef OPT_LIB
3906 inline const double& d3_array::operator()(int k, int i, int j) const
3907 {
3908  return ((t[k].m[i]).v)[j];
3909 }
3910 inline const dvector& d3_array::operator()(int k, int i) const
3911 {
3912  return t[k].m[i];
3913 }
3914 inline const dmatrix& d3_array::operator()(int i) const
3915 {
3916  return t[i];
3917 }
3918 inline const dmatrix& d3_array::operator[](int i) const
3919 {
3920  return t[i];
3921 }
3922 inline double& d3_array::operator()(int k, int i, int j)
3923 {
3924  return ((t[k].m[i]).v)[j];
3925 }
3926 inline dvector& d3_array::operator()(int k, int i)
3927 {
3928  return t[k].m[i];
3929 }
3931 {
3932  return t[i];
3933 }
3935 {
3936  return t[i];
3937 }
3938 #endif
3939 
3945 {
3948  public:
3949 # if defined(MFCL2_CONSTRUCTORS)
3950  i3_array(int sl, int sh, int nrl, int nrh, const ivector & nc);
3951  void allocate(int sl, int sh, int nrl, int nrh, const ivector & nc);
3952 # endif
3953  int operator!(void) const
3954  {
3955  return (shape == NULL);
3956  }
3957  // conclass cgors
3958  void shallow_copy(const i3_array &);
3959  i3_array(void);
3960  i3_array(int sl, int sh, const index_type & nrl, const index_type & nrh,
3961  const index_type & ncl, const index_type & nch);
3962 
3963  i3_array(int _sl, int _sh, const imatrix & m1);
3964 
3965  i3_array(int sl, int sh);
3966  i3_array(int sl, int sh, int nrl, int nrh, int ncl, int nch);
3967  i3_array(int sl, int sh, int nrl, int nrh, const ivector & ncl, int nch);
3968 
3969  i3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
3970  const imatrix & ncl, const imatrix & nch);
3971  i3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
3972  int ncl, const imatrix & nch);
3973  i3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
3974  const ivector & ncl, const ivector & nch);
3975  i3_array(int sl, int sh, int nrl, int nrh, const ivector & ncl,
3976  const ivector & nch);
3977  i3_array(int sl, int sh, int nrl, const ivector & nrh, int ncl,
3978  const ivector & nch);
3979  i3_array(int sl, int sh, int nrl, const ivector & nrh, int ncl, int nch);
3980  i3_array(int sl, int sh, int nrl, const ivector & nrh, int ncl,
3981  const imatrix & nch);
3982  i3_array(const i3_array & m2);
3983  ~i3_array();
3984 
3985  void allocate(int sl, int sh, int nrl, const ivector& nrh, int ncl, int nch);
3986  void allocate(const dvar3_array &);
3987  void allocate(const i3_array & i3v);
3988  void allocate(int sl, int sh, int nrl, int nrh, int ncl, int nch);
3989  void allocate(int sl, int sh);
3990 
3991  void allocate(int sl, int sh, int nrl, int nrh, const ivector& ncl, int nch);
3992 
3993  void allocate(int sl, int sh, const index_type& nrl, const index_type& nrh,
3994  const index_type & ncl, const index_type & nch);
3995 
3996  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
3997  const imatrix & ncl, const imatrix & nch);
3998  void allocate(int sl, int sh, int nrl, const ivector & nrh, int ncl,
3999  const imatrix & nch);
4000  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
4001  int ncl, const imatrix & nch);
4002  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
4003  int ncl, int nch);
4004  void allocate(int sl, int sh, const ivector & nrl, int nrh,
4005  int ncl, int nch);
4006  //void allocate(int sl, int sh, int nrl, const ivector& nrh,
4007  // int ncl,int nch);
4008  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
4009  const ivector & ncl, const ivector & nch);
4010  void allocate(int sl, int sh, int nrl, const ivector & nrh,
4011  int ncl, const ivector & nch);
4012  void allocate(int sl, int sh, int nrl, int nrh, const ivector & ncl,
4013  const ivector & nch);
4014  void allocate(int sl, int sh, int nrl, int nrh, int ncl, const ivector& nch);
4015  void allocate(void);
4016  void deallocate(void);
4017  void initialize(int sl, int sh, int nrl, const ivector & nrh, int ncl,
4018  const ivector & nch);
4019 
4020  //access functions
4021  int indexmin() const
4022  {
4023  return slicemin();
4024  }
4025  int indexmax() const
4026  {
4027  return slicemax();
4028  }
4029  int slicemin() const
4030  {
4031  return shape ? shape->slice_min : 1;
4032  }
4033  int slicemax() const
4034  {
4035  return shape ? shape->slice_max : 0;
4036  }
4037  int colmin(void) const
4038  {
4039  return ((*this) (slicemin()).colmin());
4040  }
4041  int colmax(void) const
4042  {
4043  return ((*this) (slicemin()).colmax());
4044  }
4045  int rowmin(void) const
4046  {
4047  return ((*this) (slicemin()).rowmin());
4048  }
4049  int rowmax(void) const
4050  {
4051  return ((*this) (slicemin()).rowmax());
4052  }
4053  // returns the number of rows
4054  unsigned int slicesize() const
4055  {
4056  return static_cast<unsigned int>(slicemax() - slicemin() + 1);
4057  }
4058  // returns the number of rows
4059  int rowsize() const
4060  {
4061  return (rowmax() - rowmin() + 1);
4062  }
4063  // returns the number of columns
4064  int colsize() const
4065  {
4066  return (colmax() - colmin() + 1);
4067  }
4068  void initialize();
4069 
4070  imatrix& elem(int i);
4071  const imatrix& elem(int i) const;
4072  int& operator()(int i, int j, int k);
4073  ivector& operator()(int i, int j);
4074  imatrix& operator[](int i);
4075  imatrix& operator()(int i);
4076  const int& operator()(int i, int j, int k) const;
4077  const ivector& operator()(int i, int j) const;
4078  const imatrix& operator[](int i) const;
4079  const imatrix& operator()(int i) const;
4080 
4081  i3_array& operator=(const i3_array& other);
4082  i3_array& operator=(int value);
4083 
4084  void fill_randu(long int &n);
4085  void fill_randn(long int &n);
4086  void fill_randu_ni(long int &n);
4087  void fill_randn_ni(long int &n);
4088 
4089  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
4090 };
4091 inline imatrix& i3_array::elem(int i)
4092 {
4093  if (i < slicemin())
4094  {
4095  cerr << "matrix bound exceeded -- row index too low in"
4096  << "ivector& i3_array::elem(int).\n";
4097  ad_exit(1);
4098  }
4099  if (i > slicemax())
4100  {
4101  cerr << "matrix bound exceeded -- row index too high in"
4102  << "ivector& i3_array::elem(int).\n";
4103  ad_exit(1);
4104  }
4105  return t[i];
4106 }
4107 inline const imatrix& i3_array::elem(int i) const
4108 {
4109  if (i < slicemin())
4110  {
4111  cerr << "matrix bound exceeded -- row index too low in"
4112  << "ivector& i3_array::elem(int).\n";
4113  ad_exit(1);
4114  }
4115  if (i > slicemax())
4116  {
4117  cerr << "matrix bound exceeded -- row index too high in"
4118  << "ivector& i3_array::elem(int).\n";
4119  ad_exit(1);
4120  }
4121  return t[i];
4122 }
4124 {
4125 #ifdef OPT_LIB
4126  return t[i];
4127 #else
4128  return elem(i);
4129 #endif
4130 }
4132 {
4133 #ifdef OPT_LIB
4134  return t[i];
4135 #else
4136  return elem(i);
4137 #endif
4138 }
4139 inline ivector& i3_array::operator()(int i, int j)
4140 {
4141 #ifdef OPT_LIB
4142  return t[i].m[j];
4143 #else
4144  return elem(i)(j);
4145 #endif
4146 }
4147 inline int& i3_array::operator()(int i, int j, int k)
4148 {
4149 #ifdef OPT_LIB
4150  return ((t[i].m[j]).v)[k];
4151 #else
4152  return elem(i)(j, k);
4153 #endif
4154 }
4155 inline const imatrix& i3_array::operator[](int i) const
4156 {
4157 #ifdef OPT_LIB
4158  return t[i];
4159 #else
4160  return elem(i);
4161 #endif
4162 }
4163 inline const imatrix& i3_array::operator()(int i) const
4164 {
4165 #ifdef OPT_LIB
4166  return t[i];
4167 #else
4168  return elem(i);
4169 #endif
4170 }
4171 inline const ivector& i3_array::operator()(int i, int j) const
4172 {
4173 #ifdef OPT_LIB
4174  return t[i].m[j];
4175 #else
4176  return elem(i)(j);
4177 #endif
4178 }
4179 inline const int& i3_array::operator()(int i, int j, int k) const
4180 {
4181 #ifdef OPT_LIB
4182  return ((t[i].m[j]).v)[k];
4183 #else
4184  return elem(i)(j, k);
4185 #endif
4186 }
4187 
4188 # if defined(__NUMBERVECTOR__)
4191 # endif
4192 
4198 {
4201 
4202 public:
4203  void shallow_copy(const dvar3_array &);
4204  dvar3_array sub(int, int);
4205  dvar3_array(int, int);
4206  int operator!(void) const
4207  {
4208  return (shape == NULL);
4209  }
4210  // conclass cgors
4211 
4212  void initialize(void);
4213  void allocate(int sl, int sh, int nrl, int nrh, int ncl, int nch);
4214  void allocate(int sl, int sh, int nrl, int nrh);
4215  void allocate(int sl, int sh, const index_type& nrl, const index_type& nrh);
4216  void allocate(int sl, int sh);
4217 
4218  void allocate(int sl, int sh, int nrl, int nrh, const ivector& ncl, int nch);
4219  void allocate(const d3_array & m1);
4220  void allocate(void);
4221  void allocate(const dvar3_array & m1);
4222  void allocate(int sl, int sh, int nrl, int nrh,
4223  const ivector & ncl, const ivector & nch);
4224  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
4225  const ivector & ncl, const ivector & nch);
4226  void allocate(int sl, int sh, const ivector & nrl, const ivector & nrh,
4227  int ncl, int nch);
4228  void allocate(int sl, int sh, const ivector & nrl, int nrh,
4229  int ncl, int nch);
4230  void allocate(int sl, int sh, int nrl, const ivector & nrh,
4231  int ncl, int nch);
4232  void allocate(int sl, int sh, int nrl, const ivector & nrh,
4233  int ncl, const ivector & nch);
4234  void allocate(int sl, int sh, int nrl, int nrh,
4235  int ncl, const ivector & nch);
4236  void allocate(ad_integer sl, ad_integer sh, const index_type & nrl,
4237  const index_type & nrh, const index_type & ncl, const index_type & nch);
4238  void allocate(ad_integer sl, ad_integer sh, const index_type & nrl,
4239  const index_type & nrh);
4240  void allocate(ad_integer sl, ad_integer sh);
4241 
4242  void deallocate();
4243  dvar3_array(int sl, int sh, int nrl, int nrh, int ncl, int nch);
4244  dvar3_array(int sl, int sh, int nrl, int nrh, const ivector & ncl, int nch);
4245 
4246  dvar3_array(int sl, int sh, const ivector & nrl, const ivector & nrh,
4247  ivector & ncl, const ivector & nch);
4248 
4249  dvar3_array(int sl, int sh, int nrl, const ivector & nrh, int ncl,
4250  const ivector & nch);
4251 
4252  dvar3_array(int sl, int sh, int nrl, const ivector & nrh, int ncl, int nch);
4253 
4254  dvar3_array(ad_integer sl, ad_integer sh, const index_type & nrl,
4255  const index_type & nrh, const index_type & ncl, const index_type & nch);
4256 
4257  dvar3_array(const d3_array & m2);
4258 # if defined(__NUMBERVECTOR__)
4261 # endif
4262 
4263  dvar3_array(const dvar3_array & m2);
4264 
4265  dvar3_array(void);
4266 
4267  ~dvar3_array();
4268 
4269  d3_array value(const dvar3_array &);
4270 
4271  //access functions
4272  int indexmin() const { return slicemin(); }
4273  int indexmax() const { return slicemax(); }
4274  int slicemin() const { return shape ? shape->slice_min : 1; }
4275  int slicemax() const { return shape ? shape->slice_max : 0; }
4276  // returns the number of rows
4277  unsigned int slicesize() const
4278  {
4279  //assert(slicemin() <= slicemax());
4280  return static_cast<unsigned int>(slicemax() - slicemin() + 1);
4281  }
4282 
4283  int colmin() const
4284  {
4285  return ((*this) (slicemin()).colmin());
4286  }
4287  int colmax(void) const
4288  {
4289  return ((*this) (slicemin()).colmax());
4290  }
4291  int rowmin(void) const
4292  {
4293  return ((*this) (slicemin()).rowmin());
4294  }
4295  int rowmax(void) const
4296  {
4297  return ((*this) (slicemin()).rowmax());
4298  }
4299  // returns the number of rows
4300  int rowsize() const
4301  {
4302  return (rowmax() - rowmin() + 1);
4303  }
4304  // returns the number of columns
4305  int colsize() const
4306  {
4307  return (colmax() - colmin() + 1);
4308  }
4315  dvar_matrix& elem(int i) { return t[i]; }
4324  prevariable elem(int i, int j, int k) { return t[i].elem(j, k); }
4331  const dvar_matrix& elem(int i) const { return t[i]; }
4340  const prevariable elem(int i, int j, int k) const { return t[i].elem(j, k); }
4341 
4342 #ifdef OPT_LIB
4343  inline const prevariable operator() (int k, int i, int j) const
4344  {
4345  return (((t[k].m[i]).va) + j);
4346  }
4347 
4348  inline const dvar_vector & operator() (int k, int i) const
4349  {
4350  return (t[k].m[i]);
4351  }
4352 
4353  inline const dvar_matrix & operator() (int i) const
4354  {
4355  return (t[i]);
4356  }
4357 
4358  inline const dvar_matrix & operator[] (int i) const
4359  {
4360  return (t[i]);
4361  }
4362 
4363  inline prevariable operator () (int k, int i, int j)
4364  {
4365  return (((t[k].m[i]).va) + j);
4366  }
4367 
4368  inline dvar_vector & operator () (int k, int i)
4369  {
4370  return (t[k].m[i]);
4371  }
4372 
4373  inline dvar_matrix & operator() (int i)
4374  {
4375  return (t[i]);
4376  }
4377 
4378  inline dvar_matrix & operator[] (int i)
4379  {
4380  return (t[i]);
4381  }
4382 #else
4383  prevariable operator () (int k, int i, int j);
4384  dvar_vector & operator ()(int k, int i);
4385  dvar_matrix & operator[](int i);
4386  dvar_matrix & operator()(int i);
4387  const prevariable operator() (int k, int i, int j) const;
4388  const dvar_vector & operator() (int k, int i) const;
4389  const dvar_matrix & operator[] (int i) const;
4390  const dvar_matrix & operator() (int i) const;
4391 #endif
4392 
4393  dvar3_array & operator=(const d3_array & m1);
4394  dvar3_array & operator=(double x);
4395  dvar3_array & operator=(const dvar3_array & m1);
4396 
4397  void fill_randu(long int &n);
4398  void fill_randn(long int &n);
4399 
4400  void fill_randu_ni(long int &n);
4401  void fill_randn_ni(long int &n);
4402  double fill_seqadd(double, double);
4403  void operator/=(const prevariable &);
4404  void operator /=(double);
4405 
4406  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
4407 };
4408 
4411 
4412 double inv_cumd_exponential(double y);
4413 double cumd_exponential(double x);
4414 
4415 double cumd_logistic(const double &x);
4416 double inv_cumd_logistic(const double &x);
4417 
4420 double inv_cumd_norm(const double &x);
4421 double cumd_norm(const double &x);
4422 double cumd_norm(const double &x, double);
4425 prevariable & cumd_norm(const prevariable & x);
4426 prevariable & bounded_cumd_norm(const prevariable & x, double);
4427 double bounded_cumd_norm(double x, double);
4428 //dvariable& old_cumd_norm(const prevariable& x);
4429 double normal_tail_right(const double &x);
4430 
4431 dvariable inv_cumd_norm_logistic(const prevariable & x, double);
4432 prevariable & cumd_norm_logistic(const prevariable & x, double);
4433 double inv_cumd_norm_logistic(double x, double);
4434 double cumd_norm_logistic(double x, double);
4435 
4441 {
4443  public:
4445  {
4446  v = x.get_v();
4447  }
4449  {
4450  v = p;
4451  }
4452  double &xval()
4453  {
4454  return ((v->x));
4455  }
4456 };
4457 
4460 void save_double_derivative(double x, const prevariable_position & pos);
4461 double restore_prevariable_value(void);
4462 void save_double_value(double x);
4463 int sum(const imatrix &);
4464 double sum(const dmatrix &);
4465 double sum(const d3_array &);
4466 double sum(const d4_array &);
4467 double sum(const d5_array &);
4468 double sum(const d6_array &);
4469 double sum(const d7_array &);
4470 dvariable sum(const dvar_matrix &);
4471 dvariable sum(const dvar3_array &);
4472 dvariable sum(const dvar4_array &);
4473 dvariable sum(const dvar5_array &);
4474 dvariable sum(const dvar6_array &);
4475 dvariable sum(const dvar7_array &);
4476 
4477 dmatrix fabs(const dmatrix & m);
4478 //double& value(const double& u);
4479  //const double& value(const double& u);
4480 double norm(const d3_array &);
4481 double norm2(const d3_array &);
4482 double sumsq(const d3_array &);
4483 d3_array exp(const d3_array & m);
4484 d3_array mfexp(const d3_array & m);
4485 d3_array mfexp(const d3_array & m, double d);
4486 d3_array log(const d3_array & m);
4487 d3_array fabs(const d3_array & m);
4488 d3_array sin(const d3_array & m);
4489 d3_array cos(const d3_array & m);
4490 d3_array tan(const d3_array & m);
4491 d3_array sqrt(const d3_array & m);
4492 d3_array sqr(const d3_array & m);
4493 d3_array elem_prod(const d3_array & m1, const d3_array & m2);
4494 d3_array elem_div(const d3_array & m1, const d3_array & m2);
4495 d3_array operator+(const d3_array & m1, const d3_array & m2);
4496 d3_array operator+(const d3_array & m1, double m2);
4497 d3_array operator/(const d3_array & m1, double m2);
4498 d3_array operator/(double m2, const d3_array & m1);
4499 d3_array operator+(double m1, const d3_array & m2);
4500 d3_array operator-(const d3_array & m1, const d3_array & m2);
4501 d3_array operator-(const d3_array & m1, double m2);
4502 d3_array operator-(double m1, const d3_array & m2);
4503 d3_array operator*(const d3_array & m1, const d3_array & m2);
4504 dmatrix operator *(const d3_array & m1, const dvector & m2);
4505 d3_array operator*(const d3_array & m1, double m2);
4506 d3_array operator*(double m1, const d3_array & m2);
4507 
4508 dvariable norm(const dvar3_array & m);
4509 dvariable norm2(const dvar3_array & m);
4510 dvariable sumsq(const dvar3_array & m);
4511 dvar3_array exp(const dvar3_array & m);
4512 dvar3_array mfexp(const dvar3_array & m);
4513 dvar3_array mfexp(const dvar3_array & m, double d);
4514 dvar3_array log(const dvar3_array & m);
4515 dvar3_array fabs(const dvar3_array & m);
4516 dvar3_array sin(const dvar3_array & m);
4517 dvar3_array cos(const dvar3_array & m);
4518 dvar3_array tan(const dvar3_array & m);
4519 dvar3_array sqrt(const dvar3_array & m);
4520 dvar3_array sqr(const dvar3_array & m);
4521 dvar3_array elem_prod(const dvar3_array & m1, const dvar3_array & m2);
4522 dvar3_array elem_div(const dvar3_array & m1, const dvar3_array & m2);
4523 dvar3_array operator+(const dvar3_array & m1, const dvar3_array & m2);
4524 dvar3_array operator-(const dvar3_array & m1, const dvar3_array & m2);
4525 dvar3_array elem_prod(const d3_array & m1, const dvar3_array & m2);
4526 dvar3_array elem_div(const d3_array & m1, const dvar3_array & m2);
4527 dvar3_array operator+(const d3_array & m1, const dvar3_array & m2);
4528 dvar3_array operator-(const d3_array & m1, const dvar3_array & m2);
4529 dvar3_array elem_prod(const dvar3_array & m1, const d3_array & m2);
4530 dvar3_array elem_div(const dvar3_array & m1, const d3_array & m2);
4531 dvar3_array operator+(const dvar3_array & m1, const d3_array & m2);
4532 dvar3_array operator+(const dvar3_array & m1, const dvariable & m2);
4533 dvar3_array operator+(const dvariable & d1, const dvar3_array & m1);
4534 
4535 dvar3_array operator/(const prevariable & m2, const dvar3_array & m1);
4536 dvar3_array operator/(const prevariable & m2, const d3_array & m1);
4537 dvar3_array operator/(double m2, const dvar3_array & m1);
4538 
4539 dvar3_array operator/(const dvar3_array & m1, const prevariable & m2);
4540 dvar3_array operator/(const d3_array & m1, const prevariable & m2);
4541 dvar3_array operator/(const dvar3_array & m1, double m2);
4542 
4543 dvar3_array operator+(const dvariable & m1, const d3_array & m2);
4544 dvar3_array operator+(double m1, const dvar3_array & m2);
4545 dvar3_array operator-(const dvar3_array & m1, const d3_array & m2);
4546 dvar3_array operator-(const dvar3_array & m1, const dvariable & m2);
4547 dvar3_array operator-(const dvariable & m1, const d3_array & m2);
4548 dvar3_array operator-(const dvariable & m1, const dvar3_array & m2);
4549 dvar3_array operator-(double m1, const dvar3_array & m2);
4550 dvar3_array operator*(const dvar3_array & m1, const d3_array & m2);
4551 dvar3_array operator*(const dvar3_array & m1, const dvariable & m2);
4552 dvar3_array operator*(const dvariable & m1, const d3_array & m2);
4553 dvar3_array operator*(const dvariable & m1, const dvar3_array & m2);
4554 dvar3_array operator*(double m1, const dvar3_array & m2);
4555 
4556 ivector square(const ivector& x);
4557 
4558 double square(double x);
4559 dvector square(const dvector & x);
4560 dmatrix square(const dmatrix & x);
4561 d3_array square(const d3_array & x);
4562 
4563 dvariable & square(const prevariable & x);
4564 dvar_vector square(const dvar_vector & x);
4565 dvar_matrix square(const dvar_matrix & x);
4566 dvar3_array square(const dvar3_array & x);
4567 
4568 double cube(double x);
4569 double fourth(double x);
4570 dvector cube(const dvector & x);
4571 dmatrix cube(const dmatrix & x);
4572 d3_array cube(const d3_array & x);
4573 
4574 d3_array pow(const d3_array & x, int e);
4575 dvar3_array pow(const dvar3_array & x, int e);
4576 
4577 prevariable & cube(const prevariable & x);
4578 dvar_vector cube(const dvar_vector & x);
4579 dvar_matrix cube(const dvar_matrix & x);
4580 dvar3_array cube(const dvar3_array & x);
4581 
4582 void set_value(const dvar_matrix & x, const dvar_vector & v, const int &_ii,
4583  double s);
4584 void set_value(const dvar_matrix & x, const dvar_vector & v, const int &ii,
4585  double fmin, double fmax, const dvariable & fpen, double s);
4586 void set_value_inv(const dvar_matrix & x, const dvector & v, const int &ii,
4587  double s);
4588 void set_value_inv(const dvar_matrix & x, const dvector & v, const int &ii,
4589  double fmin, double fmax, double s);
4590 void set_value(const dvar_vector & x, const dvar_vector & v, const int &_ii,
4591  double s);
4592 void set_value(const dvar_vector & _x, const dvar_vector & v, const int &_ii,
4593  double fmin, double fmax, const dvariable & fpen, double s);
4594 void set_value_inv(const dvar_vector & x, const dvector & _v, const int &_ii,
4595  double s);
4596 void set_value_inv(const dvar_vector & x, const dvector & _v, const int &_ii,
4597  double fmin, double fmax, double s);
4598 void set_value_inv(const dvar_matrix & x, const dvector & v, const int &ii);
4599 void set_value_inv(const prevariable & x, const dvector & v, const int &ii,
4600  double s);
4601 void set_value_inv(const prevariable & x, const dvector & v, const int &ii);
4602 void set_value_inv(const dvar_matrix & x, const dvector & v, const int &ii);
4603 void set_value_inv(const dvar_matrix & u, const dvector & x, const int &ii,
4604  double fmin, double fmax);
4605 void set_value_inv(const dvar3_array & u, const dvector & x, const int &ii,
4606  double fmin, double fmax);
4607 void set_value_inv(const dvar3_array & u, const dvector & x, const int &ii);
4608 
4609 void set_value_inv(double x, const dvector & v, const int &ii);
4610 
4611 void set_value_inv_exp(const prevariable & x, const dvector & _v,
4612  const int &_ii, double fmin, double fmax, double s);
4613 
4614 void set_value_inv(const prevariable & x, const dvector & _v, const int &_ii,
4615  double fmin, double fmax, double s);
4616 
4617 void set_value_inv(const prevariable & u, const dvector & x, const int &ii,
4618  double fmin, double fmax);
4619 void set_value_inv(double u, const dvector & x, const int &ii, double fmin,
4620  double fmax);
4621 void set_value_inv(const dvector & x, const dvector & v, const int &ii);
4622 void set_value_inv(const dvar_vector & x, const dvector & v, const int &ii);
4623 void set_value_inv(const dvar_vector & x, const dvector & v, const int &ii,
4624  double fmin, double fmax);
4625 void set_value_inv(const dvector & x, const dvector & v, const int &ii,
4626  double fmin, double fmax);
4627 void set_value_inv(const dmatrix & x, const dvector & v, const int &ii);
4628 void set_value_inv(const dmatrix & x, const dvector & v, const int &ii,
4629  double fmin, double fmax);
4630 void set_value_inv(const d3_array & x, const dvector & v, const int &ii);
4631 void set_value_inv(const d3_array & x, const dvector & v, const int &ii,
4632  double fmin, double fmax);
4633 void set_value(const prevariable & x, const dvar_vector & v, const int &ii);
4634 void set_value(const prevariable & x, const dvar_vector & v, const int &ii,
4635  double s);
4636 void set_value(const dvar_vector & x, const dvar_vector & v, const int &ii);
4637 
4638 void set_value_exp(const prevariable & _x, const dvar_vector & v,
4639  const int &_ii, double fmin, double fmax, const dvariable & fpen, double s);
4640 void set_value(const prevariable & _x, const dvar_vector & v, const int &_ii,
4641  double fmin, double fmax, const dvariable & fpen, double s);
4642 
4643 void set_value(const prevariable & x, const dvar_vector & v, const int &ii,
4644  double fmin, double fmax, const dvariable & fpen);
4645 void set_value(const dvar_vector & x, const dvar_vector & v, const int &ii,
4646  double fmin, double fmax, const dvariable & fpen);
4647 void set_value(const dvar_matrix & x, const dvar_vector & v,
4648  const int &ii);
4649 void set_value(const dvar_matrix & x, const dvar_vector & v, const int &ii,
4650  double fmin, double fmax, const dvariable & fpen);
4651 void set_value(dvar3_array & x, const dvar_vector & v, const int &ii);
4652 void set_value(dvar3_array & x, const dvar_vector & v, const int &ii,
4653  double fmin, double fmax, const dvariable & fpen);
4654 
4655 void set_value_inv_partial(const dvector & x, const dvector & v, const int &ii,
4656  int n);
4657 void set_value_inv_partial(const dvector & x, const dvector & v, const int &ii,
4658  int n, double fmin, double fmax);
4659 void set_value_inv_partial(const dmatrix & x, const dvector & v, const int &ii,
4660  int n);
4661 void set_value_inv_partial(const dvar_matrix & x, const dvector & v,
4662  const int &ii, int n);
4663 void set_value_inv_partial(const d3_array & x, const dvector& v, const int &ii,
4664  int n);
4665 
4666 void set_value_inv_partial(const dvar_vector & x, const dvector & v,
4667  const int &ii, int n);
4668 void set_value_inv_partial(const dvar_vector & x, const dvector & v,
4669  const int &ii, int n, double fmin, double fmax);
4670 
4671 void set_value_partial(const dvar_vector & x, const dvar_vector & v,
4672  const int &ii, int n);
4673 void set_value_partial(const dvar_vector & x, const dvar_vector & v,
4674  const int &ii, int n, double fmin, double fmax, const dvariable & fpen);
4675 void set_value_partial(const dvar_matrix & x, const dvar_vector & v,
4676  const int &ii, int n);
4677 void set_value_partial(dvar3_array & x, const dvar_vector & v, const int &ii,
4678  int n);
4679 
4680 unsigned int size_count(const dvar_vector& x);
4681 unsigned int size_count(const dvar_matrix& x);
4682 unsigned int size_count(const dvar3_array& x);
4683 unsigned int size_count(const dvar4_array& x);
4684 unsigned int size_count(const dvector& x);
4685 unsigned int size_count(const dmatrix& x);
4686 unsigned int size_count(const d3_array& x);
4687 unsigned int size_count(const d4_array& x);
4688 
4689 int size_count_partial(const dvar_vector & x, int);
4690 int size_count_partial(const dvar_matrix & x, int);
4691 int size_count_partial(const dvar3_array & x, int);
4692 int size_count_partial(const dvector & x, int);
4693 int size_count_partial(const dmatrix & x, int);
4694 int size_count_partial(const d3_array & x, int);
4695 
4696 int min(int, int);
4697 // ********************************************************
4698 // Prototypes for compiled derivative calculations
4699 void dfinvpret(void);
4700 void dvdv_dot(void);
4701 void dmdm_prod(void);
4702 void dv_init(void);
4703 
4704 
4705 // ********************************************************
4706 int save_identifier_string(const char *);
4707 void insert_identifier_string(const char *s);
4708 void verify_identifier_string(const char *);
4709 
4710 
4715  const int &ii);
4717  const int &ii);
4721 double restore_double_value(void);
4722 int restore_int_value(void);
4723 void save_double_value(double x);
4724 void save_int_value(int x);
4725 void save_pointer_value(void *ptr);
4726 void *restore_pointer_value(void);
4729 dvariable nograd_assign(double tmp);
4737  const int &ii);
4740 void save_dmatrix_derivatives(const dvar_matrix_position & pos, double x,
4741  const int &i, int &j);
4746 void nograd_assign_row(const dvar_matrix & m, const dvector & v,
4747  const int &ii);
4748 void nograd_assign_column(const dvar_matrix & m, const dvector & v,
4749  const int &ii);
4750 
4751 long int reset_gs_stack(void);
4752 void reset_gs_stack(long int);
4753 
4754 dvar_vector solve(const dvar_matrix & aa, const dvar_vector & z);
4755 dvar_vector solve(const dvar_matrix & aa, const dvar_vector & z,
4756  prevariable & ln_unsigned_det, const prevariable & sign);
4757 
4758 //dvar_vector solve(const dvar_matrix& aa, const dvar_vector& z,
4759  // prevariable& ln_unsigned_det, const prevariable& sign);
4760 
4761 dvector csolve(const dmatrix & aa, const dvector & z);
4762 dvector solve(const dmatrix & aa, const dvector & z);
4763 dvector solve(const dmatrix & aa, const dvector & z,
4764  const double &ln_unsigned_det, double &sign);
4765 
4766 dmatrix choleski_decomp(const dmatrix & M);
4767 dmatrix choleski_decomp_error(const dmatrix & M, int &ierror);
4768 dmatrix choleski_decomp_neghess_error(const dmatrix & M, int &ierror);
4769 dmatrix choleski_decomp_positive(const dmatrix & MM, const int &ierr);
4770 dmatrix choleski_decomp_positive(const dmatrix & MM, double bound);
4772 
4773 dvar_matrix solve(const dvar_matrix & aa, const dvar_matrix & zz);
4774 dmatrix expm(const dmatrix & A);
4775 dvar_matrix expm(const dvar_matrix & A);
4776 
4777 dvariable factln(const dvariable & n);
4778 double factln(double n);
4779 dvar_vector factln(const dvar_vector & n);
4780 dvector factln(const dvector & n);
4781 
4783 
4784 
4785 dvar_vector posfun(const dvar_vector & x, double eps, const prevariable & pen);
4786 dvariable posfun(const dvariable& x, const double eps, const prevariable & pen);
4787 dvariable posfun2(const dvariable& x, const double eps, const prevariable& pen);
4788 double posfun(const double &x, const double eps, const double &_pen);
4789 double posfun2(const double &x, const double eps, const double &_pen);
4790 double dfposfun(const double &x, const double eps);
4791 dvariable dfposfun(const prevariable & x, const double eps);
4792 double dfposfun1(const double &x, const double eps);
4793 dvar_vector log_comb(const dvar_vector & n, const dvector & k);
4794 dvariable log_comb(double n, const dvariable & k);
4795 dvar_vector log_comb(const dvar_vector & n, const dvar_vector & k);
4796 dvar_vector log_comb(const dvector & n, const dvar_vector & k);
4797 dvar_vector log_comb(double n, const dvar_vector & k);
4798 dvar_vector log_comb(const dvariable & n, const dvector & k);
4799 dvar_vector log_comb(const dvariable & n, const dvar_vector & k);
4800 dvariable log_comb(const dvariable & n, double k);
4801 dvariable log_comb(const dvariable & n, const dvariable & k);
4802 dvector log_comb(const dvector & n, const dvector & k);
4803 dvector log_comb(double n, const dvector & k);
4804 double log_comb(double n, double k);
4805 dmatrix orthpoly(int n, int deg);
4806 dmatrix orthpoly(int n, int deg, int skip);
4807 dvar_vector gammln(const dvar_vector & n);
4808 dvector gammln(const dvector & n);
4809 
4815 {
4816 public:
4820 
4821  double& operator()(const int& i);
4822 
4823  int min;
4824  int max;
4826 
4827  int indexmin() const
4828  {
4829  return min;
4830  }
4831  int indexmax() const
4832  {
4833  return max;
4834  }
4835 
4836  friend class dvar_matrix_position;
4837 };
4838 
4844 {
4845  public:
4846  int row_min;
4847  int row_max;
4851  dvar_matrix_position(const dvar_matrix &, int);
4852  dvar_matrix_position(int min, int max);
4855  int &rowmin(void)
4856  {
4857  return row_min;
4858  }
4859  int &rowmax(void)
4860  {
4861  return row_max;
4862  }
4863  ivector & colmin(void)
4864  {
4865  return lb;
4866  }
4867  ivector & colmax(void)
4868  {
4869  return ub;
4870  }
4871  friend ostream & operator<<(const ostream &, const dvar_matrix_position &);
4872  friend class dmatrix_position;
4873  friend class dmatrix;
4874 };
4875 
4877 dmatrix use_shape(const dmatrix & m);
4878 
4884 {
4885  public:
4886  int row_min;
4887  int row_max;
4891  dmatrix_position(const dmatrix &);
4892  dmatrix_position(int min, int max);
4895  friend class dmatrix;
4896 };
4897 
4903 {
4904  int min;
4905  int max;
4906  public:
4907  d3_array_position(int mmin, int mmax);
4908 
4909  int indexmin() const
4910  {
4911  return min;
4912  }
4913  int indexmax() const
4914  {
4915  return max;
4916  }
4917 };
4918 
4924 {
4925  int min;
4926  int max;
4927  double *v;
4928  public:
4929  dvector_position(const dvector & v);
4930  dvector_position(const dvector_position & dvp);
4931  dvector_position(void);
4932  int indexmin() const
4933  {
4934  return min;
4935  }
4936  int indexmax() const
4937  {
4938  return max;
4939  }
4940  friend class dmatrix_position;
4941 };
4942 
4948 {
4949  int min;
4950  int max;
4951  int *v;
4952  public:
4953  ivector_position(void);
4954  ivector_position(const ivector & v);
4955  ivector_position(const ivector_position & dvp);
4956  int indexmin() const
4957  {
4958  return min;
4959  }
4960  int indexmax() const
4961  {
4962  return max;
4963  }
4964 };
4965 
4966 ostream & operator<<(const ostream & s, const ptr_vector & ptr);
4967 ostream & operator<<(const ostream &, const dvar_matrix_position &);
4968 
4969 char which_library();
4970 
4975 class fmmq:public fmm_control
4976 {
4977  private:
4981 
4982  double dmin, fbest, df;
4983  long int llog, n1, ic, iconv, i1, link;
4984  double z, zz, gys, gs, sig, gso, alpha, tot, fy, dgs;
4985  long int itn, icc, np, nn, is, iu, iv, ib, ifn;
4986  int i, j;
4987  double gmax;
4988  double fsave;
4999  int mode;
5001  int ir;
5002  int isfv;
5003  int istart;
5004  int istop;
5005  double c;
5006  double cc;
5007  double dff;
5008  double fa;
5009  double fb;
5010  double dga;
5011  double dgb;
5012  double stmin;
5013  double stepbd;
5014  double tfmin;
5015  double gmin;
5016  double step;
5017  double gl1;
5018  double gl2;
5019  unsigned int k;
5020  int ititle;
5021  int print;
5022  int ipra;
5023  int ip;
5024  int n;
5025  public:
5026  fmmq(int nvar);
5027  fmmq(int nvar, const lvector & ipar);
5028  double minimize(const dvector & x, double (*pf) (const dvar_vector &));
5029  double minimize(const independent_variables & x, const dvector & c,
5030  double (*pf) (const dvar_vector &, const dvector &));
5031  void fmin(const double &f, const dvector & x, const dvector & g);
5032  void va13c(const dvector & x, double f, const dvector & g);
5033 };
5034 
5040 {
5041  dvector x; // indep variables values
5042  dvar_vector y; // dep variable values
5043  dvar_vector y2; // second derivatives
5044  public:
5045  vcubic_spline_function(const dvector & _x, const dvar_vector & _y,
5046  double yp1 = 0.0, double ypn = 0.0);
5047  vcubic_spline_function(const dvector & _x, const dvar_vector & _y,
5048  dvariable yp1, dvariable ypn);
5049  vcubic_spline_function(const dvector & _x, const dvar_vector & _y,
5050  dvariable yp1);
5051  dvariable operator () (double u);
5052  dvar_vector operator () (const dvector & u);
5054 };
5055 
5061 {
5062  dvector x; // indep variables values
5063  dvector y; // dep variable values
5064  dvector y2; // second derivatives
5065  public:
5066  cubic_spline_function(const dvector & _x, const dvector & _y,
5067  double yp1 = 0.0, double ypn = 0.0);
5068  double operator () (double u);
5069  dvector operator() (const dvector & u);
5070 };
5071 
5072 #ifdef __ZTC__
5073 void *cdecl _farptr_norm(void *);
5074 void *cdecl _farptr_fromlong(unsigned long int);
5075 #endif
5076 /*
5077 #if DOS386==1
5078  #ifdef __NDPX__
5079  void * farptr_fromlong(long int);
5080  void * _farptr_fromlong(long int i);
5081  #elif __SUN__
5082  void * farptr_fromlong(long int);
5083  #elif __GNU__
5084  void * farptr_fromlong(long int);
5085  #elif __ZTC__
5086  void * _farptr_fromlong(unsigned long int i);
5087  void * _farptr_norm(void *);
5088  #else
5089  void * farptr_fromlong(long int);
5090  #endif
5091 #else
5092  #ifdef __ZTC__
5093  void * _farptr_norm(void *);
5094  void * _farptr_fromlong(unsigned long int);
5095  #else
5096  void * farptr_fromlong(long int);
5097  #endif
5098 #endif
5099 */
5100 
5101 // this is the speical version with an index for reordering the matrix
5102 void ludcmp_index(const dmatrix & a, const ivector & indx, const double &d);
5103 
5104 void ludcmp(const dmatrix & a, const ivector & indx, const double &d);
5105 
5111 {
5112  double mult;
5113  double eps;
5115  public:
5116  function_tweaker(double eps, double mult);
5117  double operator () (double);
5118 };
5119 
5125 {
5126  double mult;
5127  double eps;
5129  public:
5130  dfunction_tweaker(double eps, double mult);
5132 };
5133 
5139 {
5140  unsigned int ncopies;
5143  //int slice_min;
5144  //int slice_max;
5145  //int row_min;
5146  //int row_max;
5147  //int col_min;
5148  //int col_max;
5149  four_array_shape(int hsl, int hsu);//, int sl,int sh,int rl,
5150  // int ru,int cl,int cu);
5151  //mat_shape(){};
5152 
5153  friend class d4_array;
5154  friend class dvar4_array;
5155 };
5156 
5162 {
5165  public:
5166  void shallow_copy(const d4_array &);
5167  d4_array(int, int);
5168  d4_array sub(int, int);
5169  void allocate(int hsl, int hsu, int sl, int sh, int nrl, int nrh, int ncl,
5170  int nch);
5171  void allocate(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5172  const imatrix & nrh, int ncl, const imatrix & nch);
5173  void allocate(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5174  const imatrix & nrh, int ncl, const i3_array & nch);
5175  void allocate(int hsl, int hsu, int sl, int sh, int nrl,
5176  int nrh, const ivector & ncl, const ivector & nch);
5177  void allocate(int hsl, int hsu, int sl, int sh, const ivector & nrl,
5178  const ivector & nrh, const ivector & ncl, const ivector & nch);
5179  void allocate(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5180  const imatrix & nrh, int ncl, int nch);
5181  void deallocate(void);
5182  void allocate(void);
5183  void allocate(const d4_array &);
5184  void allocate(const dvar4_array &);
5185  int operator!(void) const
5186  {
5187  return (shape == NULL);
5188  }
5189  d4_array(int hsl, int hsu, int sl, int sh, ivector nrl, ivector nrh,
5190  ivector ncl, ivector nch);
5191 
5192  d4_array(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5193  const imatrix & nrh, int ncl, const i3_array & nch);
5194 
5195  d4_array(int hsl, int hsu, const index_type & sl, const index_type & sh,
5196  const index_type & nrl, const index_type & nrh, const index_type & ncl,
5197  const index_type & nch);
5198 
5199  void allocate(int hsl, int hsu, const index_type & sl, const index_type& sh,
5200  const index_type & nrl, const index_type & nrh, const index_type & ncl,
5201  const index_type & nch);
5202  void allocate(ad_integer hsl, ad_integer hsu, const index_type & sl,
5203  const index_type & sh, const index_type & nrl, const index_type & nrh,
5204  const index_type & ncl, const index_type & nch);
5205 
5206  void allocate(ad_integer hsl, ad_integer hsu, const index_type & sl,
5207  const index_type & sh, const index_type & nrl, const index_type & nrh);
5208  void allocate(ad_integer hsl, ad_integer hsu, const index_type & sl,
5209  const index_type & sh);
5210  void allocate(ad_integer hsl, ad_integer hsu);
5211 
5212  d4_array & operator=(const d4_array &);
5213  d4_array(const d4_array & m2);
5214  d4_array(int, int, int, int, int, int, int, int);
5215  //d4_array(int,int,int,ivector,int,imatrix,int,int);
5216  d4_array(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5217  const imatrix & nrh, int ncl, int nch);
5218  d4_array();
5219  ~d4_array();
5220  d3_array & elem(int i)
5221  {
5222  return t[i];
5223  }
5224  dmatrix & elem(int i, int j)
5225  {
5226  return ((*this) (i)) (j);
5227  }
5228  dvector & elem(int i, int j, int k)
5229  {
5230  return (((*this) (i, j)) (k));
5231  }
5232  double &elem(int i, int j, int k, int l)
5233  {
5234  return (((*this) (i, j, k)) (l));
5235  }
5236  const d3_array & elem(int i) const
5237  {
5238  return t[i];
5239  }
5240  const dmatrix & elem(int i, int j) const
5241  {
5242  return ((*this) (i)) (j);
5243  }
5244  const dvector & elem(int i, int j, int k) const
5245  {
5246  return (((*this) (i, j)) (k));
5247  }
5248  const double &elem(int i, int j, int k, int l) const
5249  {
5250  return (((*this) (i, j, k)) (l));
5251  }
5252  const d3_array& operator()(int i) const;
5253  const d3_array& operator[](int i) const;
5254  const dmatrix& operator()(int i, int j) const;
5255  const dvector& operator()(int i, int j, int k) const;
5256  const double& operator()(int i, int j, int k, int l) const;
5257  d3_array& operator()(int);
5258  d3_array& operator[](int);
5259  dmatrix& operator()(int, int);
5260  dvector& operator()(int, int, int);
5261  double& operator()(int, int, int, int);
5262 
5263  //access functions
5264  friend class four_array_shape;
5265 
5266  int slicemin(void)
5267  {
5268  return ((*this) (hslicemin()).slicemin());
5269  }
5270  int slicemax(void)
5271  {
5272  return ((*this) (hslicemin()).slicemax());
5273  }
5274  int rowmin(void)
5275  {
5276  return ((*this) (hslicemin(), slicemin()).rowmin());
5277  }
5278  int rowmax(void)
5279  {
5280  return ((*this) (hslicemin(), slicemin()).rowmax());
5281  }
5282  int colmin(void)
5283  {
5284  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
5285  }
5286  int colmax(void)
5287  {
5288  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
5289  }
5290  // returns the number of rows
5292  {
5293  return (slicemax() - slicemin() + 1);
5294  }
5295  // returns the number of rows
5296  int rowsize()
5297  {
5298  return (rowmax() - rowmin() + 1);
5299  }
5300  // returns the number of columns
5301  int colsize()
5302  {
5303  return (colmax() - colmin() + 1);
5304  }
5305  int indexmin() const
5306  {
5307  return hslicemin();
5308  }
5309  int indexmax() const
5310  {
5311  return hslicemax();
5312  }
5313  int hslicemin() const
5314  {
5315  return shape ? shape->hslice_min : 1;
5316  }
5317  int hslicemax() const
5318  {
5319  return shape ? shape->hslice_max : 0;
5320  }
5321  int slicemin(void) const
5322  {
5323  return ((*this) (hslicemin()).slicemin());
5324  }
5325  int slicemax(void) const
5326  {
5327  return ((*this) (hslicemin()).slicemax());
5328  }
5329  int rowmin(void) const
5330  {
5331  return ((*this) (hslicemin(), slicemin()).rowmin());
5332  }
5333  int rowmax(void) const
5334  {
5335  return ((*this) (hslicemin(), slicemin()).rowmax());
5336  }
5337  int colmin(void) const
5338  {
5339  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
5340  }
5341  int colmax(void) const
5342  {
5343  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
5344  }
5345 
5346  //int hslicemin(void) const { return(shape->hslice_min);}
5347  //int hslicemax(void) const { return(shape->hslice_max);}
5348  //int slicemin(void) const { return(shape->slice_min);}
5349  //int slicemax(void) const { return(shape->slice_max);}
5350  //int colmin(void) const { return(shape->col_min);}
5351  //int colmax(void) const { return(shape->col_max);}
5352  //int rowmin(void) const { return(shape->row_min);}
5353  //int rowmax(void) const { return(shape->row_max);}
5354 
5355  // returns the number of rows
5356  unsigned int hslicesize() const
5357  {
5358  return static_cast<unsigned int>(hslicemax() - hslicemin() + 1);
5359  }
5360 
5361  // returns the number of rows
5362  int slicesize() const
5363  {
5364  return (slicemax() - slicemin() + 1);
5365  }
5366  // returns the number of rows
5367  int rowsize() const
5368  {
5369  return (rowmax() - rowmin() + 1);
5370  }
5371  // returns the number of columns
5372  int colsize() const
5373  {
5374  return (colmax() - colmin() + 1);
5375  }
5376  void operator /=(double d);
5377  void initialize();
5378  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
5379 };
5380 #ifdef OPT_LIB
5382 {
5383  return t[i];
5384 }
5386 {
5387  return t[i];
5388 }
5389 inline dmatrix& d4_array::operator()(int i, int j)
5390 {
5391  return ((*this)(i))(j);
5392 }
5393 inline dvector& d4_array::operator()(int i, int j, int k)
5394 {
5395  return ((*this)(i, j))(k);
5396 }
5397 inline double& d4_array::operator()(int i, int j, int k, int l)
5398 {
5399  return ((*this)(i, j, k))(l);
5400 }
5401 inline const d3_array& d4_array::operator()(int i) const
5402 {
5403  return t[i];
5404 }
5405 inline const d3_array& d4_array::operator[](int i) const
5406 {
5407  return t[i];
5408 }
5409 inline const dmatrix& d4_array::operator()(int i, int j) const
5410 {
5411  return ((*this)(i))(j);
5412 }
5413 inline const dvector& d4_array::operator()(int i, int j, int k) const
5414 {
5415  return ((*this)(i, j))(k);
5416 }
5417 inline const double& d4_array::operator()(int i, int j, int k, int l) const
5418 {
5419  return ((*this)(i, j, k))(l);
5420 }
5421 #endif
5422 
5423 d4_array operator/(const d4_array & m, double d);
5424 d4_array operator/(double d, const d4_array & m);
5425 #ifndef D4ARR_HPP
5426 #define D4ARR_HPP
5427 #endif
5428 
5434 {
5437  public:
5438  void shallow_copy(const dvar4_array &);
5439  dvar4_array(int, int);
5440  dvar4_array sub(int, int);
5441  void allocate(int hsl, int hsu, int sl, int sh, int nrl, int nrh, int ncl,
5442  int nch);
5443  void allocate(int hsl, int hsu, int sl, int sh, int nrl, int nrh,
5444  const ivector & ncl, const ivector & nch);
5445  void allocate(int hsl, int hsu, int sl, int sh, const ivector & nrl,
5446  const ivector & nrh, const ivector & ncl, const ivector & nch);
5447  void allocate(ad_integer, ad_integer, const index_type&, const index_type&,
5448  const index_type&, const index_type&, const index_type&, const index_type&);
5449  void allocate(ad_integer, ad_integer, const index_type &, const index_type &,
5450  const index_type &, const index_type &);
5451  void allocate(ad_integer, ad_integer, const index_type&, const index_type &);
5453 
5454  void deallocate(void);
5455  void allocate(void);
5456  void allocate(const d4_array &);
5457  void allocate(const dvar4_array &);
5458  int operator!(void) const
5459  {
5460  return (shape == NULL);
5461  }
5462  dvar4_array(int hsl, int hsu, int sl, int sh, ivector nrl, ivector nrh,
5463  ivector ncl, ivector nch);
5464  dvar4_array(const d4_array & m1);
5465  dvar4_array(const dvar4_array & m2);
5466  dvar4_array(int, int, int, int, int, int, int, int);
5467 
5469  const index_type &, const index_type &, const index_type &,
5470  const index_type &);
5471 
5472  dvar4_array(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5473  const imatrix & nrh, int ncl, int nch);
5474  void allocate(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5475  const imatrix & nrh, int ncl, int nch);
5476  //dvar4_array(int,int,int,ivector,int,imatrix,int,int);
5477  dvar4_array();
5478  ~dvar4_array();
5480  {
5481  return t[i];
5482  }
5483  dvar_matrix & elem(int i, int j)
5484  {
5485  return ((*this) (i)) (j);
5486  }
5487  dvar_vector & elem(int i, int j, int k)
5488  {
5489  return (((*this) (i, j)) (k));
5490  }
5491  prevariable elem(int i, int j, int k, int l)
5492  {
5493  return (((*this) (i, j, k)) (l));
5494  }
5495  const dvar3_array & elem(int i) const
5496  {
5497  return t[i];
5498  }
5499  const dvar_matrix & elem(int i, int j) const
5500  {
5501  return ((*this) (i)) (j);
5502  }
5503  const dvar_vector & elem(int i, int j, int k) const
5504  {
5505  return (((*this) (i, j)) (k));
5506  }
5507  const prevariable elem(int i, int j, int k, int l) const
5508  {
5509  return (((*this) (i, j, k)) (l));
5510  }
5511 
5512  d4_array vale(d4_array &);
5513  dvar4_array & operator=(const d4_array &);
5514  dvar4_array & operator=(const dvar4_array &);
5515 #ifdef OPT_LIB
5517  {
5518  return t[i];
5519  }
5521  {
5522  return t[i];
5523  }
5524  dvar_matrix & operator ()(int i, int j)
5525  {
5526  return ((*this) (i)) (j);
5527  }
5528  dvar_vector & operator ()(int i, int j, int k)
5529  {
5530  return (((*this) (i, j)) (k));
5531  }
5532  prevariable operator () (int i, int j, int k, int l)
5533  {
5534  return (((*this) (i, j, k)) (l));
5535  }
5536  inline const dvar3_array & operator() (int i) const
5537  {
5538  return t[i];
5539  }
5540  inline const dvar3_array & operator[] (int i) const
5541  {
5542  return t[i];
5543  }
5544  inline const dvar_matrix & operator() (int i, int j) const
5545  {
5546  return ((*this) (i)) (j);
5547  }
5548  inline const dvar_vector & operator() (int i, int j, int k) const
5549  {
5550  return (((*this) (i, j)) (k));
5551  }
5552  inline const prevariable operator() (int i, int j, int k, int l) const
5553  {
5554  return (((*this) (i, j, k)) (l));
5555  }
5556 #else
5557  const dvar3_array & operator() (int i) const;
5558  const dvar3_array & operator[] (int i) const;
5559  const dvar_matrix & operator() (int i, int j) const;
5560  const dvar_vector & operator() (int i, int j, int k) const;
5561  const prevariable operator() (int i, int j, int k, int l) const;
5562  dvar3_array & operator ()(int);
5563  dvar3_array & operator [](int);
5564  dvar_matrix & operator ()(int, int);
5565  dvar_vector & operator ()(int, int, int);
5566  prevariable operator () (int, int, int, int);
5567 #endif
5568  //access functions
5569  friend class four_array_shape;
5570 
5571  int slicemin(void)
5572  {
5573  return ((*this) (hslicemin()).slicemin());
5574  }
5575  int slicemax(void)
5576  {
5577  return ((*this) (hslicemin()).slicemax());
5578  }
5579  int rowmin(void)
5580  {
5581  return ((*this) (hslicemin(), slicemin()).rowmin());
5582  }
5583  int rowmax(void)
5584  {
5585  return ((*this) (hslicemin(), slicemin()).rowmax());
5586  }
5587  int colmin(void)
5588  {
5589  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
5590  }
5591  int colmax(void)
5592  {
5593  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
5594  }
5595 
5596  //int hslicemin(void) { return(shape->hslice_min);}
5597  //int hslicemax(void) { return(shape->hslice_max);}
5598  //int slicemin(void) { return(shape->slice_min);}
5599  //int slicemax(void) { return(shape->slice_max);}
5600  //int colmin(void) { return(shape->col_min);}
5601  //int colmax(void) { return(shape->col_max);}
5602  //int rowmin(void) { return(shape->row_min);}
5603  //int rowmax(void) { return(shape->row_max);}
5604 
5605  // returns the number of rows
5607  {
5608  return (slicemax() - slicemin() + 1);
5609  }
5610  // returns the number of rows
5611  int rowsize()
5612  {
5613  return (rowmax() - rowmin() + 1);
5614  }
5615  // returns the number of columns
5616  int colsize()
5617  {
5618  return (colmax() - colmin() + 1);
5619  }
5620 
5621  int indexmin() const { return hslicemin(); }
5622  int indexmax() const { return hslicemax(); }
5623  int hslicemin() const { return shape ? shape->hslice_min : 1; }
5624  int hslicemax() const { return shape ? shape->hslice_max : 0; }
5625 
5626  int slicemin(void) const
5627  {
5628  return ((*this) (hslicemin()).slicemin());
5629  }
5630  int slicemax(void) const
5631  {
5632  return ((*this) (hslicemin()).slicemax());
5633  }
5634  int rowmin(void) const
5635  {
5636  return ((*this) (hslicemin(), slicemin()).rowmin());
5637  }
5638  int rowmax(void) const
5639  {
5640  return ((*this) (hslicemin(), slicemin()).rowmax());
5641  }
5642  int colmin(void) const
5643  {
5644  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
5645  }
5646  int colmax(void) const
5647  {
5648  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
5649  }
5650  //int hslicemin(void) const { return(shape->hslice_min); }
5651  //int hslicemax(void) const { return(shape->hslice_max); }
5652  //int slicemin(void) const { return(shape->slice_min); }
5653  //int slicemax(void) const { return(shape->slice_max); }
5654  //int colmin(void) const { return(shape->col_min); }
5655  //int colmax(void) const { return(shape->col_max); }
5656  //int rowmin(void) const { return(shape->row_min); }
5657  //int rowmax(void) const { return(shape->row_max); }
5658 
5659  // returns the number of rows
5660  unsigned int hslicesize() const
5661  {
5662  return static_cast<unsigned int>(hslicemax() - hslicemin() + 1);
5663  }
5664 
5665  // returns the number of rows
5666  int slicesize() const
5667  {
5668  return (slicemax() - slicemin() + 1);
5669  }
5670  // returns the number of rows
5671  int rowsize() const
5672  {
5673  return (rowmax() - rowmin() + 1);
5674  }
5675 // returns the number of columns
5676  int colsize() const
5677  {
5678  return (colmax() - colmin() + 1);
5679  }
5680  void initialize(void);
5681  void operator/=(const prevariable & d);
5682  void operator/=(const double &d);
5683 
5684  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
5685 };
5686 
5687 dvar4_array operator/(const d4_array & m, const prevariable & d);
5688 dvar4_array operator/(const dvar4_array & m, double d);
5689 dvar4_array operator/(const dvar4_array & m, const prevariable & d);
5690 
5691 dvar5_array operator/(const d5_array & m, const prevariable & d);
5692 dvar5_array operator/(const dvar5_array & m, double d);
5693 dvar5_array operator/(const dvar5_array & m, const prevariable & d);
5694 
5695 d4_array log(const d4_array & x);
5696 dvar4_array log(const dvar4_array & x);
5697 d4_array mfexp(const d4_array & x);
5698 dvar4_array mfexp(const dvar4_array & x);
5699 d4_array exp(const d4_array & x);
5700 dvar4_array exp(const dvar4_array & x);
5701 d4_array sqrt(const d4_array & x);
5702 dvar4_array sqrt(const dvar4_array & x);
5703 
5704 d5_array log(const d5_array & x);
5705 dvar5_array log(const dvar5_array & x);
5706 d5_array mfexp(const d5_array & x);
5707 dvar5_array mfexp(const dvar5_array & x);
5708 d5_array exp(const d5_array & x);
5709 dvar5_array exp(const dvar5_array & x);
5710 d5_array sqrt(const d5_array & x);
5711 dvar5_array sqrt(const dvar5_array & x);
5712 
5713 ostream & operator<<(const ostream & ostr, const d4_array & z);
5714 ostream & operator<<(const ostream & ostr, const d5_array & z);
5715 ostream & operator<<(const ostream & ostr, const d6_array & z);
5716 istream & operator>>(const istream & istr, const d4_array & z);
5717 istream & operator>>(const istream & istr, const d5_array & z);
5718 istream & operator>>(const istream & istr, const d6_array & z);
5719 ostream & operator<<(const ostream & ostr, const dvar4_array & z);
5720 ostream & operator<<(const ostream & ostr, const dvar5_array & z);
5721 ostream & operator<<(const ostream & ostr, const dvar6_array & z);
5722 istream & operator>>(const istream & istr, const dvar4_array & z);
5723 istream & operator>>(const istream & istr, const dvar5_array & z);
5724 istream & operator>>(const istream & istr, const dvar6_array & z);
5725 
5730 class fmmt:public fmm_control
5731 {
5732  private:
5735  int m;
5736  int diagco;
5737  public:
5738  double dmin, fbest, df;
5739  double gmax;
5743  double eps;
5744  double xtol;
5745  double gtol;
5746  int nvar;
5747  long int iter;
5751 
5752  public:
5753  double minimize(const independent_variables & x,
5754  double (*pf) (const dvar_vector &));
5755  fmmt(int _nvar, int _m = 7);
5756 
5757  double minimize(const independent_variables & x, const dvector & c,
5758  double (*pf) (const dvar_vector &, const dvector &));
5759 
5760  void fmin(const double &f, const dvector & x, const dvector & g);
5761 
5762  dmatrix & hessian();
5763 };
5764 
5770 {
5773  public:
5774  void allocate(int hsl, int hsu, int sl, int sh, int nrl, int nrh, int ncl,
5775  int nch);
5776 
5777  void allocate(const ad_integer & hsl, const ad_integer & hsu,
5778  const index_type & sl, const index_type & sh,
5779  const index_type & nrl, const index_type & nrh,
5780  const index_type & ncl, const index_type & nch);
5781 
5782  void shallow_copy(const i4_array &);
5783  void deallocate(void);
5784  void allocate(void);
5785  void allocate(const i4_array &);
5786  void allocate(const dvar4_array &);
5787  int operator!(void) const
5788  {
5789  return (shape == NULL);
5790  }
5791  i4_array(int hsl, int hsu, int sl, int sh, ivector nrl, ivector nrh,
5792  ivector ncl, ivector nch);
5793 
5794  i4_array(int hsl, int hsu);
5795  void allocate(int hsl, int hsu);
5796 
5797  i4_array(int hsl, int hsu, int sl, const ivector & sh, int nrl,
5798  const imatrix & nrh, int ncl, const i3_array & nch);
5799 
5800  i4_array(const ad_integer & hsl, const ad_integer & hsh,
5801  const index_type & sl, const index_type & sh,
5802  const index_type & nrl, const index_type & nrh,
5803  const index_type & ncl, const index_type & nch);
5804 
5805  i4_array & operator=(const i4_array &);
5806  i4_array(const i4_array & m2);
5807  i4_array(int, int, int, int, int, int, int, int);
5808  //i4_array(int,int,int,ivector,int,imatrix,int,int);
5809  i4_array(int hsl, int hsu, int sl, const ivector & sh,
5810  int nrl, const imatrix & nrh, int ncl, int nch);
5811  i4_array();
5812  ~i4_array();
5813 
5814  i3_array& elem(int i);
5815  const i3_array& elem(int i) const;
5816 
5817  imatrix& elem(int i, int j)
5818  {
5819  return elem(i)(j);
5820  }
5821  ivector& elem(int i, int j, int k)
5822  {
5823  return elem(i)(j, k);
5824  }
5825  int& elem(int i, int j, int k, int l)
5826  {
5827  return elem(i)(j, k, l);
5828  }
5829 
5830  i3_array& operator()(int i);
5831  i3_array& operator[](int j);
5832  imatrix& operator()(int i, int j);
5833  ivector& operator()(int i, int j, int k);
5834  int& operator()(int i, int j, int k, int l);
5835  const i3_array& operator()(int i) const;
5836  const i3_array& operator[](int i) const;
5837  const imatrix& operator()(int i, int j) const;
5838  const ivector& operator()(int i, int j, int k) const;
5839  const int& operator()(int i, int j, int k, int l) const;
5840 
5841  //access functions
5842  friend class four_array_shape;
5843 
5844  int slicemin(void)
5845  {
5846  return ((*this) (hslicemin()).slicemin());
5847  }
5848  int slicemax(void)
5849  {
5850  return ((*this) (hslicemin()).slicemax());
5851  }
5852  int rowmin(void)
5853  {
5854  return ((*this) (hslicemin(), slicemin()).rowmin());
5855  }
5856  int rowmax(void)
5857  {
5858  return ((*this) (hslicemin(), slicemin()).rowmax());
5859  }
5860  int colmin(void)
5861  {
5862  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
5863  }
5864  int colmax(void)
5865  {
5866  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
5867  }
5868  // returns the number of rows
5870  {
5871  return (hslicemax() - hslicemin() + 1);
5872  }
5873  // returns the number of rows
5874  int size()
5875  {
5876  return (indexmax() - indexmin() + 1);
5877  }
5878  // returns the number of rows
5880  {
5881  return (slicemax() - slicemin() + 1);
5882  }
5883  // returns the number of rows
5884  int rowsize()
5885  {
5886  return (rowmax() - rowmin() + 1);
5887  }
5888  // returns the number of columns
5889  int colsize()
5890  {
5891  return (colmax() - colmin() + 1);
5892  }
5893  int indexmin() const
5894  {
5895  return hslicemin();
5896  }
5897  int indexmax() const
5898  {
5899  return hslicemax();
5900  }
5901  int hslicemin() const
5902  {
5903  return shape ? shape->indexmin() : 1;
5904  }
5905  int hslicemax() const
5906  {
5907  return shape ? shape->indexmax() : 0;
5908  }
5909  int slicemin(void) const
5910  {
5911  return ((*this) (hslicemin()).slicemin());
5912  }
5913  int slicemax(void) const
5914  {
5915  return ((*this) (hslicemin()).slicemax());
5916  }
5917  int rowmin(void) const
5918  {
5919  return ((*this) (hslicemin(), slicemin()).rowmin());
5920  }
5921  int rowmax(void) const
5922  {
5923  return ((*this) (hslicemin(), slicemin()).rowmax());
5924  }
5925  int colmin(void) const
5926  {
5927  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
5928  }
5929  int colmax(void) const
5930  {
5931  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
5932  }
5933  int hslicesize() const
5934  {
5935  return indexmax() - indexmin() + 1;
5936  }
5937  int size() const
5938  {
5939  return (indexmax() - indexmin() + 1);
5940  }
5941  // returns the number of rows
5942  int slicesize() const
5943  {
5944  return (slicemax() - slicemin() + 1);
5945  }
5946  // returns the number of rows
5947  int rowsize() const
5948  {
5949  return (rowmax() - rowmin() + 1);
5950  }
5951  // returns the number of columns
5952  int colsize() const
5953  {
5954  return (colmax() - colmin() + 1);
5955  }
5956  void initialize();
5957  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
5958 };
5959 inline i3_array& i4_array::elem(int i)
5960 {
5961  if (i < indexmin() || i > indexmax())
5962  {
5963  cerr << "Index out of bounds in "
5964  << "i4_array::elem(int).\n";
5965  ad_exit(1);
5966  }
5967  return t[i];
5968 }
5969 inline const i3_array& i4_array::elem(int i) const
5970 {
5971  if (i < indexmin() || i > indexmax())
5972  {
5973  cerr << "Index out of bounds in "
5974  << "i4_array::elem(int).\n";
5975  ad_exit(1);
5976  }
5977  return t[i];
5978 }
5980 {
5981 #ifdef OPT_LIB
5982  return t[i];
5983 #else
5984  return elem(i);
5985 #endif
5986 }
5988 {
5989 #ifdef OPT_LIB
5990  return t[i];
5991 #else
5992  return elem(i);
5993 #endif
5994 }
5995 inline imatrix& i4_array::operator()(int i, int j)
5996 {
5997 #ifdef OPT_LIB
5998  return t[i](j);
5999 #else
6000  return elem(i)(j);
6001 #endif
6002 }
6003 inline ivector& i4_array::operator()(int i, int j, int k)
6004 {
6005 #ifdef OPT_LIB
6006  return t[i](j, k);
6007 #else
6008  return elem(i)(j, k);
6009 #endif
6010 }
6011 inline int& i4_array::operator()(int i, int j, int k, int a)
6012 {
6013 #ifdef OPT_LIB
6014  return t[i](j, k, a);
6015 #else
6016  return elem(i)(j, k, a);
6017 #endif
6018 }
6019 inline const i3_array& i4_array::operator()(int i) const
6020 {
6021 #ifdef OPT_LIB
6022  return t[i];
6023 #else
6024  return elem(i);
6025 #endif
6026 }
6027 inline const i3_array& i4_array::operator[](int i) const
6028 {
6029 #ifdef OPT_LIB
6030  return t[i];
6031 #else
6032  return elem(i);
6033 #endif
6034 }
6035 inline const imatrix& i4_array::operator()(int i, int j) const
6036 {
6037 #ifdef OPT_LIB
6038  return t[i](j);
6039 #else
6040  return elem(i)(j);
6041 #endif
6042 }
6043 inline const ivector& i4_array::operator()(int i, int j, int k) const
6044 {
6045 #ifdef OPT_LIB
6046  return t[i](j, k);
6047 #else
6048  return elem(i)(j, k);
6049 #endif
6050 }
6051 inline const int& i4_array::operator()(int i, int j, int k, int a) const
6052 {
6053 #ifdef OPT_LIB
6054  return t[i](j, k, a);
6055 #else
6056  return elem(i)(j, k, a);
6057 #endif
6058 }
6059 
6060 ostream& operator<<(const ostream& output, const i4_array& iarray);
6061 istream& operator>>(const istream& input, const i4_array& iarray);
6062 
6068 {
6071  public:
6072  void allocate(int hhsl, int hhsu);
6073 
6074  void allocate(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh, int nrl,
6075  int nrh, int ncl, int nch);
6076 
6077  void allocate(const ad_integer & hsl, const ad_integer & hsu,
6078  const index_type & sl, const index_type & sh, const index_type & nrl,
6079  const index_type & nrh, const index_type & ncl, const index_type & nch,
6080  const index_type & aa, const index_type & bb);
6081 
6082  void shallow_copy(const i5_array&);
6083  void deallocate(void);
6084  void allocate(void);
6085  void allocate(const i5_array &);
6086  //void allocate(const dvar4_array&);
6087  int operator!(void) const
6088  {
6089  return (shape == NULL);
6090  }
6091  i5_array(int hsl, int hsu);
6092  i5_array(int hsl, int hsu, int sl, int sh, ivector nrl, ivector nrh,
6093  ivector ncl, ivector nch);
6094 
6095  i5_array(int hsl, int hsu, int sl, const ivector & sh, int nrl,
6096  const imatrix & nrh, int ncl, const i3_array & nch);
6097 
6098  i5_array(const ad_integer & hsl, const ad_integer & hsh,
6099  const index_type & sl, const index_type & sh,
6100  const index_type & nrl, const index_type & nrh,
6101  const index_type & ncl, const index_type & nch,
6102  const index_type & aa, const index_type & bb);
6103 
6104  i5_array & operator=(const i5_array &);
6105  i5_array(const i5_array & m2);
6106  i5_array(int, int, int, int, int, int, int, int);
6107  //i5_array(int,int,int,ivector,int,imatrix,int,int);
6108  i5_array(int hsl, int hsu, int sl, const ivector & sh,
6109  int nrl, const imatrix & nrh, int ncl, int nch);
6110  i5_array();
6111  ~i5_array();
6112 
6113  i4_array& elem(int i);
6114  const i4_array& elem(int i) const;
6115 
6116  i4_array& operator[](int);
6117  i4_array& operator()(int);
6118  i3_array& operator()(int, int);
6119  imatrix& operator()(int, int, int);
6120  ivector& operator()(int, int, int, int);
6121  int& operator()(int, int, int, int, int);
6122  const i4_array& operator[](int) const;
6123  const i4_array& operator()(int) const;
6124  const i3_array& operator()(int, int) const;
6125  const imatrix& operator()(int, int, int) const;
6126  const ivector& operator()(int, int, int, int) const;
6127  const int& operator()(int, int, int, int, int) const;
6128 
6129  //access functions
6130  friend class four_array_shape;
6131 
6132  int slicemin(void)
6133  {
6134  return ((*this) (hslicemin()).slicemin());
6135  }
6136  int slicemax(void)
6137  {
6138  return ((*this) (hslicemin()).slicemax());
6139  }
6140  int rowmin(void)
6141  {
6142  return ((*this) (hslicemin(), slicemin()).rowmin());
6143  }
6144  int rowmax(void)
6145  {
6146  return ((*this) (hslicemin(), slicemin()).rowmax());
6147  }
6148  int colmin(void)
6149  {
6150  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
6151  }
6152  int colmax(void)
6153  {
6154  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
6155  }
6156 
6157  // returns the number of rows
6159  {
6160  return (hslicemax() - hslicemin() + 1);
6161  }
6162  // returns the number of rows
6163  int size()
6164  {
6165  return (indexmax() - indexmin() + 1);
6166  }
6167  // returns the number of rows
6169  {
6170  return (slicemax() - slicemin() + 1);
6171  }
6172  // returns the number of rows
6173  int rowsize()
6174  {
6175  return (rowmax() - rowmin() + 1);
6176  }
6177  // returns the number of columns
6178  int colsize()
6179  {
6180  return (colmax() - colmin() + 1);
6181  }
6182  int hslicemin() const
6183  {
6184  return shape ? shape->indexmin() : 1;
6185  }
6186  int hslicemax() const
6187  {
6188  return shape ? shape->indexmax() : 0;
6189  }
6190  int indexmin() const
6191  {
6192  return hslicemin();
6193  }
6194  int indexmax() const
6195  {
6196  return hslicemax();
6197  }
6198  int slicemin(void) const
6199  {
6200  return ((*this) (hslicemin()).slicemin());
6201  }
6202  int slicemax(void) const
6203  {
6204  return ((*this) (hslicemin()).slicemax());
6205  }
6206  int rowmin(void) const
6207  {
6208  return ((*this) (hslicemin(), slicemin()).rowmin());
6209  }
6210  int rowmax(void) const
6211  {
6212  return ((*this) (hslicemin(), slicemin()).rowmax());
6213  }
6214  int colmin(void) const
6215  {
6216  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmin());
6217  }
6218  int colmax(void) const
6219  {
6220  return ((*this) (hslicemin(), slicemin(), rowmax()).indexmax());
6221  }
6222  int hslicesize() const
6223  {
6224  return indexmax() - indexmin() + 1;
6225  }
6226  int size() const
6227  {
6228  return (indexmax() - indexmin() + 1);
6229  }
6230  // returns the number of rows
6231  int slicesize() const
6232  {
6233  return (slicemax() - slicemin() + 1);
6234  }
6235  // returns the number of rows
6236  int rowsize() const
6237  {
6238  return (rowmax() - rowmin() + 1);
6239  }
6240  // returns the number of columns
6241  int colsize() const
6242  {
6243  return (colmax() - colmin() + 1);
6244  }
6245  void initialize();
6246  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
6247 };
6248 inline i4_array& i5_array::elem(int i)
6249 {
6250 #ifndef OPT_LIB
6251  if (i < indexmin() || i > indexmax())
6252  {
6253  cerr << "Index out of bounds in i5_array::elem(int).\n";
6254  ad_exit(1);
6255  }
6256 #endif
6257  return t[i];
6258 }
6259 inline const i4_array& i5_array::elem(int i) const
6260 {
6261 #ifndef OPT_LIB
6262  if (i < indexmin() || i > indexmax())
6263  {
6264  cerr << "Index out of bounds in i5_array::elem(int).\n";
6265  ad_exit(1);
6266  }
6267 #endif
6268  return t[i];
6269 }
6270 #ifdef OPT_LIB
6272 {
6273  return t[i];
6274 }
6276 {
6277  return t[i];
6278 }
6279 inline i3_array& i5_array::operator()(int i, int j)
6280 {
6281  return t[i](j);
6282 }
6283 inline imatrix& i5_array::operator()(int i, int j, int k)
6284 {
6285  return t[i](j, k);
6286 }
6287 inline ivector& i5_array::operator()(int i, int j, int k, int l)
6288 {
6289  return t[i](j, k, l);
6290 }
6291 inline int& i5_array::operator()(int i, int j, int k, int l, int m)
6292 {
6293  return t[i](j, k, l, m);
6294 }
6295 inline const i4_array& i5_array::operator()(int i) const
6296 {
6297  return t[i];
6298 }
6299 inline const i4_array& i5_array::operator[](int i) const
6300 {
6301  return t[i];
6302 }
6303 inline const i3_array& i5_array::operator()(int i, int j) const
6304 {
6305  return t[i](j);
6306 }
6307 inline const imatrix& i5_array::operator()(int i, int j, int k) const
6308 {
6309  return t[i](j, k);
6310 }
6311 inline const ivector& i5_array::operator()(int i, int j, int k, int l) const
6312 {
6313  return t[i](j, k, l);
6314 }
6315 inline const int& i5_array::operator()(int i, int j, int k, int l, int m) const
6316 {
6317  return t[i](j, k, l, m);
6318 }
6319 #endif
6320 
6321 ostream& operator<<(const ostream& output, const i5_array& iarray);
6322 istream& operator>>(const istream& input, const i5_array& iarray);
6323 
6324 // ***************************************************************
6325 // ***************************************************************
6326 // ***************************************************************
6332 {
6335  public:
6336  d5_array(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh, int nrl,
6337  int nrh, int ncl, int nch);
6338  void allocate(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
6339  int nrl, int nrh, int ncl, int nch);
6340 
6341  void allocate(int imin, int imax);
6342 
6343  void shallow_copy(const d5_array&);
6344 
6345  d5_array(int imin, int imax);
6346 
6347  d5_array(const ad_integer & hhsl, const ad_integer & hhsu,
6348  const index_type & hsl, const index_type & hsu, const index_type & sl,
6349  const index_type & sh, const index_type & nrl, const index_type & nrh,
6350  const index_type & ncl, const index_type & nch);
6351 
6352  void allocate(const ad_integer & hhsl, const ad_integer & hhsu,
6353  const index_type & hsl, const index_type & hsu,
6354  const index_type & sl, const index_type & sh,
6355  const index_type & nrl, const index_type & nrh,
6356  const index_type & ncl, const index_type & nch);
6357 
6358  void deallocate(void);
6359  void allocate(void);
6360  void allocate(const d5_array &);
6361  //void allocate(const dvar5_array&);
6362  int operator!(void) const
6363  {
6364  return (shape == NULL);
6365  }
6366 
6367  d5_array & operator=(const d5_array &);
6368  d5_array(const d5_array & m2);
6369  d5_array();
6370  ~d5_array();
6371  d4_array & elem(int i)
6372  {
6373  return t[i];
6374  }
6375  d3_array & elem(int i, int j)
6376  {
6377  return ((*this) (i)) (j);
6378  }
6379  dmatrix & elem(int i, int j, int k)
6380  {
6381  return (((*this) (i, j)) (k));
6382  }
6383  dvector & elem(int i, int j, int k, int l)
6384  {
6385  return (((*this) (i, j, k)) (l));
6386  }
6387  double &elem(int i, int j, int k, int l, int _m)
6388  {
6389  return (((*this) (i)) (j, k, l, _m));
6390  }
6391  const d4_array & elem(int i) const
6392  {
6393  return t[i];
6394  }
6395  const d3_array & elem(int i, int j) const
6396  {
6397  return ((*this) (i)) (j);
6398  }
6399  const dmatrix & elem(int i, int j, int k) const
6400  {
6401  return (((*this) (i, j)) (k));
6402  }
6403  const dvector & elem(int i, int j, int k, int l) const
6404  {
6405  return (((*this) (i, j, k)) (l));
6406  }
6407  const double &elem(int i, int j, int k, int l, int _m) const
6408  {
6409  return (((*this) (i)) (j, k, l, _m));
6410  }
6411 #ifdef OPT_LIB
6413  {
6414  return t[i];
6415  }
6417  {
6418  return t[i];
6419  }
6420  d3_array & operator ()(int i, int j)
6421  {
6422  return ((*this) (i)) (j);
6423  }
6424  dmatrix & operator ()(int i, int j, int k)
6425  {
6426  return (((*this) (i, j)) (k));
6427  }
6428  dvector & operator ()(int i, int j, int k, int l)
6429  {
6430  return (((*this) (i)) (j, k, l));
6431  }
6432  double &operator () (int i, int j, int k, int l, int _m)
6433  {
6434  return (((*this) (i)) (j, k, l, _m));
6435  }
6436  inline const d4_array & operator() (int i) const
6437  {
6438  return t[i];
6439  }
6440  inline const d4_array & operator[] (int i) const
6441  {
6442  return t[i];
6443  }
6444  inline const d3_array & operator() (int i, int j) const
6445  {
6446  return ((*this) (i)) (j);
6447  }
6448  inline const dmatrix & operator() (int i, int j, int k) const
6449  {
6450  return (((*this) (i)) (j, k));
6451  }
6452  inline const dvector & operator() (int i, int j, int k, int l) const
6453  {
6454  return (((*this) (i)) (j, k, l));
6455  }
6456  inline const double &operator () (int i, int j, int k, int l, int _m) const
6457  {
6458  return (((*this) (i)) (j, k, l, _m));
6459  }
6460 #else
6461  const d4_array & operator() (int i) const;
6462  const d4_array & operator[] (int i) const;
6463  const d3_array & operator() (int i, int j) const;
6464  const dmatrix & operator() (int i, int j, int k) const;
6465  const dvector & operator() (int i, int j, int k, int l) const;
6466  const double &operator() (int i, int j, int k, int l, int _m) const;
6467  d4_array & operator ()(int);
6468  d4_array & operator [](int);
6469  d3_array & operator ()(int, int);
6470  dmatrix & operator ()(int, int, int);
6471  dvector & operator ()(int, int, int, int);
6472  double &operator () (int, int, int, int, int);
6473 #endif
6474  //access functions
6475  int indexmin() const
6476  {
6477  return shape ? shape->indexmin() : 1;
6478  }
6479  int indexmax() const
6480  {
6481  return shape ? shape->indexmax() : 0;
6482  }
6483  unsigned int size() const
6484  {
6485  return static_cast<unsigned int>(indexmax() - indexmin() + 1);
6486  }
6487  void initialize();
6488  void operator/=(double d);
6489  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
6490 };
6491 
6492 d5_array operator/(const d5_array & m, double d);
6493 
6499 {
6502 public:
6503  dvar5_array();
6504  dvar5_array(const d5_array& darray);
6505  dvar5_array(const dvar5_array& other);
6506  dvar5_array(int hhsl, int hhsu);
6507  dvar5_array(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
6508  int nrl, int nrh, int ncl, int nch);
6509  ~dvar5_array();
6510 
6511  dvar5_array sub(int hhsl, int hhsu);
6512  void shallow_copy(const dvar5_array &);
6513  void allocate(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
6514  int nrl, int nrh, int ncl, int nch);
6515 
6516  dvar5_array(const ad_integer & hhsl, const ad_integer & hhsu,
6517  const index_type & hsl, const index_type & hsu,
6518  const index_type & sl, const index_type & sh,
6519  const index_type & nrl, const index_type & nrh,
6520  const index_type & ncl, const index_type & nch);
6521 
6522  void allocate(int imin, int imax);
6523 
6524  void allocate(const ad_integer & hhsl, const ad_integer & hhsu,
6525  const index_type & hsl, const index_type & hsu,
6526  const index_type & sl, const index_type & sh,
6527  const index_type & nrl, const index_type & nrh,
6528  const index_type & ncl, const index_type & nch);
6529 
6530  void deallocate(void);
6531  void allocate(void);
6532  void allocate(const d5_array &);
6533  void allocate(const dvar5_array &);
6534  int operator!(void) const
6535  {
6536  return (shape == NULL);
6537  }
6538 
6539  dvar5_array & operator=(const d5_array &);
6540  dvar5_array & operator=(const dvar5_array & m);
6542  {
6543  return t[i];
6544  }
6545  dvar3_array & elem(int i, int j)
6546  {
6547  return ((*this) (i)) (j);
6548  }
6549  dvar_matrix & elem(int i, int j, int k)
6550  {
6551  return (((*this) (i, j)) (k));
6552  }
6553  dvar_vector & elem(int i, int j, int k, int l)
6554  {
6555  return (((*this) (i, j, k)) (l));
6556  }
6557  prevariable elem(int i, int j, int k, int l, int _m)
6558  {
6559  return (((*this) (i)) (j, k, l, _m));
6560  }
6561  const dvar4_array & elem(int i) const
6562  {
6563  return t[i];
6564  }
6565  const dvar3_array & elem(int i, int j) const
6566  {
6567  return ((*this) (i)) (j);
6568  }
6569  const dvar_matrix & elem(int i, int j, int k) const
6570  {
6571  return (((*this) (i, j)) (k));
6572  }
6573  const dvar_vector & elem(int i, int j, int k, int l) const
6574  {
6575  return (((*this) (i, j, k)) (l));
6576  }
6577  const prevariable elem(int i, int j, int k, int l, int _m) const
6578  {
6579  return (((*this) (i)) (j, k, l, _m));
6580  }
6581 #ifdef OPT_LIB
6583  {
6584  return t[i];
6585  }
6587  {
6588  return t[i];
6589  }
6590  dvar3_array & operator ()(int i, int j)
6591  {
6592  return ((*this) (i)) (j);
6593  }
6594  dvar_matrix & operator ()(int i, int j, int k)
6595  {
6596  return (((*this) (i, j)) (k));
6597  }
6598  dvar_vector & operator ()(int i, int j, int k, int l)
6599  {
6600  return (((*this) (i)) (j, k, l));
6601  }
6602  prevariable operator () (int i, int j, int k, int l, int _m)
6603  {
6604  return (((*this) (i)) (j, k, l, _m));
6605  }
6606  inline const dvar4_array & operator() (int i) const
6607  {
6608  return t[i];
6609  }
6610  inline const dvar4_array & operator[] (int i) const
6611  {
6612  return t[i];
6613  }
6614  inline const dvar3_array & operator() (int i, int j) const
6615  {
6616  return ((*this) (i)) (j);
6617  }
6618  inline const dvar_matrix & operator() (int i, int j, int k) const
6619  {
6620  return (((*this) (i)) (j, k));
6621  }
6622  inline const dvar_vector & operator() (int i, int j, int k, int l) const
6623  {
6624  return (((*this) (i)) (j, k, l));
6625  }
6626  inline const prevariable operator() (int i, int j, int k, int l, int _m)
6627  const
6628  {
6629  return (((*this) (i)) (j, k, l, _m));
6630  }
6631 #else
6632  const dvar4_array & operator() (int i) const;
6633  const dvar4_array & operator[] (int i) const;
6634  const dvar3_array & operator() (int i, int j) const;
6635  const dvar_matrix & operator() (int i, int j, int k) const;
6636  const dvar_vector & operator() (int i, int j, int k, int l) const;
6637  const prevariable operator() (int i, int j, int k, int l, int _m) const;
6638  dvar4_array & operator ()(int);
6639  dvar4_array & operator [](int);
6640  dvar3_array & operator ()(int, int);
6641  dvar_matrix & operator ()(int, int, int);
6642  dvar_vector & operator ()(int, int, int, int);
6643  prevariable operator () (int, int, int, int, int);
6644 #endif
6645  //access functions
6646  int indexmin() const
6647  {
6648  return shape ? shape->indexmin() : 1;
6649  }
6650  int indexmax() const
6651  {
6652  return shape ? shape->indexmax() : 0;
6653  }
6654  unsigned int size() const
6655  {
6656  return static_cast<unsigned int>(indexmax() - indexmin() + 1);
6657  }
6658  void initialize();
6659  void operator/=(const prevariable& d);
6660  void operator/=(const double& d);
6661 
6662  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
6663 };
6664 
6665 dvar5_array operator/(const d5_array & m, const prevariable & d);
6666 dvar5_array operator/(const dvar5_array & m, double d);
6667 dvar5_array operator/(const dvar5_array & m, const prevariable & d);
6668 
6674 {
6677 public:
6678  void shallow_copy(const d6_array&);
6679  d6_array(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh, int nrl,
6680  int nrh, int ncl, int nch, int l6, int u6);
6681  void allocate(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
6682  int nrl, int nrh, int ncl, int nch, int l6, int u6);
6683  void allocate(int hhsl, int hhsu);
6684 
6685  d6_array(const ad_integer & hhsl, const ad_integer & hhsu,
6686  const index_type & hsl, const index_type & hsu,
6687  const index_type & sl, const index_type & sh,
6688  const index_type & nrl, const index_type & nrh,
6689  const index_type & ncl, const index_type & nch,
6690  const index_type & l6, const index_type & u6);
6691 
6692  void allocate(const ad_integer & hhsl, const ad_integer & hhsu,
6693  const index_type & hsl, const index_type & hsu,
6694  const index_type & sl, const index_type & sh,
6695  const index_type & nrl, const index_type & nrh,
6696  const index_type & ncl, const index_type & nch,
6697  const index_type & l6, const index_type & u6);
6698 
6699  void deallocate(void);
6700  void allocate(void);
6701  void allocate(const d6_array &);
6702  //void allocate(const dvar5_array&);
6703  int operator!(void) const
6704  {
6705  return (shape == NULL);
6706  }
6707 
6708  d6_array & operator=(const d6_array &);
6709  d6_array(const d6_array & m2);
6710  d6_array();
6711  ~d6_array();
6712  d5_array& elem(int i);
6713  d4_array& elem(int i, int j)
6714  {
6715  return elem(i)(j);
6716  }
6717  d3_array& elem(int i, int j, int k)
6718  {
6719  return elem(i)(j, k);
6720  }
6721  dmatrix& elem(int i, int j, int k, int l)
6722  {
6723  return elem(i)(j, k, l);
6724  }
6725  dvector& elem(int i, int j, int k, int l, int _m)
6726  {
6727  return elem(i)(j, k, l, _m);
6728  }
6729  double &elem(int i, int j, int k, int l, int _m, int _n)
6730  {
6731  return elem(i)(j, k, l, _m, _n);
6732  }
6733  const d5_array& elem(int i) const;
6734  const d4_array& elem(int i, int j) const
6735  {
6736  return elem(i)(j);
6737  }
6738  const d3_array& elem(int i, int j, int k) const
6739  {
6740  return elem(i)(j, k);
6741  }
6742  const dmatrix& elem(int i, int j, int k, int l) const
6743  {
6744  return elem(i)(j, k, l);
6745  }
6746  const dvector& elem(int i, int j, int k, int l, int _m) const
6747  {
6748  return elem(i)(j, k, l, _m);
6749  }
6750  const double& elem(int i, int j, int k, int l, int _m, int _n) const
6751  {
6752  return elem(i)(j, k, l, _m, _n);
6753  }
6755  {
6756  return elem(i);
6757  }
6759  {
6760  return elem(i);
6761  }
6762  d4_array& operator()(int i, int j)
6763  {
6764  return elem(i)(j);
6765  }
6766  d3_array& operator ()(int i, int j, int k)
6767  {
6768  return elem(i)(j, k);
6769  }
6770  dmatrix& operator ()(int i, int j, int k, int l)
6771  {
6772  return elem(i)(j, k, l);
6773  }
6774  dvector& operator ()(int i, int j, int k, int l, int _m)
6775  {
6776  return elem(i)(j, k, l, _m);
6777  }
6778  double& operator()(int i, int j, int k, int l, int _m, int _n)
6779  {
6780  return elem(i)(j, k, l, _m, _n);
6781  }
6782  inline const d5_array& operator()(int i) const
6783  {
6784  return elem(i);
6785  }
6786  inline const d5_array& operator[](int i) const
6787  {
6788  return elem(i);
6789  }
6790  inline const d4_array& operator()(int i, int j) const
6791  {
6792  return elem(i)(j);
6793  }
6794  inline const d3_array& operator()(int i, int j, int k) const
6795  {
6796  return elem(i)(j, k);
6797  }
6798  inline const dmatrix& operator()(int i, int j, int k, int l) const
6799  {
6800  return elem(i)(j, k, l);
6801  }
6802  inline const dvector& operator()(int i, int j, int k, int l, int _m) const
6803  {
6804  return elem(i)(j, k, l, _m);
6805  }
6806  inline const double& operator()(int i, int j, int k, int l, int _m, int _n)
6807  const
6808  {
6809  return elem(i)(j, k, l, _m, _n);
6810  }
6811  //access functions
6812  int indexmin() const
6813  {
6814  return shape ? shape->indexmin() : 1;
6815  }
6816  int indexmax() const
6817  {
6818  return shape ? shape->indexmax() : 0;
6819  }
6820  unsigned int size() const
6821  {
6822  return static_cast<unsigned int>(indexmax() - indexmin() + 1);
6823  }
6824  void initialize();
6825  void operator/=(double d);
6826  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
6827 };
6828 inline d5_array& d6_array::elem(int i)
6829 {
6830 #ifndef OPT_LIB
6831  if (i < indexmin() || i > indexmax())
6832  {
6833  cerr << "Error: Index is out of bounds in"
6834  << " d5_array& d6_array::elem(int).\n";
6835  ad_exit(1);
6836  }
6837 #endif
6838 
6839  return t[i];
6840 }
6841 inline const d5_array& d6_array::elem(int i) const
6842 {
6843 #ifndef OPT_LIB
6844  if (i < indexmin() || i > indexmax())
6845  {
6846  cerr << "Error: Index is out of bounds in"
6847  << " d5_array& d6_array::elem(int).\n";
6848  ad_exit(1);
6849  }
6850 #endif
6851 
6852  return t[i];
6853 }
6854 
6855 d6_array operator/(const d6_array & m, double d);
6856 
6862 {
6865  public:
6866  void shallow_copy(const dvar6_array &);
6867  dvar6_array(int hhsl, int hhsu);
6868  void allocate(int hhsl, int hhsu);
6869  dvar6_array(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
6870  int nrl, int nrh, int ncl, int nch, int l6, int u6);
6871  void allocate(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
6872  int nrl, int nrh, int ncl, int nch, int l6, int u6);
6873 
6874  dvar6_array(const ad_integer & hhsl, const ad_integer & hhsu,
6875  const index_type & hsl, const index_type & hsu,
6876  const index_type & sl, const index_type & sh,
6877  const index_type & nrl, const index_type & nrh,
6878  const index_type & ncl, const index_type & nch,
6879  const index_type & l6, const index_type & u6);
6880 
6881  void allocate(const ad_integer & hhsl, const ad_integer & hhsu,
6882  const index_type & hsl, const index_type & hsu,
6883  const index_type & sl, const index_type & sh,
6884  const index_type & nrl, const index_type & nrh,
6885  const index_type & ncl, const index_type & nch,
6886  const index_type & l6, const index_type & u6);
6887 
6888  void deallocate(void);
6889  void allocate(void);
6890  void allocate(const d6_array &);
6891  void allocate(const dvar6_array &);
6892  int operator!(void) const
6893  {
6894  return (shape == NULL);
6895  }
6896 
6897  dvar6_array & operator=(const d6_array &);
6898  dvar6_array & operator=(const dvar6_array & m);
6899  dvar6_array(const d6_array & m2);
6900  dvar6_array(const dvar6_array & m2);
6901  dvar6_array();
6902  ~dvar6_array();
6904  {
6905  return t[i];
6906  }
6907  dvar4_array & elem(int i, int j)
6908  {
6909  return ((*this) (i)) (j);
6910  }
6911  dvar3_array & elem(int i, int j, int k)
6912  {
6913  return (((*this) (i, j)) (k));
6914  }
6915  dvar_matrix & elem(int i, int j, int k, int l)
6916  {
6917  return (((*this) (i, j, k)) (l));
6918  }
6919  dvar_vector & elem(int i, int j, int k, int l, int _m)
6920  {
6921  return (((*this) (i)) (j, k, l, _m));
6922  }
6923  prevariable elem(int i, int j, int k, int l, int _m, int _n)
6924  {
6925  return (((*this) (i)) (j, k, l, _m, _n));
6926  }
6927  const dvar5_array & elem(int i) const
6928  {
6929  return t[i];
6930  }
6931  const dvar4_array & elem(int i, int j) const
6932  {
6933  return ((*this) (i)) (j);
6934  }
6935  const dvar3_array & elem(int i, int j, int k) const
6936  {
6937  return (((*this) (i, j)) (k));
6938  }
6939  const dvar_matrix & elem(int i, int j, int k, int l) const
6940  {
6941  return (((*this) (i, j, k)) (l));
6942  }
6943  const dvar_vector & elem(int i, int j, int k, int l, int _m) const
6944  {
6945  return (((*this) (i)) (j, k, l, _m));
6946  }
6947  const prevariable elem(int i, int j, int k, int l, int _m, int _n) const
6948  {
6949  return (((*this) (i)) (j, k, l, _m, _n));
6950  }
6951 #ifdef OPT_LIB
6953  {
6954  return t[i];
6955  }
6957  {
6958  return t[i];
6959  }
6960  dvar4_array & operator ()(int i, int j)
6961  {
6962  return ((*this) (i)) (j);
6963  }
6964  dvar3_array & operator ()(int i, int j, int k)
6965  {
6966  return (((*this) (i, j)) (k));
6967  }
6968  dvar_matrix & operator ()(int i, int j, int k, int l)
6969  {
6970  return (((*this) (i)) (j, k, l));
6971  }
6972  dvar_vector & operator ()(int i, int j, int k, int l, int _m)
6973  {
6974  return (((*this) (i)) (j, k, l, _m));
6975  }
6976  prevariable operator () (int i, int j, int k, int l, int _m, int _n)
6977  {
6978  return (((*this) (i)) (j, k, l, _m, _n));
6979  }
6980  inline const dvar5_array & operator() (int i) const
6981  {
6982  return t[i];
6983  }
6984  inline const dvar5_array & operator[] (int i) const
6985  {
6986  return t[i];
6987  }
6988  inline const dvar4_array & operator() (int i, int j) const
6989  {
6990  return ((*this) (i)) (j);
6991  }
6992  inline const dvar3_array & operator() (int i, int j, int k) const
6993  {
6994  return (((*this) (i)) (j, k));
6995  }
6996  inline const dvar_matrix & operator() (int i, int j, int k, int l) const
6997  {
6998  return (((*this) (i)) (j, k, l));
6999  }
7000  inline const dvar_vector & operator() (int i, int j, int k, int l, int _m)
7001  const
7002  {
7003  return (((*this) (i)) (j, k, l, _m));
7004  }
7005  inline const prevariable operator() (int i, int j, int k, int l, int _m,
7006  int _n) const
7007  {
7008  return (((*this) (i)) (j, k, l, _m, _n));
7009  }
7010 #else
7011  const dvar5_array & operator() (int i) const;
7012  const dvar5_array & operator[] (int i) const;
7013  const dvar4_array & operator() (int i, int j) const;
7014  const dvar3_array & operator() (int i, int j, int k) const;
7015  const dvar_matrix & operator() (int i, int j, int k, int l) const;
7016  const dvar_vector & operator() (int i, int j, int k, int l, int _m) const;
7017  const prevariable operator() (int i, int j, int k, int l, int _m, int _n)
7018  const;
7019  dvar5_array & operator ()(int);
7020  dvar5_array & operator [](int);
7021  dvar4_array & operator ()(int, int);
7022  dvar3_array & operator ()(int, int, int);
7023  dvar_matrix & operator ()(int, int, int, int);
7024  dvar_vector & operator ()(int, int, int, int, int);
7025  prevariable operator () (int, int, int, int, int, int);
7026 #endif
7027  //access functions
7028  int indexmin() const
7029  {
7030  return shape ? shape->indexmin() : 1;
7031  }
7032  int indexmax() const
7033  {
7034  return shape ? shape->indexmax() : 0;
7035  }
7036  unsigned int size() const
7037  {
7038  return static_cast<unsigned int>(indexmax() - indexmin() + 1);
7039  }
7040  void initialize();
7041  void operator/=(const prevariable& d);
7042  void operator/=(const double& d);
7043  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
7044 };
7045 
7046 dvar6_array operator/(const d6_array & m, const prevariable & d);
7047 dvar6_array operator/(const dvar6_array & m, double d);
7048 dvar6_array operator/(const dvar6_array & m, const prevariable & d);
7049 
7055 {
7058  public:
7059  void allocate(int l7, int u7);
7060  d7_array(int l7, int u7, int hhsl, int hhsu, int hsl, int hsu, int sl,
7061  int sh, int nrl, int nrh, int ncl, int nch, int l6, int u6);
7062  void allocate(int l7, int u7, int hhsl, int hhsu, int hsl, int hsu,
7063  int sl, int sh, int nrl, int nrh, int ncl, int nch, int l6, int u6);
7064 
7065  d7_array(const ad_integer & hhsl, const ad_integer & hhsu,
7066  const index_type & l7, const index_type & u7,
7067  const index_type & hsl, const index_type & hsu,
7068  const index_type & sl, const index_type & sh,
7069  const index_type & nrl, const index_type & nrh,
7070  const index_type & ncl, const index_type & nch,
7071  const index_type & l6, const index_type & u6);
7072 
7073  void allocate(const ad_integer & hhsl, const ad_integer & hhsu,
7074  const index_type & l7, const index_type & u7,
7075  const index_type & hsl, const index_type & hsu,
7076  const index_type & sl, const index_type & sh,
7077  const index_type & nrl, const index_type & nrh,
7078  const index_type & ncl, const index_type & nch,
7079  const index_type & l6, const index_type & u6);
7080 
7081  void deallocate(void);
7082  void allocate(void);
7083  void allocate(const d7_array &);
7084  //void allocate(const dvar5_array&);
7085  int operator!(void) const
7086  {
7087  return (shape == NULL);
7088  }
7089 
7090  d7_array();
7091  d7_array(const d7_array&);
7092  ~d7_array();
7093 
7094  d7_array & operator=(const d7_array &);
7095 
7096  d6_array& elem(int i);
7097  d5_array& elem(int i, int j)
7098  {
7099  return elem(i)(j);
7100  }
7101  d4_array& elem(int i, int j, int k)
7102  {
7103  return elem(i)(j, k);
7104  }
7105  d3_array& elem(int i, int j, int k, int l)
7106  {
7107  return elem(i)(j, k, l);
7108  }
7109  dmatrix& elem(int i, int j, int k, int l, int _m)
7110  {
7111  return elem(i)(j, k, l, _m);
7112  }
7113  dvector& elem(int i, int j, int k, int l, int _m, int _n)
7114  {
7115  return elem(i)(j, k, l, _m, _n);
7116  }
7117  double& elem(int i, int j, int k, int l, int _m, int _n, int _p)
7118  {
7119  return elem(i)(j, k, l, _m, _n, _p);
7120  }
7121  const d6_array& elem(int i) const;
7122  const d5_array& elem(int i, int j) const
7123  {
7124  return elem(i)(j);
7125  }
7126  const d4_array& elem(int i, int j, int k) const
7127  {
7128  return elem(i)(j, k);
7129  }
7130  const d3_array& elem(int i, int j, int k, int l) const
7131  {
7132  return elem(i)(j, k, l);
7133  }
7134  const dmatrix& elem(int i, int j, int k, int l, int _m) const
7135  {
7136  return elem(i)(j, k, l, _m);
7137  }
7138  const dvector& elem(int i, int j, int k, int l, int _m, int _n) const
7139  {
7140  return elem(i)(j, k, l, _m, _n);
7141  }
7142  const double& elem(int i, int j, int k, int l, int _m, int _n, int _p) const
7143  {
7144  return elem(i)(j, k, l, _m, _n, _p);
7145  }
7147  {
7148  return elem(i);
7149  }
7151  {
7152  return elem(i);
7153  }
7154  d5_array& operator()(int i, int j)
7155  {
7156  return elem(i)(j);
7157  }
7158  d4_array& operator()(int i, int j, int k)
7159  {
7160  return elem(i, j)(k);
7161  }
7162  d3_array& operator ()(int i, int j, int k, int l)
7163  {
7164  return elem(i)(j, k, l);
7165  }
7166  dmatrix& operator()(int i, int j, int k, int l, int _m)
7167  {
7168  return elem(i)(j, k, l, _m);
7169  }
7170  dvector & operator ()(int i, int j, int k, int l, int _m, int _n)
7171  {
7172  return elem(i)(j, k, l, _m, _n);
7173  }
7174  double& operator()(int i, int j, int k, int l, int _m, int _n, int _p)
7175  {
7176  return elem(i)(j, k, l, _m, _n, _p);
7177  }
7178  inline const d6_array& operator()(int i) const
7179  {
7180  return elem(i);
7181  }
7182  inline const d6_array& operator[](int i) const
7183  {
7184  return elem(i);
7185  }
7186  inline const d5_array& operator()(int i, int j) const
7187  {
7188  return elem(i)(j);
7189  }
7190  inline const d4_array& operator()(int i, int j, int k) const
7191  {
7192  return elem(i)(j, k);
7193  }
7194  inline const d3_array & operator() (int i, int j, int k, int l) const
7195  {
7196  return elem(i)(j, k, l);
7197  }
7198  inline const dmatrix& operator()(int i, int j, int k, int l, int _m) const
7199  {
7200  return elem(i)(j, k, l, _m);
7201  }
7202  inline const dvector& operator()(int i, int j, int k, int l, int _m,
7203  int _n) const
7204  {
7205  return elem(i)(j, k, l, _m, _n);
7206  }
7207  inline const double& operator()(int i, int j, int k, int l, int _m, int _n,
7208  int _p) const
7209  {
7210  return elem(i)(j, k, l, _m, _n, _p);
7211  }
7212 
7213  //access functions
7214  int indexmin() const
7215  {
7216  return shape ? shape->indexmin() : 1;
7217  }
7218  int indexmax() const
7219  {
7220  return shape ? shape->indexmax() : 0;
7221  }
7222  unsigned int size() const
7223  {
7224  return static_cast<unsigned int>(indexmax() - indexmin() + 1);
7225  }
7226  void initialize();
7227  void operator/=(double d);
7228  void shallow_copy(const d7_array&);
7229  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
7230 };
7231 inline d6_array& d7_array::elem(int i)
7232 {
7233 #ifndef OPT_LIB
7234  if (i < indexmin() || i > indexmax())
7235  {
7236  cerr << "Error index out of bounds in\n"
7237  "d5_array& d7_array::elem(int)" << endl;
7238  ad_exit(1);
7239  }
7240 #endif
7241  return t[i];
7242 }
7243 inline const d6_array& d7_array::elem(int i) const
7244 {
7245 #ifndef OPT_LIB
7246  if (i < indexmin() || i > indexmax())
7247  {
7248  cerr << "Error index out of bounds in\n"
7249  "d5_array& d7_array::elem(int)" << endl;
7250  ad_exit(1);
7251  }
7252 #endif
7253  return t[i];
7254 }
7255 
7256 d7_array operator/(const d7_array & m, double d);
7257 
7263 {
7266  public:
7267  dvar7_array(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
7268  int nrl, int nrh, int ncl, int nch, int l6, int u6, int l7, int u7);
7269  void allocate(int hhsl, int hhsu);
7270  void allocate(int hhsl, int hhsu, int hsl, int hsu, int sl, int sh,
7271  int nrl, int nrh, int ncl, int nch, int l6, int u6, int l7, int u7);
7272 
7273  dvar7_array(const ad_integer & hhsl, const ad_integer & hhsu,
7274  const index_type & l7, const index_type & u7,
7275  const index_type & hsl, const index_type & hsu,
7276  const index_type & sl, const index_type & sh,
7277  const index_type & nrl, const index_type & nrh,
7278  const index_type & ncl, const index_type & nch,
7279  const index_type & l6, const index_type & u6);
7280 
7281  void allocate(const ad_integer & hhsl, const ad_integer & hhsu,
7282  const index_type & l7, const index_type & u7,
7283  const index_type & hsl, const index_type & hsu,
7284  const index_type & sl, const index_type & sh,
7285  const index_type & nrl, const index_type & nrh,
7286  const index_type & ncl, const index_type & nch,
7287  const index_type & l6, const index_type & u6);
7288 
7289  void deallocate(void);
7290  void allocate(void);
7291  void allocate(const d7_array &);
7292  void allocate(const dvar7_array &);
7293  int operator!(void) const
7294  {
7295  return (shape == NULL);
7296  }
7297 
7298  dvar7_array & operator=(const d7_array &);
7299  dvar7_array & operator=(const dvar7_array & m);
7300  dvar7_array(d7_array & m2);
7301  dvar7_array(dvar7_array & m2);
7302  dvar7_array();
7303  ~dvar7_array();
7304  void shallow_copy(const dvar7_array&);
7306  {
7307  return t[i];
7308  }
7309  dvar5_array & elem(int i, int j)
7310  {
7311  return ((*this) (i)) (j);
7312  }
7313  dvar4_array & elem(int i, int j, int k)
7314  {
7315  return (((*this) (i, j)) (k));
7316  }
7317  dvar3_array & elem(int i, int j, int k, int l)
7318  {
7319  return (((*this) (i, j, k)) (l));
7320  }
7321  dvar_matrix & elem(int i, int j, int k, int l, int _m)
7322  {
7323  return (((*this) (i)) (j, k, l, _m));
7324  }
7325  dvar_vector & elem(int i, int j, int k, int l, int _m, int _n)
7326  {
7327  return (((*this) (i)) (j, k, l, _m, _n));
7328  }
7329  prevariable elem(int i, int j, int k, int l, int _m, int _n, int _p)
7330  {
7331  return (((*this) (i)) (j, k, l, _m, _n, _p));
7332  }
7333  const dvar6_array & elem(int i) const
7334  {
7335  return t[i];
7336  }
7337  const dvar5_array & elem(int i, int j) const
7338  {
7339  return ((*this) (i)) (j);
7340  }
7341  const dvar4_array & elem(int i, int j, int k) const
7342  {
7343  return (((*this) (i, j)) (k));
7344  }
7345  const dvar3_array & elem(int i, int j, int k, int l) const
7346  {
7347  return (((*this) (i, j, k)) (l));
7348  }
7349  const dvar_matrix & elem(int i, int j, int k, int l, int _m) const
7350  {
7351  return (((*this) (i)) (j, k, l, _m));
7352  }
7353  const dvar_vector & elem(int i, int j, int k, int l, int _m, int _n) const
7354  {
7355  return (((*this) (i)) (j, k, l, _m, _n));
7356  }
7357  const prevariable elem(int i, int j, int k, int l, int _m, int _n, int _p)
7358  const
7359  {
7360  return (((*this) (i)) (j, k, l, _m, _n, _p));
7361  }
7362 #ifdef OPT_LIB
7364  {
7365  return t[i];
7366  }
7368  {
7369  return t[i];
7370  }
7371  dvar5_array & operator ()(int i, int j)
7372  {
7373  return ((*this) (i)) (j);
7374  }
7375  dvar4_array & operator ()(int i, int j, int k)
7376  {
7377  return (((*this) (i, j)) (k));
7378  }
7379  dvar3_array & operator ()(int i, int j, int k, int l)
7380  {
7381  return (((*this) (i)) (j, k, l));
7382  }
7383  dvar_matrix & operator ()(int i, int j, int k, int l, int _m)
7384  {
7385  return (((*this) (i)) (j, k, l, _m));
7386  }
7387  dvar_vector & operator ()(int i, int j, int k, int l, int _m, int _n)
7388  {
7389  return (((*this) (i)) (j, k, l, _m, _n));
7390  }
7391  prevariable operator () (int i, int j, int k, int l, int _m, int _n, int _p)
7392  {
7393  return (((*this) (i)) (j, k, l, _m, _n, _p));
7394  }
7395  inline const dvar6_array & operator() (int i) const
7396  {
7397  return t[i];
7398  }
7399  inline const dvar6_array & operator[] (int i) const
7400  {
7401  return t[i];
7402  }
7403  inline const dvar5_array & operator() (int i, int j) const
7404  {
7405  return ((*this) (i)) (j);
7406  }
7407  inline const dvar4_array & operator() (int i, int j, int k) const
7408  {
7409  return (((*this) (i)) (j, k));
7410  }
7411  inline const dvar3_array & operator() (int i, int j, int k, int l) const
7412  {
7413  return (((*this) (i)) (j, k, l));
7414  }
7415  inline const dvar_matrix & operator() (int i, int j, int k, int l, int _m)
7416  const
7417  {
7418  return (((*this) (i)) (j, k, l, _m));
7419  }
7420  inline const dvar_vector & operator() (int i, int j, int k, int l, int _m,
7421  int _n) const
7422  {
7423  return (((*this) (i)) (j, k, l, _m, _n));
7424  }
7425  inline const prevariable operator()(int i, int j, int k, int l, int _m,
7426  int _n, int _p) const
7427  {
7428  return (((*this) (i)) (j, k, l, _m, _n, _p));
7429  }
7430 #else
7431  const dvar6_array & operator() (int i) const;
7432  const dvar6_array & operator[] (int i) const;
7433  const dvar5_array & operator() (int i, int j) const;
7434  const dvar4_array & operator() (int i, int j, int k) const;
7435  const dvar3_array & operator() (int i, int j, int k, int l) const;
7436  const dvar_matrix & operator() (int i, int j, int k, int l, int _m) const;
7437  const dvar_vector & operator() (int i, int j, int k, int l, int _m, int _n)
7438  const;
7439  const prevariable operator() (int i, int j, int k, int l, int _m, int _n,
7440  int _p) const;
7441  dvar6_array & operator ()(int);
7442  dvar6_array & operator [](int);
7443  dvar5_array & operator ()(int, int);
7444  dvar4_array & operator ()(int, int, int);
7445  dvar3_array & operator ()(int, int, int, int);
7446  dvar_matrix & operator ()(int, int, int, int, int);
7447  dvar_vector & operator ()(int, int, int, int, int, int);
7448  prevariable operator () (int, int, int, int, int, int, int);
7449 #endif
7450  //access functions
7451  int indexmin() const
7452  {
7453  return shape ? shape->indexmin() : 1;
7454  }
7455  int indexmax() const
7456  {
7457  return shape ? shape->indexmax() : 0;
7458  }
7459  unsigned int size() const
7460  {
7461  return static_cast<unsigned int>(indexmax() - indexmin() + 1);
7462  }
7463  void initialize();
7464  void operator/=(const prevariable& d);
7465  void operator/=(const double& d);
7466  unsigned int get_ncopies() const { return shape ? shape->ncopies : 0; }
7467 };
7468 
7469 dvar7_array operator/(const d7_array & m, const prevariable & d);
7470 dvar7_array operator/(const dvar7_array & m, double d);
7471 dvar7_array operator/(const dvar7_array & m, const prevariable & d);
7472 
7473 class lmatrix;
7474 
7480 {
7481  public:
7482  int row_min;
7483  int row_max;
7487  lmatrix_position(const lmatrix &);
7488  lmatrix_position(int min, int max);
7491 };
7492 
7495 
7500 class lmatrix
7501 {
7502  protected:
7505  friend char *fform(const char *, const dmatrix &);
7506 
7507  public:
7508  int operator!(void) const
7509  {
7510  return (shape == NULL);
7511  }
7512 
7513  lmatrix(int, int);
7514  // makes a matrix [0..nr][0..nc]
7515 
7516  lmatrix(int, int, int, int);
7517  // makes a matrix [nrl..nrh][ncl..nch]
7518  lmatrix(int, int, int, const ivector &);
7519  lmatrix(int, int, const ivector &, const ivector &);
7520  lmatrix(const ad_integer & nrl, const ad_integer & nrh,
7521  const index_type & ncl, const index_type & nch);
7522 
7523  lmatrix & operator=(const lmatrix & t);
7524  lmatrix & operator=(const imatrix & t);
7525  lmatrix(const lmatrix &);
7526  // copy initializer
7527  lmatrix(const lmatrix_position &);
7528  lmatrix(void);
7529 
7530  ~lmatrix();
7531 
7532  void save_lmatrix_value(void);
7533  void save_lmatrix_position(void);
7536 
7537  void allocate(const lmatrix & dm);
7538  void allocate(int nrl, int nrh, int ncl, int nch);
7539  void allocate(int nrl, int nrh, int ncl, const ivector & nch);
7540  void allocate(int nrl, int nrh, const ivector & ncl,
7541  const ivector & nch);
7542  void allocate(const ad_integer & nrl, const ad_integer & nrh,
7543  const index_type & ncl, const index_type & nch);
7544  void deallocate();
7545 
7546 #ifdef OPT_LIB
7547  inline lvector & operator() (int i)
7548  {
7549  return m[i];
7550  }
7551  inline AD_LONG_INT & operator() (int i, int j)
7552  {
7553  return (*((*(m + i)).v + j));
7554  }
7555  inline lvector & operator[] (int i)
7556  {
7557  return m[i];
7558  }
7559 #else
7560  lvector & operator [] (int);
7561  lvector & operator () (int);
7562  AD_LONG_INT & operator () (int, int);
7563 #endif
7564 
7565 #ifdef OPT_LIB
7566  inline const lvector & operator() (int i) const
7567  {
7568  return m[i];
7569  }
7570  inline const AD_LONG_INT & operator() (int i, int j) const
7571  {
7572  return (*((*(m + i)).v + j));
7573  }
7574  inline const lvector & operator[] (int i) const
7575  {
7576  return m[i];
7577  }
7578 #else
7579  const lvector & operator[] (int) const;
7580  const lvector & operator() (int) const;
7581  const AD_LONG_INT & operator() (int, int) const;
7582 #endif
7583 
7584  int colmin(void) const
7585  {
7586  return (shape->col_min);
7587  }
7588  int colmax(void) const
7589  {
7590  return (shape->col_max);
7591  }
7592  int rowmin(void) const
7593  {
7594  return (shape->row_min);
7595  }
7596  int rowmax(void) const
7597  {
7598  return (shape->row_max);
7599  }
7600  // returns the number of rows
7601  unsigned int rowsize() const
7602  {
7603  return shape->nrows;
7604  }
7605  // returns the number of columns
7606  unsigned int colsize() const
7607  {
7608  return shape->ncols;
7609  }
7610 
7611  void write_on(const ostream &) const;
7612  void write_on(const uostream &) const;
7613  void read_from(const istream &);
7614  void read_from(const uistream &);
7615  void initialize(void);
7616  friend class i3_array;
7617 };
7618 
7619 // void dmatrix::allocate(int nrl,int nrh,const index_type& ncl,
7620 // const index_type& nch)
7621 class index_guts;
7622 class index_type;
7623 class number_index;
7624 class vector_index;
7625 class matrix_index;
7626 class i3_index;
7627 
7632 class adkludge{};
7633 
7639 {
7640  const index_type *a;
7641  int i;
7642  public:
7643  pre_index_type(const index_type * _a, int _i):a(_a), i(_i)
7644  {
7645  }
7646  friend class index_type;
7647 };
7648 
7649 class data_int;
7650 
7655 {
7656 protected:
7657  int d;
7658 
7659 public:
7660  operator int() const
7661  {
7662  return d;
7663  }
7664  ad_integer(const int &_d, const adkludge&): d(_d)
7665  {
7666  }
7667  ad_integer(const data_int& di);
7668  ad_integer(const int _d): d(_d)
7669  {
7670  }
7671  ad_integer(const index_type& it);
7672 
7674  {
7675  adkludge adk;
7676 
7677  return ad_integer(_d, adk);
7678  }
7679 };
7680 
7683 {
7684 protected:
7685  int* ncopies;
7686 
7687 public:
7688  index_guts();
7689  index_guts(const index_guts& ig);
7690  virtual ~index_guts();
7691 
7692  virtual index_guts* operator[](int) = 0;
7693  virtual int indexmin() const = 0;
7694  virtual int indexmax() const = 0;
7695 
7696  virtual int isinteger() const
7697  {
7698  return 1;
7699  }
7700  virtual int dimension() const
7701  {
7702  return -1;
7703  }
7704  virtual operator int()
7705  {
7706  cerr << "Error in index_type"
7707  " -- object not dereferenced enough" << endl;
7708  ad_exit(1);
7709  return 1;
7710  }
7711 
7712  friend class ad_integer;
7713  friend class index_type;
7714 };
7717 {
7718  int* ncopies;
7719 
7720 public:
7721  smart_counter();
7722  smart_counter(const smart_counter& sc);
7723  ~smart_counter();
7724 
7725  int* get_ncopies();
7726 };
7732 {
7734 
7735 public:
7736  index_type(const int x);
7737  index_type(const ivector& x);
7738  index_type(const imatrix& x);
7739  index_type(const i3_array& x);
7740  index_type(const i4_array& x);
7741  index_type(const pre_index_type& pit);
7742  index_type(const index_type& pit);
7743  //index_type (i4_array& x) { p = new i4_index(x);}
7744  ~index_type();
7745 
7746  index_type operator[](int i);
7747  index_type operator()(int i);
7748  index_type operator[](int i) const;
7749  index_type operator()(int i) const;
7750 
7751  int integer() const;
7752  int isinteger() const
7753  {
7754  return p->isinteger();
7755  }
7756  int dimension() const
7757  {
7758  return p->dimension();
7759  }
7760  int indexmin() const
7761  {
7762  return p->indexmin();
7763  }
7764  int indexmax() const
7765  {
7766  return p->indexmax();
7767  }
7768 
7769  friend class ad_integer;
7770 };
7772 class number_index: public ad_integer, public index_guts
7773 {
7774 private:
7775  virtual int isinteger() const
7776  {
7777  return 0;
7778  }
7779  virtual int dimension() const
7780  {
7781  return 0;
7782  }
7783  virtual index_guts* operator[](int i);
7784  virtual int indexmin() const
7785  {
7786  return 1;
7787  }
7788  virtual int indexmax() const
7789  {
7790  return 1;
7791  }
7792 public:
7794  {
7795  }
7797  virtual ~number_index()
7798  {
7799  }
7801  virtual operator int()
7802  {
7803  return d;
7804  }
7805 
7806  friend class index_type;
7807 };
7809 class vector_index: public ivector, public index_guts
7810 {
7811  virtual index_guts* operator[](int i)
7812  {
7813  return new number_index(ivector::operator[](i));
7814  }
7815 public:
7816  //vector_index(const ivector& v) : ivector(v){}
7817 
7818  vector_index(const ivector& v);
7819  virtual ~vector_index();
7820 
7821  virtual int dimension() const
7822  {
7823  return 1;
7824  }
7825  virtual int indexmin() const
7826  {
7827  return ivector::indexmin();
7828  }
7829  virtual int indexmax() const
7830  {
7831  return ivector::indexmax();
7832  }
7833 
7834  friend class index_type;
7835 };
7837 class matrix_index: public imatrix, public index_guts
7838 {
7839 private:
7840  virtual index_guts* operator[](int i);
7841  //{
7842  // return new vector_index(imatrix::operator [](i));
7843  //}
7844 public:
7846  {
7847  }
7848  virtual ~matrix_index();
7849 
7850  virtual int dimension() const
7851  {
7852  return 2;
7853  }
7854  virtual int indexmin() const
7855  {
7856  return imatrix::rowmin();
7857  }
7858  virtual int indexmax() const
7859  {
7860  return imatrix::rowmax();
7861  }
7862 
7863  friend class index_type;
7864 };
7866 class i3_index: public i3_array, public index_guts
7867 {
7868  virtual index_guts* operator[](int i)
7869  {
7870  return new matrix_index(i3_array::operator[](i));
7871  }
7872 public:
7874  {
7875  }
7876 
7877  virtual int dimension() const
7878  {
7879  return 3;
7880  }
7881  virtual int indexmin() const
7882  {
7883  return i3_array::slicemin();
7884  }
7885  virtual int indexmax() const
7886  {
7887  return i3_array::slicemax();
7888  }
7889 
7890  friend class index_type;
7891 };
7893 class i4_index: public i4_array, public index_guts
7894 {
7895  virtual index_guts* operator[](int i)
7896  {
7897  return new i3_index(i4_array::operator[](i));
7898  }
7899 public:
7901  {
7902  }
7903 
7904  virtual int dimension() const
7905  {
7906  return 4;
7907  }
7908  virtual int indexmin() const
7909  {
7910  return i4_array::slicemin();
7911  }
7912  virtual int indexmax() const
7913  {
7914  return i4_array::slicemax();
7915  }
7916 
7917  friend class index_type;
7918 };
7919 
7920 void ad_begin_funnel(void);
7921 
7927 {
7928  vector_range_exception(int i, int imin, int imax);
7929  friend class dvector;
7930  friend class dvar_vector;
7931 };
7932 
7938 {
7939  public:
7940  int e;
7941  spdll_exception(int _e = 0)
7942  {
7943  e = _e;
7944  }
7945 };
7946 
7952 {
7953  unsigned long* mt;
7954  int mti;
7955 public:
7956  random_number_generator(const int seed);
7958 
7959  double better_rand();
7960  void reinitialize(const int seed);
7961 };
7962 
7963 double randpoisson(double lambda, const random_number_generator & rng);
7964 
7965 // note that od is the overdispersion od >1
7966 double randnegbinomial(double mu, double tau,
7967  const random_number_generator & rng);
7968 double randn(const random_number_generator & rng);
7969 double randu(const random_number_generator & rng);
7970 double gasdev(const random_number_generator & _rng);
7971 double expdev(const random_number_generator & _rng);
7972 double sgamma(double a, const random_number_generator & _rng);
7975  const dvar_matrix_position& mpos);
7976 
7982 {
7983  int bw;
7985  public:
7986  const dmatrix & get_dmatrix(void) const
7987  {
7988  return d;
7989  }
7990  void initialize(void);
7991  int bandwidth(void) const
7992  {
7993  return bw;
7994  }
7995  int indexmin(void) const
7996  {
7997  return d(0).indexmin();
7998  }
7999  int indexmax(void) const
8000  {
8001  return d(0).indexmax();
8002  }
8003  int rowmin(void) const
8004  {
8005  return d.rowmin();
8006  }
8007  int rowmax(void) const
8008  {
8009  return d.rowmax();
8010  }
8011 
8013  {
8014  }
8016 
8017  banded_symmetric_dmatrix sub(int l, int u);
8018 
8019  void shift(int);
8020 
8022  banded_symmetric_dmatrix(int _min, int _max, int _bw);
8023 
8025  void save_dmatrix_value() const;
8026  void save_dmatrix_position(void) const;
8027  void save_dmatrix_derivatives(const dvar_matrix_position &) const;
8028 
8029 #if defined(OPT_LIB)
8030  inline double& operator()(int i, int j)
8031  {
8032  return (*((d.m[i - j]).v + i));
8033  }
8034  inline dvector operator()(int i)
8035  {
8036  return (d.m[i]);
8037  }
8038  inline const double& operator()(int i, int j) const
8039  {
8040  return (*((d.m[i - j]).v + i));
8041  }
8042  inline const dvector operator()(int i) const
8043  {
8044  return (d.m[i]);
8045  }
8046 #else
8047  double &operator () (int i, int j);
8048  dvector operator () (int i);
8049  const double &operator() (int i, int j) const;
8050  const dvector operator() (int i) const;
8051 #endif
8053  const banded_symmetric_dvar_matrix& v);
8056  const dvar_matrix_position& mpos);
8057  friend double norm2(const banded_symmetric_dmatrix & B);
8058  friend double sumsq(const banded_symmetric_dmatrix & B);
8059 };
8060 
8066 {
8067  public:
8068  int bw;
8070  void initialize(void);
8071  int bandwidth(void) const
8072  {
8073  return bw;
8074  }
8075  int indexmin(void) const
8076  {
8077  return d(0).indexmin();
8078  }
8079  int indexmax(void) const
8080  {
8081  return d(0).indexmax();
8082  }
8083  int rowmin(void) const
8084  {
8085  return d.rowmin();
8086  }
8087  int rowmax(void) const
8088  {
8089  return d.rowmax();
8090  }
8091 
8092  void save_dvar_matrix_value() const;
8093  void save_dvar_matrix_position() const;
8094  banded_symmetric_dvar_matrix(int _min, int _max, int _bw);
8096 
8097 #if defined(OPT_LIB)
8099  {
8100  return ((d.m[i - j]).va + i);
8101  }
8103  {
8104  return (d.m[i]);
8105  }
8106 #else
8107  prevariable operator () (int i, int j);
8108  dvar_vector operator () (int i);
8109 #endif
8111  friend dvariable norm(const banded_symmetric_dvar_matrix & B);
8112  friend dvariable norm2(const banded_symmetric_dvar_matrix & B);
8113  friend dvariable sumsq(const banded_symmetric_dvar_matrix & B);
8114 };
8115 
8121 {
8122  int bw;
8124  public:
8125  void initialize(void);
8126  void shift(int);
8127  int bandwidth(void) const
8128  {
8129  return bw;
8130  }
8131  int indexmin(void) const
8132  {
8133  return d(0).indexmin();
8134  }
8135  int indexmax(void) const
8136  {
8137  return d(0).indexmax();
8138  }
8139  int rowmin(void) const
8140  {
8141  return d.rowmin();
8142  }
8143  int rowmax(void) const
8144  {
8145  return d.rowmax();
8146  }
8147 
8148  void save_dmatrix_value(void) const;
8149  void save_dmatrix_position(void) const;
8151  banded_lower_triangular_dmatrix(int _min, int _max, int _bw);
8155  void save_dmatrix_derivatives(const dvar_matrix_position &) const;
8158  const dvar_matrix_position& mpos);
8159 #if defined(OPT_LIB)
8160  inline double& operator()(int i, int j)
8161  {
8162  return (*((d.m[i - j]).v + i));
8163  }
8164  inline dvector operator()(int i)
8165  {
8166  return (d.m[i]);
8167  }
8168  inline const double& operator()(int i, int j) const
8169  {
8170  return (*((d.m[i - j]).v + i));
8171  }
8172  inline const dvector operator()(int i) const
8173  {
8174  return (d.m[i]);
8175  }
8176 #else
8177  double &operator () (int i, int j);
8178  dvector operator () (int i);
8179  const double &operator() (int i, int j) const;
8180  const dvector operator() (int i) const;
8181 #endif
8184 };
8185 
8191 {
8192 public:
8193  int bw;
8195  int bandwidth(void) const
8196  {
8197  return bw;
8198  }
8199  int indexmin(void) const
8200  {
8201  return d(0).indexmin();
8202  }
8203  int indexmax(void) const
8204  {
8205  return d(0).indexmax();
8206  }
8207  int rowmin(void) const
8208  {
8209  return d.rowmin();
8210  }
8211  int rowmax(void) const
8212  {
8213  return d.rowmax();
8214  }
8215  void initialize(void);
8216  void save_dvar_matrix_value() const;
8217  void save_dvar_matrix_position() const;
8218 
8219  banded_lower_triangular_dvar_matrix(int _min, int _max, int _bw);
8222 
8223 #if defined(OPT_LIB)
8224  inline prevariable operator()(int i, int j)
8225  {
8226  return ((d.m[i - j]).va + i);
8227  }
8228  inline dvar_vector operator()(int i)
8229  {
8230  return (d.m[i]);
8231  }
8232  inline const prevariable operator()(int i, int j) const
8233  {
8234  return ((d.m[i - j]).va + i);
8235  }
8236  inline const dvar_vector operator()(int i) const
8237  {
8238  return (d.m[i]);
8239  }
8240 #else
8241  prevariable operator () (int i, int j);
8242  dvar_vector operator () (int i);
8243  const prevariable operator() (int i, int j) const;
8244  const dvar_vector operator() (int i) const;
8245 #endif
8246  inline double& elem_value(int i, int j)
8247  {
8248  return *(double *) ((d.m[i - j]).va + i);
8249  }
8250  inline const double& elem_value(int i, int j) const
8251  {
8252  return *(double *) ((d.m[i - j]).va + i);
8253  }
8254 };
8255 
8256 ostream & operator<<(const ostream & ofs,
8257  const banded_symmetric_dmatrix & S);
8258 ostream & operator<<(const ostream & ofs,
8259  const banded_symmetric_dvar_matrix & S);
8260 ostream & operator<<(const ostream & ofs,
8262 ostream & operator<<(const ostream & ofs,
8264 
8265 // check to see how this is transposed before using
8266 dmatrix solve(const banded_symmetric_dmatrix & m, const dmatrix & M);
8267 dmatrix solve(const dmatrix & m, const dmatrix & M);
8268 dvector solve(const banded_symmetric_dmatrix & m, const dvector & v);
8269 
8271  const banded_symmetric_dmatrix& S,
8272  int& ierr
8273 );
8274 
8276  (const banded_symmetric_dvar_matrix & S, double eps, dvariable & fpen);
8277 
8280  int &ierr
8281 );
8282 double ln_det_choleski(
8283  const banded_symmetric_dmatrix& S,
8284  int& ierr
8285 );
8288  int &ierr
8289 );
8290 
8293  (const dvar_matrix_position & pos);
8294 
8297  (const dvar_matrix_position & pos);
8298 
8300  (const dvar_matrix_position & pos);
8301 
8302 unsigned long max(unsigned long u, unsigned long v);
8303 unsigned long min(unsigned long u, unsigned long v);
8304 double max(const double u, const double v);
8305 double min(const double u, const double v);
8306 int max(int i, int j, int k);
8307 int max(int i, int j);
8308 
8310  const dvar_vector & v);
8311 
8313  int &ierr);
8314 
8316  const dvector & v);
8318  const dvector & v);
8319 int admax(int i, int j);
8320 
8321 dmatrix diagonal_matrix(const dvector & v);
8323 dvector diagonal(const dmatrix &);
8324 ivector diagonal(const imatrix &);
8326 
8327 double gammln(double xx);
8328 //dvariable gammln(const dvariable& xx);
8329 dvariable gammln(const prevariable& xx);
8330 ivector histogram(double min, double max, int nbin, const dvector& input);
8331 
8332 double cumd_cauchy(const double &x);
8333 double density_cauchy(const double &x);
8334 double log_density_cauchy(const double &x);
8335 double inv_cumd_cauchy(const double &x);
8337 dvariable cumd_cauchy(const prevariable & x);
8339 
8340 double log_negbinomial_density(double x, double mu, double tau);
8341 
8342 dvariable log_negbinomial_density(double x, const prevariable & mu,
8343  const prevariable & tau);
8344 
8345 dvariable log_density_poisson(double x, const prevariable & mu);
8346 double log_density_poisson(double x, double mu);
8347 
8348 //double negbinomial_density(double x,double r, double mu);
8349 
8355 {
8357  public:
8359  {
8360  ptr = (dvector *) (&v);
8361  }
8362  friend ostream & operator<<(const ostream &, const pre_column_print &);
8363 };
8364 
8370 {
8372  public:
8374  {
8375  ptr = (dvector *) (&v);
8376  }
8377  friend ostream & operator<<(const ostream &, const pre_zero_print &);
8378 };
8379 
8380 ostream & operator<<(const ostream &, const pre_column_print &);
8381 ostream & operator<<(const ostream &, const pre_zero_print &);
8382 
8384 pre_zero_print zero_print(const dvector & v);
8385 
8386 dvector VEC(const dmatrix &);
8387 dmatrix MAT(const dvector &, int i, int j);
8388 
8389 dvar_vector VEC(const dvar_matrix &);
8390 dvar_matrix MAT(const dvar_vector &, int i, int j);
8391 
8392 dmatrix operator-(const dmatrix & m);
8393 dvar_matrix operator-(const dvar_matrix & m);
8394 
8395 ivector sgn(const dvector &);
8396 ivector sgn(const dvar_vector &);
8397 
8398 int allocated(const ivector & v);
8399 int allocated(const lvector & v);
8400 int allocated(const dvector & v);
8401 int allocated(const dvar_vector & v);
8402 
8403 int allocated(const imatrix & v);
8404 int allocated(const dmatrix & v);
8405 int allocated(const dvar_matrix & v);
8406 
8407 int allocated(const i3_array & v);
8408 int allocated(const d3_array & v);
8409 int allocated(const dvar3_array & v);
8410 
8411 int allocated(const i4_array & v);
8412 int allocated(const d4_array & v);
8413 int allocated(const dvar4_array & v);
8414 
8415 int allocated(const i5_array& iarr5);
8416 int allocated(const d5_array & v);
8417 int allocated(const dvar5_array & v);
8418 
8419 int allocated(const d6_array & v);
8420 int allocated(const dvar6_array & v);
8421 
8422 int allocated(const d7_array & v);
8423 int allocated(const dvar7_array & v);
8424 
8426  dvariable & fpen);
8427 
8430  const imatrix & missflags);
8431 
8432 void gauss_hermite(const dvector & _x, const dvector & _w);
8433 void normalized_gauss_hermite(const dvector & _x, const dvector & _w);
8434 void gauss_legendre(double x1, double x2, const dvector & _x,
8435  const dvector & _w);
8436 void gauss_legendre(const dvector & _x, const dvector & _w);
8437 
8438 //dvariable beta(const prevariable&,const prevariable&);
8439 
8440 double betacf(const double a, const double b, double x, int maxit = 100);
8441 dvariable betacf(const dvariable& a, const dvariable& b, const dvariable& x, int maxit = 100);
8442 
8443 dvariable betai(const dvariable a, const dvariable b, const dvariable x, int maxit = 100);
8444 double betai(const double a,const double b,const double x, int maxit=100);
8445 dvariable pbeta( const dvariable x, const dvariable a, const dvariable b, int maxit = 100);
8446 double pbeta(const double x, const double a,const double b, int maxit=100);
8447 
8448 dvariable besselI(dvariable x, int nu);
8449 dvariable besselK(dvariable x, int nu);
8450 dvariable besselJ(dvariable x, int nu);
8451 dvariable besselY(dvariable x, int nu);
8452 
8453 double besselI(double x, int nu);
8454 double besselK(double x, int nu);
8455 double besselJ(double x, int nu);
8456 double besselY(double x, int nu);
8457 
8458 /*
8459 double betai(double _aa, double _bb, double _xx);
8460 dvariable betai(const dvariable & _a, const dvariable & _b,
8461  const dvariable & _x);
8462 double incbet(const double a, const double b, const double x);
8463 dvariable incbet(const dvariable & _a, const dvariable & _b,
8464  const dvariable & _x);
8465 
8466 df1_three_variable incbet(const df1_three_variable & _aa,
8467  const df1_three_variable & _bb, const df1_three_variable & _xx);
8468 */
8469 
8470 dvar_matrix tensor_prod(const dvar_matrix & a, const dvar_matrix & b);
8471 
8472 extern "C" void exit_handler(int k);
8473 
8474 class double_index_guts;
8475 class double_index_type;
8476 class double_number_index;
8477 class double_vector_index;
8478 class double_matrix_index;
8479 class double_i3_index;
8480 
8486 {
8488  int i;
8489  public:
8490  pre_double_index_type(const double_index_type * _a, int _i):a(_a), i(_i)
8491  {
8492  }
8493  friend class double_index_type;
8494 };
8495 
8500 {
8501 protected:
8502  double d;
8503 public:
8504  ad_double() = delete;
8505 
8506  operator double () const
8507  {
8508  return d;
8509  }
8510  ad_double(const double& _d, const adkludge&): d(_d)
8511  {
8512  }
8513  ad_double(double _d):d(_d)
8514  {
8515  }
8516  ad_double(const ad_double& other): ad_double(double(other))
8517  {
8518  }
8519 
8520  ad_double(const double_index_type& it);
8521  static ad_double make_ad_double(double _d)
8522  {
8523  adkludge adk;
8524  //??Should parameter be d or _d?
8525  return ad_double(_d, adk);
8526  }
8527  ad_double& operator=(const ad_double&) = delete;
8528 };
8529 
8535 {
8536  friend class ad_double;
8537  protected:
8538  int *ncopies;
8539  public:
8540  virtual double_index_guts * operator [] (int) = 0;
8541  virtual int isdouble(void) const
8542  {
8543  return 1;
8544  }
8545  virtual operator double ()
8546  {
8547  cerr << "Error in double_index_type"
8548  " -- object not dereferenced enough" << endl;
8549  ad_exit(1);
8550  return 1;
8551  }
8552  virtual int indexmin(void) = 0;
8553  virtual int indexmax(void) = 0;
8556  virtual ~ double_index_guts();
8557  friend class double_index_type;
8558 };
8559 
8565 {
8567  public:
8568  double ddouble(void) const;
8569  int isdouble(void) const
8570  {
8571  return p->isdouble();
8572  }
8573  double_index_type(double x);
8574  //index_type(const data_int& x);
8575  double_index_type(const dvector & x);
8576  double_index_type(const dmatrix & x);
8577  double_index_type(const d3_array & x);
8579  double_index_type(const double_index_type & pit);
8580  //index_type (i4_array& x) { p = new i4_index(x);}
8584  double_index_type operator [] (int i) const;
8585  double_index_type operator () (int i) const;
8586  int indexmin(void) const
8587  {
8588  return p->indexmin();
8589  }
8590  int indexmax(void) const
8591  {
8592  return p->indexmax();
8593  }
8594  friend class ad_integer;
8595 };
8596 
8602 {
8603  private:
8604  virtual int isdouble_(void) const
8605  {
8606  return 0;
8607  }
8608  virtual double_index_guts *operator [] (int i);
8609  virtual int indexmin(void)
8610  {
8611  return 1;
8612  }
8613  virtual int indexmax(void)
8614  {
8615  return 1;
8616  }
8617  public:
8618  virtual ~ double_index()
8619  {
8620  }
8622  {
8623  }
8624  // only overload this for number_index ... will fail for other classes
8625  virtual operator double ()
8626  {
8627  return d;
8628  }
8629  friend class double_index_type;
8630 };
8631 
8637 {
8639  {
8640  return new double_index(dvector::operator [](i));
8641  }
8642  public:
8643  //vector_index(const ivector& v) : ivector(v){}
8644  dvector_index(const dvector & v);
8645  virtual ~ dvector_index();
8646  virtual int indexmin(void)
8647  {
8648  return dvector::indexmin();
8649  }
8650  virtual int indexmax(void)
8651  {
8652  return dvector::indexmax();
8653  }
8654  friend class double_index_type;
8655 };
8656 
8662 {
8663  private:
8664  virtual double_index_guts * operator [] (int i);
8665  //{
8666  //return new dvector_index(dmatrix::operator [](i));
8667  //}
8668  public:
8669  virtual ~ dmatrix_index();
8671  {
8672  }
8673  virtual int indexmin(void)
8674  {
8675  return dmatrix::rowmin();
8676  }
8677  virtual int indexmax(void)
8678  {
8679  return dmatrix::rowmax();
8680  }
8681  friend class double_index_type;
8682 };
8683 
8689 {
8691  {
8692  return new dmatrix_index(d3_array::operator [](i));
8693  }
8694  public:
8696  {
8697  }
8698  virtual int indexmin(void)
8699  {
8700  return d3_array::slicemin();
8701  }
8702  virtual int indexmax(void)
8703  {
8704  return d3_array::slicemax();
8705  }
8706  friend class index_type;
8707 };
8708 
8709 dvariable mf_upper_bound(const prevariable & x, double M, prevariable & fpen);
8710 double mf_upper_bound(const double &x, double M, prevariable & fpen);
8711 
8712 int operator==(double v0, const prevariable & v1);
8713 int operator<=(double v0, const prevariable & v1);
8714 int operator>=(double v0, const prevariable & v1);
8715 int operator>(double v0, const prevariable & v1);
8716 int operator<(double v0, const prevariable & v1);
8717 int operator!=(double v0, const prevariable & v1);
8718 
8720  const prevariable & rho, int nbox);
8721 
8722 dvariable cumbvn(const dvariable& x, const dvariable& y, const dvariable& rho);
8723 
8724 dvariable cumbvn(const dvariable & xl, const dvariable & yl,
8725  const dvariable & xu, const dvariable & yu, const dvariable & rho);
8726 
8727 double ghk(const dvector & lower, const dvector & upper,
8728  const dmatrix & Sigma, const dmatrix & eps);
8729 
8730 double ghk_choleski(const dvector & lower, const dvector & upper,
8731  const dmatrix & ch, const dmatrix & eps);
8732 
8733 dvariable ghk_choleski_m(const dvar_vector & upper,
8734  const dvar_matrix & ch, const dmatrix & eps);
8735 
8736 double ghk(const dvector & lower, const dvector & upper,
8737  const dmatrix & Sigma, const dmatrix & eps, int i);
8738 
8739 dvariable ghk(const dvar_vector & lower, const dvar_vector & upper,
8740  const dvar_matrix & Sigma, const dmatrix & eps);
8741 
8742 dvariable ghk(const dvar_vector & lower, const dvar_vector & upper,
8743  const dvar_matrix & Sigma, const dmatrix & eps, int i);
8744 
8746  const dvar_matrix & ch, const dmatrix & eps);
8747 
8749  const dvar_matrix & ch, const dmatrix & eps);
8750 
8756 {
8757  public:
8759  {
8760  }
8761 };
8762 
8763 void tracing_message(int traceflag, const char *s);
8764 void tracing_message(int traceflag, const char *s, int *pn);
8765 void tracing_message(int traceflag, const char *s, double *pd);
8766 void tracing_message(int traceflag, const char *s, double d);
8767 
8768 int sub_unallocated(const dvar_vector&);
8769 int sub_unallocated(const dvar_matrix&);
8770 int sub_unallocated(const dvar3_array&);
8771 int sub_unallocated(const dvar4_array&);
8772 int sub_unallocated(const dvar5_array&);
8773 int sub_unallocated(const dvector&);
8774 int sub_unallocated(const dmatrix&);
8775 int sub_unallocated(const d3_array&);
8776 int sub_unallocated(const d4_array&);
8777 int sub_unallocated(const d5_array&);
8778 int sub_unallocated(const ivector&);
8779 int sub_unallocated(const imatrix&);
8780 int sub_unallocated(const i3_array&);
8781 int sub_unallocated(const i4_array&);
8782 int sub_unallocated(const i5_array&);
8783 
8784 void check_derivative_values(const char *s);
8785 void check_derivative_values(const char *s, int i);
8786 void check_derivative_values_break(const char *s, int i, int b);
8787 void df_check_derivative_values(void);
8790 extern int ad_kill_flag;
8791 void reset_gradient_stack(void);
8792 
8793 #define AD_SET_DERIVATIVES1(depvar,indvar,df) \
8794  gradient_structure::GRAD_STACK1->set_gradient_stack2(default_evaluation2,\
8795  &(value(depvar)), &(value(indvar)),df);
8796 
8797 #define AD_SET_DERIVATIVES2(depvar,indvar1,df1,indvar2,df2) \
8798  gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation3,\
8799  &(value(depvar)), &(value(indvar1)),df1,&(value(indvar2)),df2);
8800 
8801 #define AD_SET_DERIVATIVES3(depvar,indvar1,df1,indvar2,df2,indvar3,df3) \
8802  gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation3ind,\
8803  &(value(depvar)), &(value(indvar1)),df1,&(value(indvar2)),df2, \
8804  &(value(indvar3)),df3);
8805 
8806 #define AD_SET_DERIVATIVES4(depvar,indvar1,df1,indvar2,df2,indvar3,df3, \
8807  indvar4, df4) \
8808  gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation4ind,\
8809  &(value(depvar)), &(value(indvar1)),df1,&(value(indvar2)),df2, \
8810  &(value(indvar3)),df3, \
8811  &(value(indvar4)),df4);
8812 
8813 #define ADJOINT_CODE(x) \
8814  gradient_structure::GRAD_STACK1->set_gradient_stack(x);
8815 
8816 int make_sub_directory(const char *s);
8817 #include <adstring.hpp>
8819 #if defined(USE_ADPVM)
8820 class adpvm_manager;
8821 #endif
8822 class adtimer;
8823 
8828 class ad_comm
8829 {
8830 protected:
8831  ad_comm();
8832  ad_comm(int argc, char *argv[]);
8833  virtual ~ad_comm();
8834 
8835  void allocate();
8836  public:
8837  static int bandwidth;
8839  static int no_pvm_flag;
8840  static int no_atlas_flag;
8842 #ifdef DIAG_TIMER
8843  static int time_flag;
8844  static adtimer *ptm;
8845  static adtimer *ptm1;
8846 #endif
8847 #if defined(USE_ADPVM)
8848  virtual void get_slave_assignments(void);
8849  static adpvm_manager *pvm_manager;
8850 #endif
8852  static streampos change_datafile_name(const adstring & s,
8853  const streampos & off = 0);
8854  static streampos change_pinfile_name(const adstring & s,
8855  const streampos & off = 0);
8858  static ofstream *global_logfile;
8862  static char option_flags[];
8863  static int argc;
8864  static unsigned int wd_flag;
8865  static unsigned char directory_prefix;
8866  static char **argv;
8867 };
8868 
8869 int option_match(int argc, char *argv[], const char *string);
8870 int option_match(int argc, char *argv[], const char *string, int& nopt);
8871 int option_match(char *s, const char *string, int& nopt);
8872 int option_match(char *s, const char *string);
8873 int ad_chdir(const char *s);
8874 void ad_getcd(const adstring & s);
8875 void grad_chk(void);
8876 void send_dv3_to_master(const dvar3_array & v);
8877 
8878 inline dvariable inv(const prevariable & x)
8879 {
8880  return 1.0 / x;
8881 }
8882 
8883 double gamma_density(double _x, double r, double mu);
8884 dvariable gamma_density(const prevariable & _x, double r, double mu);
8885 dvariable gamma_density(const dvariable & _x, const dvariable & _r,
8886  const dvariable & _mu);
8887 
8888 double log_gamma_density(double _x, double r, double mu);
8889 dvariable log_gamma_density(const prevariable & _x, double r, double mu);
8890 dvariable log_gamma_density(const dvariable & _x, const dvariable & _r,
8891  const dvariable & _mu);
8892 
8893 #if !defined(_WIN32)
8894 #include <sys/time.h>
8895 #include <iostream>
8896 
8901 class adtimer
8902 {
8903  timeval tv;
8904  timeval tvold;
8905  public:
8906  double get_elapsed_time_and_reset(void);// return time in milliseconds;
8907  double get_elapsed_time(void);// return time in milliseconds;
8908  adtimer(void);
8909 };
8910 
8911 #else
8912 #include <windows.h>
8913 
8918 class adtimer
8919 {
8920 #ifdef _MSC_VER
8921  unsigned long long t;
8922  unsigned long long told;
8923 #else
8924  DWORD t;
8925  DWORD told;
8926 #endif
8927 public:
8928  adtimer();
8929 
8930  // return time in milliseconds;
8931  double get_elapsed_time_and_reset();
8932  // return time in milliseconds;
8933  double get_elapsed_time();
8934 };
8935 
8936 #endif
8937 #if defined(max)
8938 #undef max
8939 #endif
8940 #if defined(min)
8941 #undef min
8942 #endif
8943 
8944 // M is a postiive definite symmetric matrix
8946 dvariable ln_det_choleski_error(const dvar_matrix &, int &ierr);
8947 
8948 // the autodif wrapper to the ATLAS routines
8949 
8950 // M is a postiive definite symmetric matrix
8951 dvector atlas_solve_spd(const dmatrix & M, const dvector & x);
8952 dvector atlas_solve_spd(const dmatrix & M, const dvector & x, int &ierr);
8953 dmatrix atlas_solve_spd(const dmatrix & M, const dmatrix & x);
8954 dmatrix atlas_solve_spd_trans(const dmatrix & M, const dmatrix & x);
8955 
8961 {
8962  public:
8963  lower_triangular_dmatrix(int, int);
8964 };
8966 dvector solve(const lower_triangular_dmatrix & M, const dvector & v);
8967 dvector lower_triangular_solve(const dmatrix & M, const dvector & v);
8972 
8974  (const dmatrix & MM, const int &_ierr);
8975 
8977  const dvector & y);
8978 
8979 inline int admax(int i, int j)
8980 {
8981  if (i > j)
8982  return i;
8983  else
8984  return j;
8985 }
8986 
8987 inline int admin(int i, int j)
8988 {
8989  if (i > j)
8990  return j;
8991  else
8992  return i;
8993 }
8994 
8995 d4_array orthpoly2(int n, int m, int d1, int d2);
8996 double dot(const dmatrix & M, const dmatrix & d2);
8997 
8998 double norm(const banded_symmetric_dmatrix & B);
8999 double norm2(const banded_symmetric_dmatrix & B);
9000 double sumsq(const banded_symmetric_dmatrix & B);
9004 
9005 double lower_triangular_ln_det(const dmatrix & m);
9006 double lower_triangular_ln_det(const dmatrix & m, int &sgn);
9007 
9010 double bounder(double x, double min, double max, double scale);
9011 dvariable bounder(const prevariable & x, double min, double max, double scale);
9012 dmatrix inv(const dmatrix & m1, const double &_ln_det, const int &_sgn);
9013 
9014 double gamma_deviate(double _x, double _a);
9015 dvariable gamma_deviate(const prevariable & _x, const prevariable & _a);
9016 void ad_set_new_handler(void);
9017 
9018 dvariable inv_cumd_gamma(const prevariable & _y, const prevariable & _a);
9019 double inv_cumd_gamma(double _y, double _a);
9020 extern int just_to_link_fvar1;
9021 
9022 dvector inv_cumd_pareto(const dvector & _y, double alpha, double xm);
9023 
9024 dvector cumd_upper_trunc_pareto(const dvector & _y, double alpha, double xm);
9025 
9026 dvector cumd_pareto(const dvector & _y, double alpha, double xm);
9027 
9028 dvector inv_cumd_upper_trunc_pareto(const dvector & _y, double alpha,
9029  double xmin, double xmax);
9030 
9032  const prevariable & alpha, const prevariable & xmin, const prevariable& xmax);
9033 
9034 dvar_vector inv_cumd_pareto(const dvar_vector & _y, const prevariable & alpha,
9035  const prevariable & xm);
9036 
9038  const prevariable & alpha, const prevariable & xm);
9039 
9040 dvar_vector ln_pareto_density(const dvar_vector & _y, const prevariable & alpha,
9041  const prevariable & xm);
9042 
9044  const prevariable & alpha, const prevariable& xmin, const prevariable& xmax);
9045 
9046 dvar_vector pareto_density(const dvar_vector & _y, const prevariable & alpha,
9047  const prevariable & xm);
9048 
9050  const prevariable & alpha, const prevariable & xmin, const prevariable& xmax);
9051 
9052 dvariable ln_pareto_density(const prevariable & _y, const prevariable & alpha,
9053  const prevariable & xm);
9054 
9055 dvariable pareto_density(const prevariable & _y, const prevariable & alpha,
9056  const prevariable & xm);
9057 
9058 dvar_vector cumd_pareto(const dvar_vector & _y, const prevariable & alpha,
9059  const prevariable & xm);
9060 
9062  const prevariable & alpha, const prevariable & xmin, const prevariable& xmax);
9063 
9064 dvariable inv_cumd_pareto(const prevariable& _y, const prevariable& alpha,
9065  const prevariable & xm);
9066 
9068  const prevariable& alpha, const prevariable& xmin, const prevariable& xmax);
9069 
9070 dvariable cumd_pareto(const prevariable & _y, const prevariable & alpha,
9071  const prevariable & xm);
9072 
9073 dvariable inv_cumd_pareto(const prevariable & _y, const prevariable & alpha,
9074  const prevariable & xm);
9075 
9076 dvariable cumd_pareto(const prevariable & _y, const prevariable & alpha,
9077  const prevariable & xm);
9078 
9079 double inv_cumd_upper_trunc_pareto(double _y, double alpha, double xmin,
9080  double xmax);
9081 
9082 double inv_cumd_pareto(double _y, double alpha, double xm);
9083 
9084 double cumd_pareto(double _y, double alpha, double xm);
9085 
9086 double robust_normal_logistic_mixture_deviate(double x, double spread = 3.0);
9087 double robust_normal_mixture_deviate(double x, double spread = 3.0);
9089  double spread = 3.0);
9090 
9092 dvector lower_triagular_solve(const dmatrix & m, const dvector & v);
9093 dvector choleski_solve_error(dmatrix M, dvector & v, int &ierror);
9095 
9096 dvariable cumd_gamma(const dvariable & x, const dvariable & a);
9097 double cumd_gamma(double x, double a);
9098 
9099 dvariable cumd_normal_cauchy_mixture(const prevariable & _x, double _a);
9100 dvar_vector cumd_normal_cauchy_mixture(const dvar_vector & _x, double _a);
9101 
9102 dvariable cumd_normal_mixture(const prevariable & _x, double _a);
9103 dvar_vector cumd_normal_mixture(const dvar_vector & _x, double _a);
9104 
9105 dvariable inv_cumd_normal_mixture(const prevariable & _x, double _a);
9107 
9108 double inv_cumd_normal_mixture(double _x, double _a);
9109 double inv_cumd_normal_logistic_mixture(double _x, double _a);
9110 
9111 double inv_cumd_t(double n, double y, double eps = 1.e-7);
9112 
9113 dvariable inv_cumd_t(const prevariable & n, const prevariable & y,
9114  double eps = 1.e-7);
9115 
9116 double old_inv_cumd_beta_stable(double a, double b, double y, double eps = 1.e-7);
9117 double inv_cumd_beta_stable(double a, double b, double y, double eps = 0);
9118 dvariable inv_cumd_beta_stable(const prevariable & _a, const prevariable & _b, const prevariable & _y, double eps = 0);
9119 
9120 double qbeta(double x, double a, double b, double eps = 0);
9121 dvariable qbeta(dvariable x, dvariable a, dvariable b, double eps = 0);
9122 
9123 dvariable norm_to_gamma(const prevariable & v, const prevariable & alpha,
9124  double bound = 0.999999);
9125 
9126 double norm_to_gamma(double v, double alpha, double bound = 0.999999);
9127 
9129  const dvector & e);
9131 dvector get_eigen_values(const dvector & _d, const dvector & _e);
9133  const dvar_vector & _e);
9134 dvector get_eigen_values(const dvector & _d, const dvector & _e,
9135  const dmatrix & _z);
9136 
9137 dvariable beta_deviate(const prevariable & _x, const prevariable & _a,
9138  const prevariable & _b, double eps = 1.e-7);
9139 double beta_deviate(double x, double a, double b, double eps = 1.e-7);
9140 
9141 #ifdef __cplusplus
9142 extern "C"
9143 {
9144 #endif
9145 //#include <f2c.h>
9146 int smbfct_(int *neqns, ivector & xadj, ivector & adjncy, ivector & perm,
9147  ivector & invp, ivector & xlnz, int *maxlnz, ivector & xnzsub,
9148  ivector & nzsub, int *maxsub, ivector & rchlnk, ivector & mrglnk,
9149  ivector & marker, int *flag__);
9150 
9151 // int smbfct_(int *neqns, int *xadj, int *adjncy,
9152 // int *perm, int *invp, int *xlnz, int *maxlnz, int
9153 // *xnzsub, int *nzsub, int *maxsub, int *rchlnk, int *
9154 // mrglnk, int *marker, int *flag__);
9155 #ifdef __cplusplus
9156 }
9157 #endif
9158 
9159 dmatrix orthpoly_constant_begin(int n, int deg, int nconst);
9160 dmatrix orthpoly_constant_begin_end(int n, int deg, int nconst_begin,
9161  int enddeg, int nconst_end);
9162 #if defined(USE_DD)
9163 # include <ddfvar.hpp>
9164 # include <qdfvar.hpp>
9165 #endif
9166 
9167 #ifdef DIAG
9168 void test_the_pointer(void);
9169 #endif
9170 
9171 // stuff for debugging the grad stack
9172 void set_gradstack_flag(char *str, int i, int j);
9173 void set_gradstack_flag(char *str);
9174 void report_gradstack_flag(void);
9175 
9176 dvariable log_der_logistic(double a, double b, const prevariable & x);
9177 double logistic(double a, double b, const double &x);
9178 double dflogistic(double a, double b, const double &x);
9179 dvariable logistic(double a, double b, const prevariable & x);
9180 dvariable dflogistic(double a, double b, const prevariable & x);
9181 double log_density_negbinomial(double x, double mu, double tau);
9182 
9188 {
9192  public:
9194  {
9195  };
9196  sing_val_decomp(const dmatrix & _a, const dvector & _w, const dmatrix & _v);
9198  {
9199  return a;
9200  }
9202  {
9203  return w;
9204  }
9206  {
9207  return v;
9208  }
9209 };
9210 
9213  const banded_symmetric_dmatrix& _M, const int &_ierr);
9214 
9215 dvariable avg(const prevariable & x, const prevariable & y);
9216 double avg(double x, double y);
9217 
9223 {
9224  int mind;
9225  int maxd;
9226  int depth;
9228  public:
9229  multi_index(int min, int max, int dim);
9231  {
9232  return index;
9233  }
9234  void operator ++(void);
9235  int get_depth(void)
9236  {
9237  return depth;
9238  }
9239  int get_offset(void);
9240  void initialize();
9241 };
9242 
9243 inline void ADMB_getcallindex(int)
9244 {
9245 }
9246 
9247 inline void ADMB_getcallindex(double)
9248 {
9249 }
9250 
9251 inline void ADMB_getcallindex(const dvector&)
9252 {
9253 }
9254 
9255 inline void ADMB_getcallindex(const dmatrix&)
9256 {
9257 }
9258 
9259 inline void ADMB_getcallindex(const d3_array&)
9260 {
9261 }
9262 
9263 inline void ADMB_getcallindex(const d4_array&)
9264 {
9265 }
9266 
9267 inline void ADMB_getcallindex(const prevariable&)
9268 {
9269 }
9270 
9271 inline void ADMB_getcallindex(const dvar_vector&)
9272 {
9273 }
9274 
9275 inline void ADMB_getcallindex(const dvar_matrix&)
9276 {
9277 }
9278 
9279 inline void ADMB_getcallindex(const dvar3_array&)
9280 {
9281 }
9282 
9284 {
9285 }
9286 
9287 void clean(ivector & v, int level);
9288 
9294 {
9295  int n;
9296  int m;
9299  public:
9300  int indexmin(void)
9301  {
9302  return x.indexmin();
9303  }
9304  int indexmax(void)
9305  {
9306  return x.indexmax();
9307  }
9309  {
9310  return x[i];
9311  }
9313  {
9314  return x(i);
9315  }
9316  int &operator () (int i, int j)
9317  {
9318  return coords(i, j);
9319  }
9320  dvar_compressed_triplet(int mmin, int mmax, int n, int m);
9321  void allocate(int mmin, int mmax, int n, int m);
9322  void deallocate(void);
9324  {
9325  return coords;
9326  }
9328  {
9329  return x;
9330  }
9331  int get_n()
9332  {
9333  return n;
9334  }
9335  int get_m()
9336  {
9337  return m;
9338  }
9339 };
9340 
9346 {
9347  // number of rows
9348  int n;
9349  // number of columns
9350  int m;
9353  public:
9354  int indexmin(void)
9355  {
9356  return x.indexmin();
9357  }
9358  int indexmax(void)
9359  {
9360  return x.indexmax();
9361  }
9362  double &operator [] (int i)
9363  {
9364  return x[i];
9365  }
9366  double &operator () (int i)
9367  {
9368  return x(i);
9369  }
9370  int &operator () (int i, int j)
9371  {
9372  return coords(i, j);
9373  }
9374  dcompressed_triplet(int mmin, int mmax, int n, int m);
9375  //dcompressed_triplet make_dcompressed_triplet(const dmatrix & );
9376  void allocate(int mmin, int mmax, int n, int m);
9377  void deallocate(void);
9379  {
9380  return coords;
9381  }
9382  dvector & get_x(void)
9383  {
9384  return x;
9385  }
9386  int get_n()
9387  {
9388  return n;
9389  }
9390  int get_m()
9391  {
9392  return m;
9393  }
9394  void initialize(void);
9395 };
9396 
9397  /*
9398  ostream& operator << (const ostream&,const dcompressed_triplet& );
9399  istream& operator >> (const istream&,const dcompressed_triplet& );
9400  ostream& operator << (const ostream&,const dvar_compressed_triplet& );
9401  istream& operator >> (const istream&,const dvar_compressed_triplet& );
9402  */
9403 
9404 typedef struct cs_symbolic css;
9405 
9410 class hs_symbolic // Info for symbolic cholesky
9411 {
9412  public:
9413  // Dimension of underlying pos. def. matrix
9414  int n;
9415  // Dimension of underlying pos. def. matrix
9416  int m;
9417  // inverse row perm. for QR, fill red. perm for Chol
9419  // elimination tree for Cholesky and QR
9421  // column pointers for Cholesky, row counts for QR
9423  // # entries in L for LU or Cholesky; in V for QR
9424  double lnz;
9425  hs_symbolic(int, css *);
9426  hs_symbolic(int n, dmatrix & T, int order);
9427  hs_symbolic(const dcompressed_triplet & T, int order);
9428 
9429  hs_symbolic(const dvar_compressed_triplet & T, int order);
9430  int is_null();
9431  int cmp(hs_symbolic & S);
9432  hs_symbolic(void);
9433 };
9434 
9435 class hs_smatrix;
9436 class dvar_hs_smatrix;
9437 
9438 
9440 
9441 dvector return_choleski_factor_solve(hs_smatrix * PL, dvector & eps);
9442 
9443 dvar_vector return_choleski_factor_solve(dvar_hs_smatrix * PL,
9444  dvector & eps);
9445 
9447  dvector & eps);
9448 
9449 dvar_hs_smatrix *return_choleski_decomp(dvar_compressed_triplet & st);
9450 
9451 int allocated(const dcompressed_triplet & t);
9452 int allocated(const dvar_compressed_triplet & t);
9453 
9454 dvector solve(const dcompressed_triplet &, const dmatrix &,
9455  const dvector &);
9456 dvector solve(const dcompressed_triplet &, const dvector &,
9457  const hs_symbolic &, int &ierr);
9458 dvector solve(const dcompressed_triplet &, const dvector &,
9459  const hs_symbolic &);
9460 dvector solve(const dcompressed_triplet &, const dmatrix &,
9461  const dvector &, const hs_symbolic &);
9462 double ln_det(const dcompressed_triplet &);
9463 double ln_det(const dcompressed_triplet &, const hs_symbolic &);
9464 double ln_det(const dcompressed_triplet &, int &ierr);
9465 dvariable ln_det(const dvar_compressed_triplet &, int &ierr);
9466 
9467 dvar_vector return_choleski_factor_solve(dvar_hs_smatrix * PL,
9468  dvector & eps);
9469 void save_ad_pointer(void *);
9470 void *restore_ad_pointer(void);
9471 
9473 
9476 
9481 
9483 int norm2(const ivector &);
9484 int sumsq(const ivector & v);
9485 
9486 template <class ... Args>
9487 int ad_printf( FILE* stream, const char* format, Args ... args )
9488 {
9489  return fprintf(stream, format, args...);
9490 }
9491 template <class ... Args>
9492 int ad_printf( const char* format, Args ... args )
9493 {
9494  int result = printf(format, args...);
9495  fflush(stdout);
9496  return result;
9497 }
9498 std::ostream& get_output_stream();
9499 
9500 dvariable dtweedie(const double y, dvariable& mu, dvariable& phi, dvariable& p, const bool use_log);
9501 
9502 namespace defaults
9503 {
9504  const int iprint = 20;
9505  const int output = 1;
9506  const int percentage = 20;
9507  constexpr const int percentage_number = 100 / defaults::percentage;
9508 };
9509 
9510 #endif//#ifndef FVAR_HPP
void allocate(void)
Does NOT allocate, but initializes i5_array members.
Definition: i5arr.cpp:45
void reinitialize(const int seed)
Reinitialize random number seed.
Definition: rngen.cpp:106
static streampos change_pinfile_name(const adstring &s, const streampos &off=0)
Change the global_parfile stream using input_file.
Definition: model17.cpp:53
dvector gbest
Definition: fvar.hpp:3357
d3_index(d3_array &v)
Definition: fvar.hpp:8695
const double & elem(int i, int j, int k, int l, int _m, int _n) const
Definition: fvar.hpp:6750
double operator()(double)
Description not yet available.
Definition: ftweak.cpp:54
index_guts()
Default constructor.
Definition: indextyp.cpp:14
void save_dmatrix_derivatives(const dvar_matrix_position &) const
Description not yet available.
Definition: cmpdif11.cpp:118
int ub
Definition: fvar.hpp:1905
const dvar_vector & elem(int i, int j, int k, int l, int _m, int _n) const
Definition: fvar.hpp:7353
void allocate(void)
Description not yet available.
Definition: d7arr2.cpp:27
int * ncopies
Definition: fvar.hpp:7685
void fmin(const double &f, const dvector &x, const dvector &g)
int indexmax(void) const
Definition: fvar.hpp:8079
Description not yet available.
Definition: fvar.hpp:4883
long int llog
Definition: fvar.hpp:3299
void rowfill(int j, const dvector &v)
Fills dmatrix row at index row with values from vec.
Definition: cranfill.cpp:136
void default_evaluation2(void)
Description not yet available.
Definition: def_eval.cpp:136
void set_gradient_stack4(void(*func)(void), double *dep_addr, double *ind_addr1, double *ind_addr2)
Description not yet available.
Definition: fvar.hpp:1229
double restore_prevariable_derivative(const prevariable_position &_pos)
Description not yet available.
Definition: cmpdif8.cpp:131
void fill_randu(long int &n)
Description not yet available.
Definition: ranfill2.cpp:224
int indexmax(void) const
Definition: fvar.hpp:8590
Description not yet available.
Definition: fvar.hpp:7981
friend prevariable & sqr(const prevariable &t1)
Returns the square of v1.
Definition: fvar_fn1.cpp:119
~dvar5_array()
Destructor.
Definition: f5arr.cpp:110
fmm(int nvar, int disk_save=0)
Description not yet available.
Definition: fmm.cpp:35
dvariable operator()(double u)
Description not yet available.
Definition: vspline.cpp:93
void colfill_seqadd(const int &, double, double)
Fills column of a matrix with a sequence of the form base, base+offset, base+2*offset,...
Definition: ranfill1.cpp:74
int index_min
Definition: fvar.hpp:2822
friend prevariable & tan(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:144
grad_stack(const size_t size)
Definition: fvar.hpp:971
Description not yet available.
Definition: fvar.hpp:1918
dvector xsave
Definition: fvar.hpp:3358
int lin_flag
Definition: fvar.hpp:3657
dvar_vector & elem(int i, int j, int k, int l, int _m, int _n)
Definition: fvar.hpp:7325
int colmax(void) const
Definition: fvar.hpp:4287
Description not yet available.
Definition: fvar.hpp:920
Description not yet available.
Definition: fvar.hpp:1641
Base class for dvariable.
Definition: fvar.hpp:1315
friend prevariable & log(const prevariable &t1)
Description not yet available.
Definition: fvar_fn.cpp:194
friend dmatrix inv(const dmatrix &)
Inverse of a constant matrix by LU decomposition.
Definition: dmat3.cpp:37
void initialize()
Initialize elements in pointer array to null.
Definition: ptr_vec.cpp:154
int colmin(void) const
Definition: fvar.hpp:5925
dvector funval
Definition: fvar.hpp:3295
int slicemax(void)
Definition: fvar.hpp:5575
ivector * m
Definition: imatrix.h:74
d3_array_position(int mmin, int mmax)
Description not yet available.
Definition: cmpdif6.cpp:424
~grad_stack()
Destructor.
Definition: gradstak.cpp:285
double factln(double n)
Log-factorial .
Definition: combc.cpp:38
double_index_type(double x)
Description not yet available.
Definition: doublind.cpp:54
long int nn
Definition: fvar.hpp:4985
double c
Definition: fvar.hpp:5005
double df
Definition: fvar.hpp:4982
dvar_vector operator-()
Description not yet available.
Definition: fvar_a57.cpp:19
void allocate(void)
Does NOT allocate, but initializes empty d3_array.
Definition: d3arr10.cpp:11
i3_array * t
Definition: fvar.hpp:5772
double sigmoid(const double v1)
Returns computed sigmoid value at v1.
Definition: dvar.cpp:31
int curriter
Definition: fvar.hpp:5749
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
Definition: d3arr2a.cpp:73
d3_array sqr(const d3_array &arr3)
Returns d3_array with square values from arr3.
Definition: d3arr2c.cpp:25
void set_gradient_stack1(void(*func)(void), double *dep_addr, double *ind_addr1)
Sets the gradient stack entry for a function or operator with a single independent variable...
Definition: sgradclc.cpp:385
long int np
Definition: fvar.hpp:4985
dvar_vector()
Default constructor.
Definition: fvar_arr.cpp:150
void fill_multinomial(const int &seed, const dvector &p)
Description not yet available.
Definition: dvect11.cpp:83
int row_max
Definition: fvar.hpp:2007
ostream & operator<<(grad_stack)
double z
Definition: fvar.hpp:3351
const d3_array & elem(int i, int j, int k) const
Definition: fvar.hpp:6738
const dmatrix & get_dmatrix(void) const
Definition: fvar.hpp:7986
double * ind_addr1
Pointer to first independent variable.
Definition: fvar.hpp:900
int indexmin() const
Definition: fvar.hpp:580
double ghk(const dvector &lower, const dvector &upper, const dmatrix &Sigma, const dmatrix &eps)
Description not yet available.
Definition: c_ghk.cpp:12
dvar5_array & operator[](int i)
Definition: fvar.hpp:6956
void myheapcheck(char *msg)
Does nothing.
Definition: dvector.cpp:669
int n
Definition: fvar.hpp:5024
double & operator()(int i, int j)
Definition: fvar.hpp:2998
dvector log10(const dvector &vec)
Returns dvector with the common (base-10) logarithm of vec.
Definition: dvect6.cpp:273
int rowmax(void) const
Definition: fvar.hpp:3847
Description not yet available.
Definition: fvar.hpp:8485
void * restore_ad_pointer(void)
Description not yet available.
Definition: cmpdif3.cpp:237
long ialph
Definition: fvar.hpp:3190
void initialize()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d7arr.cpp:13
void initialize(void)
Definition: hs_sparse.cpp:2566
ivector parent
Definition: fvar.hpp:9420
void open(const char *name, int mode=ios::in|ios::binary, int prot=0664)
Description not yet available.
Definition: ufstream.cpp:36
imatrix & get_coords(void)
Definition: fvar.hpp:9323
int indexmax() const
Definition: fvar.hpp:5622
Description not yet available.
Definition: df13fun.h:56
double * v
pointer to the data
Definition: dvector.h:53
dmatrix fillout(const lower_triangular_dmatrix &M)
Description not yet available.
Definition: dmat36.cpp:110
long int iv
Definition: fvar.hpp:3352
void rowfill_randu_ni(const int &i, long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:88
int colmax(void) const
Definition: fvar.hpp:7588
double log_comb(double n, double k)
Log of the binomial coefficent; i.e log of &#39;n choose k&#39;.
Definition: combc.cpp:27
d4_array & operator()(int i, int j)
Definition: fvar.hpp:6762
void save(void)
Save values to file.
Definition: dfsdmat.cpp:316
double restore_prevariable_value(void)
dvar6_array * t
Definition: fvar.hpp:7265
int index_max
Definition: fvar.hpp:525
static adpvm_manager * pvm_manager
Definition: fvar.hpp:8849
i4_array & operator()(int)
Definition: fvar.hpp:6271
dvar_matrix & operator-=(const dvar_matrix &x)
Description not yet available.
Definition: fvar_m11.cpp:77
int indexmax() const
Definition: fvar.hpp:4936
double get_elapsed_time(void)
Returns the elapsed time in milliseconds from the timer object.
Definition: timer.cpp:57
Description not yet available.
Definition: fvar.hpp:8755
int index_min
Definition: fvar.hpp:524
int hslicesize()
Definition: fvar.hpp:5869
void fill_randbi(long int &n, double)
Description not yet available.
Definition: ranfill2.cpp:51
pre_zero_print(const dvector &v)
Definition: fvar.hpp:8373
virtual int indexmin(void)=0
dvector atan2(const dvector &t1, const dvector &t2)
d3_array elem_prod(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements product of a(i, j, k) * b(i, j, k).
Definition: d3arr2a.cpp:92
const d5_array & operator()(int i, int j) const
Definition: fvar.hpp:7186
int operator!(void) const
Definition: fvar.hpp:7293
virtual int indexmax(void)
Definition: fvar.hpp:8650
long int link
Definition: fvar.hpp:3350
void fill_randu_ni(long int &n)
double dfn
Definition: fvar.hpp:3187
void fmmdisp(const dvector &x, const dvector &g, const int &nvar, int scroll_flag, int noprintx)
Description not yet available.
Definition: fmm_disp.cpp:102
void shallow_copy(const i5_array &)
Shallow copy other data structure pointers.
Definition: i5arr.cpp:23
int maxfn
Definition: fvar.hpp:3631
void set_gbuffer_pointers(void)
Description not yet available.
Definition: gradstak.cpp:551
virtual index_guts * operator[](int i)
Definition: indextyp.cpp:531
double_and_int * arr_new(unsigned int sz)
Definition: newdar.cpp:78
void save_dvar_matrix_value() const
Saves the size, address, and value information for a dvar_matrix.
Definition: cmpdif4.cpp:248
void ludcmp_index(const dmatrix &_a, const ivector &_indx, const double &_d)
LU decomposition.
Definition: dmat3.cpp:613
double crit
Definition: fvar.hpp:3184
double inv_cumd_t(double n, double u, double eps)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: cinvcumdt.cpp:11
int hslicesize() const
Definition: fvar.hpp:6222
vector_index(const ivector &v)
Constructor for ivector.
Definition: indextyp.cpp:187
double right_bracket_value
Definition: fvar.hpp:3680
void fill_randcau(const random_number_generator &rng)
Description not yet available.
Definition: drancau.cpp:51
Description not yet available.
Definition: fvar.hpp:3212
const int percentage
Definition: fvar.hpp:9506
long int ifn
Definition: fvar.hpp:4985
dvar4_array & operator=(const d4_array &)
Description not yet available.
Definition: f4arr.cpp:248
double * get_address(const int &i)
Definition: fvar.hpp:1292
dvector lower_triangular_solve(const dmatrix &m, const dvector &v)
Description not yet available.
Definition: dmat37.cpp:170
double gg
Definition: fvar.hpp:3663
double dfn
Definition: fvar.hpp:3686
void ludcmp(const dmatrix &a, const ivector &indx, const double &d)
Lu decomposition of a constant matrix.
Definition: dmat3.cpp:221
void initialize(void)
Description not yet available.
Definition: fvar_m40.cpp:77
int rowmax(void) const
Definition: fvar.hpp:2564
void write_on(const ostream &s) const
Description not yet available.
Definition: lvect_io.cpp:48
virtual index_guts * operator[](int i)
Definition: fvar.hpp:7811
void deallocate(void)
Deallocate dvar6_array memory.
Definition: f6arr.cpp:67
i3_array & operator=(const i3_array &other)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: i3arr8.cpp:13
ivector pinv
Definition: fvar.hpp:9418
dvar_vector & elem(int i)
Definition: fvar.hpp:2507
friend void df_check_derivative_values_indexed(void)
Description not yet available.
Definition: newdar.cpp:427
dvar_matrix & operator--(void)
Definition: fvar.hpp:2488
int colmax(void) const
Definition: fvar.hpp:6218
long int is
Definition: fvar.hpp:4985
d4_array & elem(int i, int j, int k)
Definition: fvar.hpp:7101
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
lvector(void)
Default constructor.
Definition: lvector.cpp:30
int indexmin(void)
Definition: fvar.hpp:9354
double operator()(double u)
Definition: cspline.cpp:19
dvar_vector_position operator()(int i)
Description not yet available.
Definition: cmpdif2.cpp:134
int slicemin() const
Definition: fvar.hpp:4274
int operator!=(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:62
int iv
Definition: fvar.hpp:3302
dvar_vector get_eigen_values(const dvar_vector &_ddd, const dvar_vector &_eee)
Eigenvalues and eigenvectors.
Definition: dveigen.cpp:269
dvector & operator()(int i)
Definition: fvar.hpp:3083
index_guts * p
Definition: fvar.hpp:7733
OFF_T end_pos2
Definition: fvar.hpp:954
double zz
Definition: fvar.hpp:4984
Description not yet available.
Definition: adrndeff.h:182
int ipra
Definition: fvar.hpp:5022
Description not yet available.
Definition: fvar.hpp:7054
void check_list(void)
Check link list integrity.
Definition: ddlist.cpp:184
~lmatrix()
Destructor.
Definition: lmat.cpp:160
int ititle
Definition: fvar.hpp:5020
virtual int dimension() const
Definition: fvar.hpp:7779
int print
Definition: fvar.hpp:5021
Description not yet available.
Definition: fvar.hpp:6861
double & xval()
Definition: fvar.hpp:1414
double mult2
Second mutiplicand in chain rule multipication.
Definition: fvar.hpp:903
dvar3_array & elem(int i, int j)
Definition: fvar.hpp:6545
const dvector & operator()(int i, int j, int k, int l, int _m, int _n) const
Definition: fvar.hpp:7202
unsigned int get_ncopies() const
Definition: fvar.hpp:6826
prevariable operator()(int i, int j) const
Definition: fvar.hpp:2692
friend prevariable & sigmoid(const prevariable &t1)
Description not yet available.
Definition: fvar_fn.cpp:80
void operator/=(double d)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d4arr2.cpp:12
void jacobcalc(int nvar, const dmatrix &jac)
Description not yet available.
Definition: jacobclc.cpp:75
Description not yet available.
Definition: fvar.hpp:7479
void read_from(const istream &)
Read values to dvar_matrix from input istream s.
Definition: fvarm_io.cpp:97
int colmax(void) const
Definition: fvar.hpp:3839
void derch(const double &_f, const dvector &_x, const dvector &_gg, int n, const int &_ireturn)
Description not yet available.
Definition: conjprod.cpp:1008
void write_on(const ostream &) const
Description not yet available.
Definition: dmat_io.cpp:46
virtual double_index_guts * operator[](int i)
Description not yet available.
Definition: doublind.cpp:29
double lnz
Definition: fvar.hpp:9424
double tot
Definition: fvar.hpp:3351
pre_column_print column_print(const dvector &v)
Description not yet available.
Definition: dvect23.cpp:33
const d3_array & elem(int i) const
Definition: fvar.hpp:5236
Description not yet available.
Definition: admodel.h:1474
const double & operator()(int i, int j, int k, int l, int _m, int _n, int _p) const
Definition: fvar.hpp:7207
banded_lower_triangular_dmatrix restore_banded_lower_triangular_dvar_matrix_derivatives(const dvar_matrix_position &_pos)
Description not yet available.
Definition: cmpdif11.cpp:170
friend dvariable det(const dvar_matrix &)
Determinaant of matrix.
Definition: fvar_m20.cpp:37
virtual ~arr_list()
Definition: fvar.hpp:2086
int j
Definition: fvar.hpp:4986
int indexmin() const
Definition: fvar.hpp:5893
int colmin(void) const
Definition: fvar.hpp:4037
Description not yet available.
Definition: fvar.hpp:4440
Description not yet available.
Definition: fvar.hpp:2030
double inv_cumd_exponential(double y)
Description not yet available.
Definition: ccumdexp.cpp:14
unsigned int ncopies
Definition: fvar.hpp:3701
const double & elem(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:6407
const AD_LONG_INT & elem(int i) const
Definition: fvar.hpp:671
Description not yet available.
Definition: fvar.hpp:8369
Description not yet available.
Definition: fvar.hpp:3628
const d6_array & operator[](int i) const
Definition: fvar.hpp:7182
int sub_unallocated(const dvar_vector &)
Author: David Fournier Copyright (c) 2008-2017 Regents of the University of California.
Definition: suballoc.cpp:13
i5_array()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: i5arr.cpp:9
double Psi_1
Definition: fvar.hpp:3674
double ghk_choleski(const dvector &lower, const dvector &upper, const dmatrix &ch, const dmatrix &eps)
int size() const
Definition: fvar.hpp:6226
void *& operator[](int i)
Description not yet available.
Definition: ptr_vec.cpp:165
grad_stack_entry * true_ptr_first
Definition: fvar.hpp:923
dvariable robust_regression_fixed(const dvector &obs, const dvar_vector &pred, double a=0.7)
int Max(const ivector &t1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: ivect10.cpp:12
int & rowmin(void)
Definition: fvar.hpp:4855
double * v
Definition: fvar.hpp:4927
const dvector & elem(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:6746
d6_array()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d6arr2.cpp:9
dvector * grad
Definition: fvar.hpp:3652
d5_array & operator[](int i)
Definition: fvar.hpp:6758
double * variables_save
Definition: fvar.hpp:840
int i
Definition: fvar.hpp:3353
int count_factor(const dvector &v, const double &eps)
Definition: factors.cpp:14
Description not yet available.
Definition: imatrix.h:69
d3_array & elem(int i, int j)
Definition: fvar.hpp:6375
double extf
Definition: fvar.hpp:3671
friend prevariable & operator-(const prevariable &v1)
Description not yet available.
Definition: fvar_op2.cpp:108
unsigned int get_ncopies() const
Definition: fvar.hpp:6489
const d6_array & operator()(int i) const
Definition: fvar.hpp:7178
dmatrix row_vector(const dvector &v)
Returns dvar_matrix with a single row using values from v.
Definition: dvect13.cpp:24
AD_LONG_INT * v
Definition: fvar.hpp:658
void set_value_exp(const prevariable &_x, const dvar_vector &v, const int &_ii, double fmin, double fmax, const dvariable &fpen, double s)
dvector xbest
Definition: fvar.hpp:4990
int size_count_partial(const dvector &x, int n)
Description not yet available.
Definition: dsize.cpp:26
~fmmc()
Description not yet available.
Definition: conjprod.cpp:986
friend d3_array value(const dvar3_array &ar)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: f3arr3.cpp:13
int iprint
Definition: fvar.hpp:3634
void send_dv3_to_master(const dvar3_array &v)
double gl1
Definition: fvar.hpp:5017
void allocatec(const dvar_vector &)
Description not yet available.
Definition: fvar_arr.cpp:243
unsigned int get_ncopies() const
Definition: fvar.hpp:5378
double sig
Definition: fvar.hpp:4984
dvar_vector & shift(int min)
Description not yet available.
Definition: fvar_arr.cpp:28
ivector & elem(int i, int j, int k)
Definition: fvar.hpp:5821
dvector inv_cumd_pareto(const dvector &_y, double alpha, double xm)
long int iter
Definition: fvar.hpp:5747
void allocate(int mmin, int mmax, int n, int m)
Definition: hs_sparse.cpp:2593
dvector gsave
Definition: fvar.hpp:3359
double tfmin
Definition: fvar.hpp:5014
dvar_vector & operator/=(const prevariable &d)
Description not yet available.
Definition: fvar_a48.cpp:76
unsigned int ncopies
Definition: fvar.hpp:522
dvector rrr
Definition: fvar.hpp:3343
virtual int dimension() const
Definition: fvar.hpp:7904
void fill_randn(long int &n)
Description not yet available.
Definition: ranfill2.cpp:118
void fmin(const double &f, const dvector &x, const dvector &g)
int rowsize()
Definition: fvar.hpp:5611
grad_stack()
Definition: fvar.hpp:970
virtual int indexmin() const
Definition: fvar.hpp:7825
double * minp
Definition: fvar.hpp:3238
dvector restore_dvar_matrix_derivative_column(const dvar_matrix_position &_pos, const int &ii)
Description not yet available.
Definition: cmpdif6.cpp:228
void fill_randn_ni(long int &n)
Description not yet available.
Definition: ranf_ni.cpp:116
virtual int indexmin() const
Definition: fvar.hpp:7854
double dir_deriv
Definition: fvar.hpp:3675
char gradfile_name2[61]
Definition: fvar.hpp:937
dvar_vector pareto_density(const dvar_vector &_y, const prevariable &alpha, const prevariable &xm)
double fill_seqadd(double, double)
Description not yet available.
Definition: fvar_m36.cpp:35
pre_column_print(const dvector &v)
Definition: fvar.hpp:8358
void operator/=(double d)
Divide each element of d3_array by d.
Definition: d3arr2b.cpp:33
int mind
Definition: fvar.hpp:9224
ptr_vector ptr
Definition: fvar.hpp:4890
void default_evaluation3(void)
Description not yet available.
Definition: def_eval.cpp:157
static ofstream * global_logfile
Definition: fvar.hpp:8858
double norm_to_gamma(double v, double alpha, double bound)
Description not yet available.
Definition: cnormgam.cpp:17
dvector scale
Definition: fvar.hpp:4993
int indexmin() const
Definition: fvar.hpp:6190
long int xxlink
Definition: fvar.hpp:3299
uistream & ignore(int=1, int=EOF)
friend banded_symmetric_dmatrix value(const banded_symmetric_dvar_matrix &v)
Description not yet available.
Definition: fvar_m40.cpp:114
independent_variables & operator=(const independent_variables &other)
Definition: fvar.hpp:1959
void fill_randn(const random_number_generator &rng)
Description not yet available.
Definition: rngen.cpp:292
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
void initialize(void)
Description not yet available.
Definition: lmat3.cpp:20
OFF_T end_pos
Definition: fvar.hpp:952
double & operator[](int i)
Definition: fvar.hpp:9362
void arr_remove(arr_link **pptr)
Remove and delete arr_link node pptr from gradient_structure::ARR_LIST1.
Definition: newdar.cpp:535
double restore_prevariable_derivative(void)
dmatrix * begin() const
Definition: fvar.hpp:3809
void shallow_copy(const dvar7_array &)
Shallow copy other data structure pointers.
Definition: f7arr.cpp:68
double gammln(double xx)
Log gamma function.
Definition: combc.cpp:52
double & operator()(int i, int j)
Definition: fvar.hpp:8160
const prevariable elem(int i, int j, int k, int l, int _m, int _n) const
Definition: fvar.hpp:6947
void colfill_randn(const int &j, long int &n)
Description not yet available.
Definition: ranfill2.cpp:136
i3_array & elem(int i)
Definition: fvar.hpp:5959
int rowmax(void) const
Definition: fvar.hpp:5921
int rowmin(void)
Definition: fvar.hpp:6140
void operator/=(const prevariable &d)
Description not yet available.
Definition: f4arr2.cpp:98
int ireturn1
Definition: fvar.hpp:5748
Derived class of index types for i3_array.
Definition: fvar.hpp:7866
int admax(int i, int j)
Definition: fvar.hpp:8979
double & elem_value(int i, int j)
Definition: fvar.hpp:2676
unsigned int size() const
Definition: fvar.hpp:7222
Description not yet available.
Definition: fvar.hpp:641
double & elem_value(int i)
Definition: fvar.hpp:2226
long int nn
Definition: fvar.hpp:3352
Description not yet available.
Definition: fvar.hpp:509
void deallocate()
Deallocate dmatrix memory.
Definition: dmat.cpp:363
int colmax(void) const
Definition: fvar.hpp:5929
dvector * xi
Definition: fvar.hpp:3648
dvector tanh(const dvector &vec)
Returns dvector with hyperbolic tangent for each value of vec.
Definition: dvect6.cpp:126
int is
Definition: fvar.hpp:3302
dvector funval
Definition: fvar.hpp:5734
dvector * ptr
Definition: fvar.hpp:8371
double dgg
Definition: fvar.hpp:3666
int isinteger() const
Definition: fvar.hpp:7752
void ADMB_getcallindex(int)
Definition: fvar.hpp:9243
friend dvariable sumsq(const banded_symmetric_dvar_matrix &B)
Definition: fvar_m40.cpp:721
prevariable elem(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:6557
vector_shapex * shape
Definition: fvar.hpp:6069
friend void slave_gradcalc(void)
Description not yet available.
Definition: fvar.hpp:8688
int operator!(void) const
Definition: fvar.hpp:6703
void RETURN_ARRAYS_DECREMENT(void)
Decrements gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:507
double crit
Definition: fvar.hpp:3632
double minimize(const dvector &x, double(*pf)(const dvar_vector &))
double ** address
Definition: fvar.hpp:1288
imatrix & get_coords(void)
Definition: fvar.hpp:9378
friend class dvar_vector_iterator
Definition: fvar.hpp:1335
double & operator()(int i, int j, int k, int l, int _m, int _n, int _p)
Definition: fvar.hpp:7174
~lvector()
Destructor.
Definition: lvector.cpp:46
dvar_vector & operator[](int)
Definition: fvar.hpp:2769
virtual index_guts * operator[](int i)
Definition: fvar.hpp:7868
int ext_flag
Definition: fvar.hpp:3658
void writeon(const ostream &s) const
writeon Writes function minimizing status
Definition: fmm_cont.cpp:149
void operator/=(const prevariable &v1)
Description not yet available.
Definition: fvar_op5.cpp:100
double dfposfun(const double &x, const double eps)
Adjoint code for posfun; possibly not used.
Definition: posfunc.cpp:19
void save_dmatrix_derivatives(const dvar_matrix_position &) const
Description not yet available.
Definition: cmpdif11.cpp:144
int disk_save(void)
Definition: fvar.hpp:3243
imatrix * t
Definition: fvar.hpp:3946
dmatrix & elem(int i, int j)
Definition: fvar.hpp:5224
dvector diagonal(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat31.cpp:12
double_index_guts * p
Definition: fvar.hpp:8566
hs_symbolic(void)
Definition: hs_sparse.cpp:2471
int indexmin() const
Definition: fvar.hpp:6812
friend prevariable & sqrt(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:95
bool operator!() const
Returns true if dmatrix is empty, else false.
Definition: fvar.hpp:2846
int indexmax(void)
Definition: fvar.hpp:9358
int size() const
Definition: fvar.hpp:686
fmmt(int _nvar, int _m=7)
void operator/=(double d)
Divides all elements of d5_array by d.
Definition: d5arr1.cpp:28
friend class array_size
Definition: fvar.hpp:2459
int rowsize()
Definition: fvar.hpp:5884
lvector_position operator()(int i)
int operator!(void) const
Definition: fvar.hpp:7085
friend void slave_gradcalc(void)
friend dvar_vector sigmoid(const dvar_vector &t1)
i4_array & operator=(const i4_array &)
void fmin(const double &f, const dvector &x, const dvector &g)
Description not yet available.
Definition: fmmtr1.cpp:67
ivector iprint1
Definition: fvar.hpp:5750
int operator!(void) const
Definition: fvar.hpp:662
double besselY(double x, int nu)
Definition: cbessel.cpp:304
const dvector & elem(int i) const
Definition: fvar.hpp:3019
int colmax(void)
Definition: fvar.hpp:5286
dmatrix restore_dvar_matrix_der_nozero(const dvar_matrix_position &_pos)
Description not yet available.
Definition: cmpdif6.cpp:197
dvector atlas_solve_spd(const dmatrix &M, const dvector &x)
virtual int indexmax() const
Definition: fvar.hpp:7885
const dvar_matrix & elem(int i) const
? Retrieves an element of a dvar3_array.
Definition: fvar.hpp:4331
int indexmax() const
Definition: fvar.hpp:3822
const d3_array & operator()(int i) const
Definition: fvar.hpp:5401
vector_shape * shape
Definition: fvar.hpp:6333
void dfinvpret(void)
Adjoint code for dvar_matrix inv(const dvar_matrix&amp; aa).
Definition: fvar_m15.cpp:287
friend void make_indvar_list(const dvar_vector &)
Description not yet available.
Definition: fvar_arr.cpp:159
four_array_shape * shape
Definition: fvar.hpp:5435
double sumsq(const d3_array &a)
Definition: d3arr2a.cpp:181
i4_array & operator[](int)
Definition: fvar.hpp:6275
int operator!(void) const
Definition: fvar.hpp:4206
dvar_matrix_position(const dvar_matrix &, int)
Description not yet available.
Definition: cmpdif2.cpp:176
char gradfile_name1[61]
Definition: fvar.hpp:936
int ad_chdir(const char *s)
Description not yet available.
Definition: makesub.cpp:43
double tot
Definition: fvar.hpp:4984
dvar_matrix positive_definite_matrix(const dvar_matrix &MM, double eps, dvariable &fpen)
Description not yet available.
Definition: fvar_m47.cpp:36
int lb
Definition: fvar.hpp:625
prevariable operator[](int i)
Definition: fvar.hpp:2327
double_and_int * gradnew()
Definition: fvar2.cpp:50
dmatrix(void)
Default constructor.
Definition: dmat0.cpp:16
int _GRADFILE_PTR2
Definition: fvar.hpp:944
friend double norm(const dmatrix &)
Norm of a matrix; constant object.
Definition: dmat2.cpp:31
void grad_chk(void)
Description not yet available.
Definition: gradchk.cpp:18
double gmax
Definition: fvar.hpp:5739
double pbeta(const double x, const double a, const double b, int maxit)
beta distribution function for constant objects (alias of ibeta function with same arguments order as...
Definition: cbetai.cpp:47
Description not yet available.
Definition: fvar.hpp:5433
long int itn
Definition: fvar.hpp:4985
d3_array operator-(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:152
int colmin(void) const
Definition: fvar.hpp:2552
double left_bracket
Definition: fvar.hpp:3677
unsigned int size() const
Definition: fvar.hpp:7036
lower_triangular_dmatrix(int, int)
Description not yet available.
Definition: dmat36.cpp:17
dmatrix & elem(int i, int j, int k, int l)
Definition: fvar.hpp:6721
d4_array * t
Definition: fvar.hpp:6334
d6_array & elem(int i)
Definition: fvar.hpp:7231
int slicemin(void)
Definition: fvar.hpp:5571
bool is_valid_row(const int i) const
Check index i is in matrix row bounds [index_min, index_max].
Definition: dmat8.cpp:19
int colmin(void)
Definition: fvar.hpp:6148
dvector & get_x(void)
Definition: fvar.hpp:9382
dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat2.cpp:13
dvector eigenvalues(const banded_symmetric_dmatrix &_SS)
Description not yet available.
Definition: dmat28.cpp:411
double bounded_cumd_norm(const double x, double beta)
Description not yet available.
Definition: cumdist.cpp:119
double gmax
Definition: fvar.hpp:3354
~random_number_generator()
Destructor.
Definition: rngen.cpp:92
dmatrix expm(const dmatrix &A)
Matrix exponential.
friend prevariable & ldexp(const prevariable &, const int &)
Description not yet available.
Definition: fvar_fn1.cpp:80
unsigned int nrows
Definition: fvar.hpp:2004
const d4_array & elem(int i, int j) const
Definition: fvar.hpp:6734
#define x
independent_variables()
Default Constructor.
Definition: fvar.hpp:1941
double gso
Definition: fvar.hpp:3351
double_and_int * get_v() const
Definition: fvar.hpp:1423
~double_index_type()
Description not yet available.
Definition: doublind.cpp:153
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
void fill(const char *)
Fill variable vector from values in string s.
Definition: fvar_a10.cpp:52
Vector of double precision numbers.
Definition: dvector.h:50
double inv_cumd_gamma(double y, double a)
Definition: cgamdev.cpp:124
three_array_shape * shape
Definition: fvar.hpp:3730
Description not yet available.
Definition: fvar.hpp:8190
int rowmin(void) const
Definition: fvar.hpp:3843
prevariable operator[](int i)
Definition: fvar.hpp:9308
constexpr const int percentage_number
Definition: fvar.hpp:9507
int indexmin() const
Definition: fvar.hpp:553
long iexit
Definition: fvar.hpp:3688
int int_flag
Definition: fvar.hpp:3659
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void colshift(int min)
Changes the range of valid indices for the rows.
Definition: dmat9.cpp:39
int maxfn_flag
Definition: fvar.hpp:3194
friend ostream & operator<<(const ostream &, const pre_zero_print &)
Description not yet available.
Definition: dvect23.cpp:42
long int icc
Definition: fvar.hpp:3352
size_t total_addresses() const
Get total addresses stored.
Definition: ddlist.cpp:169
const dvector & elem(int i, int j, int k, int l, int _m, int _n) const
Definition: fvar.hpp:7138
long int link
Definition: fvar.hpp:4983
int get_depth(void)
Definition: fvar.hpp:9235
int rowmin(void) const
Definition: fvar.hpp:8003
double & operator()(int i, int j)
Definition: fvar.hpp:3281
banded_lower_triangular_dvar_matrix(int _min, int _max, int _bw)
Description not yet available.
Definition: fvar_m40.cpp:184
int slicesize()
Definition: fvar.hpp:5606
void initialize(void)
Intialize vector values to zero.
Definition: lvector.cpp:216
virtual int dimension() const
Definition: fvar.hpp:7850
int indexmin() const
Definition: fvar.hpp:2917
independent_variables & operator=(const dvector &t)
Assignment operator for dvector argument.
Definition: dvector.cpp:292
void allocate(void)
Does not allocate, but initializes pointers to NULL.
Definition: d4arr3.cpp:14
void shift(int min)
Description not yet available.
Definition: shape.cpp:23
friend void slave_gradcalc(void)
double left_bracket_value
Definition: fvar.hpp:3678
dvector w
Definition: fvar.hpp:3294
void shallow_copy(const dvar4_array &)
Shallow copy other data structure pointers.
Definition: f4arr.cpp:28
void colfill_randn_ni(const int &j, long int &n)
Description not yet available.
Definition: ranf_ni.cpp:175
dvector choleski_solve_neghess_error(dmatrix M, dvector &v, int &ierror)
Description not yet available.
Definition: dmat37.cpp:216
int slicemin(void)
Definition: fvar.hpp:6132
int slicesize() const
Definition: fvar.hpp:5942
void jacobcalc(int nvar, const dmatrix &g)
Description not yet available.
Definition: jacobclc.cpp:66
dvector funval
Definition: fvar.hpp:4980
const dvector & elem(int i, int j, int k) const
Definition: fvar.hpp:5244
unsigned int get_ncopies(void)
Definition: fvar.hpp:539
void print()
friend dvector value(const dvar_vector &v1)
Description not yet available.
Definition: fvar_ar3.cpp:43
Description not yet available.
Definition: fvar.hpp:568
friend prevariable & atan(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:64
~smart_counter()
Destructor.
Definition: indextyp.cpp:47
void clean(ivector &v, int level)
Set elements of ivec to zero starting from level + 1;.
Definition: ivector.cpp:377
Description not yet available.
Definition: fvar.hpp:7937
long maxfn
Definition: fvar.hpp:3182
friend double det(const dmatrix &)
Compute determinant of a constant matrix.
Definition: dmat3.cpp:499
i4_index(i4_array &v)
Definition: fvar.hpp:7900
ad_integer(const int &_d, const adkludge &)
Definition: fvar.hpp:7664
void fmin(const double &f, const dvector &p, const dvector &gg)
Description not yet available.
Definition: conjprod.cpp:144
dmatrix choleski_decomp_neghess_error(const dmatrix &MM, int &ierror)
Description not yet available.
Definition: dmat15.cpp:176
static adstring subdir
Definition: fvar.hpp:8851
friend dvariable norm2(const banded_symmetric_dvar_matrix &B)
Description not yet available.
Definition: fvar_m40.cpp:710
void initialize(void)
Description not yet available.
Definition: fvar_fn.cpp:56
double cumd_gamma(double x, double a)
Definition: cgamdev.cpp:38
lmatrix_position restore_lmatrix_position(void)
double gamma
Definition: fvar.hpp:3669
int noprintx
Definition: fvar.hpp:3181
double fsave
Definition: fvar.hpp:3355
dmatrix restore_dvar_matrix_derivatives(const dvar_matrix_position &_pos)
Description not yet available.
Definition: cmpdif6.cpp:178
void arr_free(double_and_int *)
virtual int indexmax(void)
Definition: fvar.hpp:8677
Description not yet available.
Definition: fvar.hpp:9222
int istop
Definition: fvar.hpp:5004
static char ** argv
Definition: fvar.hpp:8866
int hslicesize()
Definition: fvar.hpp:6158
double robust_normal_mixture_deviate(double x, double spread)
Description not yet available.
Definition: cnorlogmix.cpp:130
int restore_int_value(void)
Description not yet available.
Definition: cmpdif8.cpp:197
const dvar_matrix & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:6939
unsigned int ncols
Definition: fvar.hpp:2005
int indexmin() const
Definition: fvar.hpp:676
double fsave
Definition: fvar.hpp:3304
int ip
Definition: fvar.hpp:5023
index_type operator()(int i)
Description not yet available.
Definition: indextyp.cpp:177
void fmin(double f, const independent_variables &x, const dvector &g, const int &n, const dvector &w, const dvector &h, const fmm_control &fmc)
int j
Definition: fvar.hpp:3302
void rowshift(int min)
Description not yet available.
Definition: dmat9.cpp:58
virtual int indexmax() const
Definition: fvar.hpp:7858
double inv_cumd_norm(const double &x)
Description not yet available.
Definition: cumdist.cpp:78
Derived class of index types for ivector.
Definition: fvar.hpp:7809
dvector gbest
Definition: fvar.hpp:4989
void set_defaults()
Description not yet available.
Definition: fmm_cont.cpp:33
dvar_matrix nograd_assign_trans(const dmatrix &m)
Description not yet available.
Definition: cmpdif6.cpp:334
double_and_int * get_va()
Definition: fvar.hpp:2231
unsigned int get_ncopies() const
Definition: fvar.hpp:5957
void fill_randu_ni(long int &n)
Description not yet available.
Definition: ranf_ni.cpp:145
void initialize(void)
Description not yet available.
Definition: f4arr.cpp:586
double gso
Definition: fvar.hpp:3300
long int n1
Definition: fvar.hpp:3350
double besselJ(double x, int nu)
Definition: cbessel.cpp:292
dvar_vector nograd_assign(dvector tmp)
Description not yet available.
Definition: cmpdif6.cpp:252
cubic_spline_function(const dvector &_x, const dvector &_y, double yp1=0.0, double ypn=0.0)
Definition: cspline.cpp:12
void initialize(void)
Zero initialize allocated dvar_matrix, then saves adjoint function and position data.
Definition: fvar_ma7.cpp:48
void save_dvar_matrix_value() const
Description not yet available.
Definition: cmpdif11.cpp:28
void initialize(void)
Description not yet available.
Definition: f3arr.cpp:17
void dv_init(void)
Description not yet available.
Definition: fvar_a24.cpp:40
int rowsize() const
Definition: fvar.hpp:4059
virtual int indexmin(void)
Definition: fvar.hpp:8673
dvector gbest
Definition: fvar.hpp:5740
void save_variables()
Save variables to a buffer.
Definition: ddlist.cpp:141
prevariable elem(int i, int j) const
Definition: fvar.hpp:2519
#define cutoff
dvar_matrix & operator++(void)
Definition: fvar.hpp:2495
i3_array & operator()(int i)
Definition: fvar.hpp:5979
static unsigned char directory_prefix
Definition: fvar.hpp:8865
const prevariable elem(int i, int j, int k) const
? Retrieves an element of a dvar3_array.
Definition: fvar.hpp:4340
~dlist()
Destructor.
Definition: ddlist.cpp:54
static adstring working_directory_path
Definition: fvar.hpp:8861
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
int bandwidth(void) const
Definition: fvar.hpp:8127
dvar_matrix & elem(int i, int j, int k)
Definition: fvar.hpp:6549
OFF_T end_pos1
Definition: fvar.hpp:953
Description not yet available.
Definition: admodel.h:2767
void allocate(void)
Does not allocate, but initializes dvar_vector to empty.
Definition: fvar_arr.cpp:216
const d5_array & operator[](int i) const
Definition: fvar.hpp:6786
int slicemax() const
Definition: fvar.hpp:4275
dvar5_array * t
Definition: fvar.hpp:6864
dvar5_array()
Description not yet available.
Definition: f5arr3.cpp:17
static uistream * global_bparfile
Definition: fvar.hpp:8859
dvar6_array & operator[](int i)
Definition: fvar.hpp:7367
unsigned int decr_ncopies(void)
Definition: fvar.hpp:535
const double & operator()(int i, int j) const
Definition: fvar.hpp:3002
dvector & elem(int i, int j, int k)
Definition: fvar.hpp:5228
Holds derivative information for arithmetic operators and math library functions. ...
Definition: fvar.hpp:894
int rowmin(void) const
Definition: fvar.hpp:8139
void gauss_legendre(double x1, double x2, const dvector &_x, const dvector &_w)
Gauss-Legendre quadature.
Definition: gaussher.cpp:148
number_index(int i)
Definition: fvar.hpp:7793
double qbeta(double x, double a, double b, double eps)
int * get_ncopies()
Definition: indextyp.cpp:59
int rowmax(void) const
Definition: fvar.hpp:5333
four_array_shape(int hsl, int hsu)
Construct four_array_shape with initial values and setting min and max.
Definition: d4arr.cpp:26
double gmin
Definition: fvar.hpp:5015
int hslicemin() const
Definition: fvar.hpp:6182
d3_array operator+(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:132
dlink * append(dlink *link)
Append link to list.
Definition: ddlist.cpp:117
~dvar6_array()
Destructor.
Definition: f6arr.cpp:91
void fill_randn(long int &n)
Fill matrix with random numbers.
Definition: ranfill.cpp:244
Stores double value.
Definition: fvar.hpp:8499
double d
Definition: fvar.hpp:8502
Description not yet available.
Definition: fvar.hpp:3698
double sig
Definition: fvar.hpp:3300
void fill_randcau(const random_number_generator &rng)
Description not yet available.
Definition: drancau.cpp:39
double gtol
Definition: fvar.hpp:5745
df1_one_variable atan(const df1_one_variable &x)
Definition: df11fun.cpp:312
dvar4_array & elem(int i, int j)
Definition: fvar.hpp:6907
double fringe
Definition: fvar.hpp:3185
int decrement_current_gradfile_ptr(void)
If there is a previous file set the handle to point to it otherwise return a -1.
Definition: gradstak.cpp:519
vector_shape * shape
Definition: fvar.hpp:6863
~i4_array()
Destructor.
Definition: i4arr.cpp:211
d3_array elem_div(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements division of a(i, j, k) / b(i, j, k).
Definition: d3arr2a.cpp:112
int dimension() const
Definition: fvar.hpp:7756
Description not yet available.
Definition: fvar.hpp:3232
int hslicemax() const
Definition: fvar.hpp:6186
void colfill_seqadd(const int &, const int &, const int &)
fmmc(const int &n)
Description not yet available.
Definition: conjprod.cpp:942
friend prevariable & fabs(const prevariable &t1)
Absolute value.
Definition: fvar_fn.cpp:105
dcompressed_triplet(int mmin, int mmax, int n, int m)
Definition: hs_sparse.cpp:2571
dvar5_array & elem(int i)
Definition: fvar.hpp:6903
void gauss_hermite(const dvector &_x, const dvector &_w)
Gauss-Hermite quadature.
Definition: gaussher.cpp:36
dvar_matrix_position restore_dvar_matrix_position()
Reads back the size and address information for a dvar_matrix, restores the size, address...
Definition: cmpdif6.cpp:110
prevariable elem(int i, int j)
Definition: fvar.hpp:2511
double fsave
Definition: fvar.hpp:4988
Description not yet available.
Definition: fvar.hpp:656
int rowmax(void) const
Definition: fvar.hpp:8143
double old_inv_cumd_beta_stable(double a, double b, double y, double eps)
int hslicemax() const
Definition: fvar.hpp:5317
double dga
Definition: fvar.hpp:5010
dmatrix_position restore_dmatrix_position()
Description not yet available.
Definition: cmpdif6.cpp:143
ivector lb
Definition: fvar.hpp:7484
dvar4_array & operator[](int i)
Definition: fvar.hpp:6586
vector_shape_pool & operator=(const vector_shape_pool &)=delete
d3_array sin(const d3_array &arr3)
Returns d3_array results with computed sin from elements in arr3.
Definition: d3arr2a.cpp:43
int indexmin() const
Definition: fvar.hpp:4909
void deallocate(void)
Deallocate i3_array memory.
Definition: i3arr.cpp:277
const double & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:5248
int rowsize() const
Definition: fvar.hpp:4300
d5_array & elem(int i)
Definition: fvar.hpp:6828
Description not yet available.
Definition: fvar.hpp:4814
friend double min(const dvector &)
Returns the minimum value of vector vec.
Definition: dvect7.cpp:107
dvar3_array & elem(int i, int j, int k)
Definition: fvar.hpp:6911
const double & elem(int i, int j) const
Definition: fvar.hpp:3023
const dmatrix & elem(int k) const
Definition: fvar.hpp:3874
void shift(int min)
lmatrix(void)
Default constructor.
Definition: lmat.cpp:152
dvariable & operator=(const prevariable &)
Description not yet available.
Definition: xgradclc.cpp:375
dvector cosh(const dvector &vec)
Returns dvector with hyperbolic cosine for each value of vec.
Definition: dvect6.cpp:105
int colmax(void)
Definition: fvar.hpp:5591
void fill_randn_ni(long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:102
void colfill_randn_ni(const int &j, long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:175
void dvdv_dot(void)
Definition: fvar_a14.cpp:84
int indexmin() const
Definition: fvar.hpp:4827
dvar3_array & operator()(int i)
Definition: fvar.hpp:5516
void write_grad_stack_buffer()
Definition: fvar.hpp:976
int rowmax(void) const
Definition: fvar.hpp:7596
lmatrix & operator=(const lmatrix &t)
Description not yet available.
Definition: lmat5.cpp:18
dmatrix xy
Definition: fvar.hpp:3344
char * get_gradfile_name()
Description not yet available.
Definition: gradstak.cpp:543
int indexmax(void) const
Definition: fvar.hpp:7999
void allocate(void)
Initializes to NULL.
Definition: f4arr3.cpp:20
int rowmin() const
Definition: imatrix.h:146
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
exitptr ad_exit
Definition: gradstrc.cpp:53
int colmin(void) const
Definition: fvar.hpp:5642
long int i1
Definition: fvar.hpp:4983
lvector & shift(int min)
Shift current dimensions of lvector using to_indexmin as the new lower index value.
Definition: ivec.cpp:37
void default_evaluation1m(void)
Description not yet available.
Definition: def_eval.cpp:110
uostream & operator<<(signed char)
double randnegbinomial(double mu, double tau, const random_number_generator &rng)
Description not yet available.
Definition: rannegbn.cpp:17
const dvar_matrix & elem(int i, int j) const
Definition: fvar.hpp:5499
int index_max
Definition: fvar.hpp:2823
int bandwidth(void) const
Definition: fvar.hpp:8071
virtual int indexmin() const
Definition: fvar.hpp:7784
double density_cauchy(const double &x)
Description not yet available.
Definition: cumd_cau.cpp:29
long int iconv
Definition: fvar.hpp:4983
~dvar_matrix()
Destructor.
Definition: fvar_mat.cpp:73
int slicemin(void)
Definition: fvar.hpp:5844
prevariable elem(int i)
Definition: fvar.hpp:2221
lmatrix restore_lmatrix_value(const lmatrix_position &mpos)
void allocate(void)
Allocate dvector without allocating memory.
Definition: dvector.cpp:495
Keeps track of total number of copies.
Definition: fvar.hpp:7716
Derived class of index types for i4_array.
Definition: fvar.hpp:7893
double * ind_addr2
Pointer to second independent variable.
Definition: fvar.hpp:902
#define dmin(a, b)
Definition: cbivnorm.cpp:190
dmatrix * t
Definition: fvar.hpp:3729
double & elem_value(int i, int j)
Definition: fvar.hpp:8246
independent_variables(const independent_variables &other)
Definition: fvar.hpp:1943
dmatrix sub(int, int)
Description not yet available.
Definition: dmat.cpp:47
double dgb
Definition: fvar.hpp:5011
d6_array & operator[](int i)
Definition: fvar.hpp:7150
int colmax(void) const
Definition: fvar.hpp:5646
ad_comm()
Default constructor.
Definition: model7.cpp:366
dmatrix & elem(int i, int j, int k)
Definition: fvar.hpp:6379
double zz
Definition: fvar.hpp:3300
dvector row(const dmatrix &matrix, int i)
Returns a copied row for matrix at i.
Definition: dmat6.cpp:24
Description not yet available.
Definition: fvar.hpp:7638
Derived class of index types for ad_integer.
Definition: fvar.hpp:7772
void initialize(void)
Description not yet available.
Definition: dmat41.cpp:29
int indexmax() const
Definition: fvar.hpp:4960
const dvar4_array & elem(int i, int j, int k) const
Definition: fvar.hpp:7341
ivector & colmax(void)
Definition: fvar.hpp:4867
unsigned int rowsize() const
Definition: fvar.hpp:7601
Description not yet available.
Definition: fvar.hpp:4923
void fill_randu(long int &n)
Description not yet available.
Definition: ranfill2.cpp:190
void allocate(void)
Does NOT allocate, but initializes d6_array members.
Definition: d6arr2.cpp:14
virtual ~number_index()
Destructor.
Definition: fvar.hpp:7797
void fill_randu_ni(long int &n)
Description not yet available.
Definition: ranf_ni.cpp:160
unsigned int hslicesize() const
Definition: fvar.hpp:5356
d3_array cube(const d3_array &m)
Description not yet available.
Definition: d3arr5.cpp:17
void allocate()
Definition: model7.cpp:370
int indexmin(void) const
Definition: fvar.hpp:8075
double dfposfun1(const double &x, const double eps)
Adjoint code for posfun; possibly not used.
Definition: posfunc.cpp:39
const int iprint
Definition: fvar.hpp:9504
const d4_array & operator()(int i, int j, int k) const
Definition: fvar.hpp:7190
char which_library()
Get ADMB library mode.
Definition: libtype.cpp:15
Null class to allow specialized function overloads.
Definition: fvar.hpp:469
const double & operator()(int i, int j, int k, int l, int _m, int _n) const
Definition: fvar.hpp:6806
double_index_guts()
Description not yet available.
Definition: doublind.cpp:198
void fmin(const double &f, const dvector &x, const dvector &g)
Function fmin contains Quasi-Newton function minimizer with inexact line search using Wolfe condition...
Definition: newfmin.cpp:254
virtual ~dmatrix_index()
Destructor.
Definition: doublind.cpp:80
dlink * last_remove()
If list is not empty, pop and return last node.
Definition: ddlist.cpp:102
const double_index_type * a
Definition: fvar.hpp:8487
friend dvariable sumsq(const dvar_matrix &)
Definition: fvar_ma3.cpp:120
int slicemin() const
Definition: fvar.hpp:4029
friend double_and_int * gradnew()
Creates an entry in the gradient structure linked list.
Definition: fvar2.cpp:36
dmatrix_index(const dmatrix &v)
Definition: fvar.hpp:8670
function_tweaker(double eps, double mult)
Description not yet available.
Definition: ftweak.cpp:20
mat_shapex * shape
Definition: fvar.hpp:2825
void shallow_copy(const i3_array &)
Shallow copy other data structure pointers.
Definition: i3arr.cpp:260
const prevariable elem(int i, int j, int k, int l) const
Definition: fvar.hpp:5507
dvariable kludge_cumd_cauchy(const prevariable &x)
Description not yet available.
Definition: vcumdcau.cpp:27
dvar_vector posfun(const dvar_vector &x, double eps, const prevariable &pen)
Description not yet available.
Definition: fvar_a62.cpp:17
d3_array restore_d3_array_value(const d3_array_position &mpos)
Description not yet available.
Definition: cmpdif5.cpp:123
dmatrix & operator*=(double d)
Multiply value to all elements in dmatrix.
Definition: dmat22.cpp:48
void nograd_assign_row(const dvar_matrix &m, const dvector &v, const int &ii)
Description not yet available.
Definition: cmpdif7.cpp:28
friend dvar_matrix operator*(const dvar_matrix &m1, const dmatrix &m2)
Description not yet available.
Definition: fvar_m19.cpp:35
d3_array value(const dvar3_array &)
ADMB variable vector.
Definition: fvar.hpp:2172
friend dvar_vector elem_prod(const dvar_vector &, const dvar_vector &)
Description not yet available.
Definition: fvar_a45.cpp:32
void save_dmatrix_value() const
Description not yet available.
Definition: cmpdif5.cpp:22
double step
Definition: fvar.hpp:5016
void verify_identifier_string(const char *)
Verifies gradient stack string.
Definition: cmpdif3.cpp:149
static vector_shape_pool * xpool
Definition: fvar.hpp:513
int depth
Definition: fvar.hpp:9226
dvar6_array & operator()(int i)
Definition: fvar.hpp:7363
int disk_save
Definition: fvar.hpp:3311
void save_lmatrix_value(void)
vector_shape & operator=(const vector_shape &)=delete
double & elem_value(int i) const
Definition: fvar.hpp:2241
void deallocate(void)
Deallocate dvar5_array memory.
Definition: f5arr.cpp:86
void open(const char *name, int mode=ios::out|ios::binary, int prot=0664)
Description not yet available.
Definition: ufstream.cpp:45
Description not yet available.
Definition: fvar.hpp:6673
int indexmin() const
Definition: fvar.hpp:4021
Function minimizer control.
Definition: fvar.hpp:3178
Abstract base class for different index types.
Definition: fvar.hpp:7682
dmatrix & operator=(const dmatrix &t)
Assign values in other to dmatrix.
Definition: dmat4.cpp:27
int colsize() const
Definition: fvar.hpp:5372
double fy
Definition: fvar.hpp:3300
int indexmax() const
Definition: fvar.hpp:7455
banded_symmetric_dmatrix restore_bounded_symmetric_dvar_matrix_derivatives(const dvar_matrix_position &_pos)
Description not yet available.
Definition: cmpdif11.cpp:186
unsigned int get_ncopies() const
Definition: fvar.hpp:3903
void initialize()
Definition: ddlist.cpp:129
void shallow_copy(const d4_array &)
Copies pointer locations from other to d4_array.
Definition: d4arr.cpp:90
void df_check_derivative_values_indexed(void)
Description not yet available.
Definition: newdar.cpp:427
dvector lower_triagular_solve(const dmatrix &m, const dvector &v)
Description not yet available.
Definition: fvar.hpp:7926
void colfill_randn(const int &j, long int &n)
Fill random numbers into specified column j of matrix.
Definition: ranfill.cpp:301
static adstring adprogram_name
Definition: fvar.hpp:8860
friend void allocate_dvariable_space(void)
Description not yet available.
Definition: gradstrc.cpp:210
unsigned int size() const
Definition: fvar.hpp:2297
const double & operator()(int i, int j) const
Definition: fvar.hpp:8038
double fbest
Definition: fvar.hpp:4982
int isdouble(void) const
Definition: fvar.hpp:8569
long ihflag
Definition: fvar.hpp:3689
double gamma_density(double x, double r, double mu)
Gamma probability density function; constant objects.
Definition: cgamdens.cpp:21
friend uostream & operator<<(const uostream &, const dfsdmat &)
Description not yet available.
Definition: dfsdmat.cpp:283
d5_array & operator=(const d5_array &)
Assigns element values from other to d5_array.
Definition: d5arr.cpp:100
void save_prevariable_value() const
Description not yet available.
Definition: cmpdif8.cpp:72
int colmin() const
Definition: fvar.hpp:4283
int operator==(const prevariable &v1) const
Description not yet available.
Definition: fvar_opr.cpp:83
int rowsize(void) const
Definition: fvar.hpp:3859
long int iconv
Definition: fvar.hpp:3350
friend class subdvector
Definition: fvar.hpp:529
dvar5_array sub(int hhsl, int hhsu)
Description not yet available.
Definition: f5arr.cpp:29
virtual int indexmax() const =0
int indexmax() const
Definition: fvar.hpp:585
dvar_vector & operator++(void)
Definition: fvar.hpp:2191
int mode
Definition: fvar.hpp:4999
double mean(const dvector &vec)
Returns computed mean of vec.
Definition: cranfill.cpp:43
double norm(const d3_array &a)
Return computed norm value of a.
Definition: d3arr2a.cpp:190
adstring get_string_marker(void)
Description not yet available.
Definition: cmpdif3.cpp:171
long int icc
Definition: fvar.hpp:4985
unsigned int ncopies
Definition: fvar.hpp:2003
~d6_array()
Destructor.
Definition: d6arr.cpp:83
dmatrix & operator()(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:7166
int operator<(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:53
dlink * last
Definition: fvar.hpp:836
int imax
Definition: fvar.hpp:3640
int slicemax() const
Definition: fvar.hpp:3830
unsigned int get_ncopies() const
Definition: fvar.hpp:2461
int rowmin(void) const
Definition: fvar.hpp:6206
friend prevariable & pow(const prevariable &t1, const prevariable &t2)
Description not yet available.
Definition: fvar_fn1.cpp:207
void default_evaluation3ind(void)
Description not yet available.
Definition: def_eval.cpp:174
prevariable elem(int i, int j, int k)
? Retrieves an element of a dvar3_array.
Definition: fvar.hpp:4324
dlist()
Default constructor.
Definition: ddlist.cpp:17
double gmax
maximum gradient
Definition: fvar.hpp:3303
ivector_position(void)
Default constructor.
Definition: cmpdif2.cpp:124
void save_dvar_matrix_value() const
Description not yet available.
Definition: cmpdif11.cpp:37
double better_rand()
Random number generator.
Definition: rngen.cpp:134
dvector * extg
Definition: fvar.hpp:3653
void operator/=(const prevariable &)
Description not yet available.
Definition: f3arr5.cpp:72
unsigned int colsize() const
Definition: fvar.hpp:2948
int indexmax() const
Definition: fvar.hpp:4273
double z
Definition: fvar.hpp:3300
double std_dev(const dvector &vec)
Returns the computed standand deviation of vec.
Definition: cranfill.cpp:34
dvar_matrix * t
Definition: fvar.hpp:4199
int _GRADFILE_PTR1
Definition: fvar.hpp:943
double besselI(double x, int nu)
Definition: cbessel.cpp:267
double fb
Definition: fvar.hpp:5009
static double cumd_normal_mixture(double x, double a)
Description not yet available.
Definition: cnormmix.cpp:21
dvar4_array & elem(int i)
Definition: fvar.hpp:6541
void ad_set_new_handler(void)
Description not yet available.
Definition: newhand.cpp:41
Description not yet available.
Definition: fvar.hpp:8636
dvector * extx
Definition: fvar.hpp:3650
int indexmax() const
Definition: fvar.hpp:681
void deallocate(void)
Deallocate d7_array memory.
Definition: d7arr.cpp:59
const d5_array & operator()(int i) const
Definition: fvar.hpp:6782
d4_array & operator()(int i, int j, int k)
Definition: fvar.hpp:7158
arr_link * last
Definition: fvar.hpp:2066
int operator!(void) const
Definition: fvar.hpp:5787
double restore_double_value()
Description not yet available.
Definition: cmpdif8.cpp:182
friend dvector operator*(const dvector &, const dmatrix &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat1.cpp:18
dvector * g
Definition: fvar.hpp:3646
mat_shape()
Definition: fvar.hpp:2011
friend prevariable & operator/(const prevariable &t1, const prevariable &t2)
Description not yet available.
Definition: fvar_op2.cpp:123
dvariable()
Default constructor.
Definition: fvar.hpp:1526
int indexmin(void) const
Definition: fvar.hpp:8586
Description not yet available.
Definition: fvar.hpp:8901
int colmin(void) const
Definition: fvar.hpp:6214
d5_array * t
Definition: fvar.hpp:6676
void fill_randu_ni(long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:145
dvar_matrix & elem(int i, int j, int k, int l)
Definition: fvar.hpp:6915
dvar_vector y2
Definition: fvar.hpp:5043
int colmin(void) const
Definition: fvar.hpp:3835
dvector * ptr
Definition: fvar.hpp:8356
void gradcalc(int nvar, const dvector &g)
Definition: sgradclc.cpp:77
vector_shape * shape
Definition: fvar.hpp:659
d5_array & operator()(int i, int j)
Definition: fvar.hpp:7154
virtual double_index_guts * operator[](int)=0
AD_LONG_INT & elem(int i)
Definition: fvar.hpp:667
double dflogistic(double a, double b, const double &x)
dvar6_array()
Description not yet available.
Definition: f6arr2.cpp:17
friend dvariable norm2(const dvar_matrix &)
Definition: fvar_ma3.cpp:98
df1_one_matrix choleski_decomp(const df1_one_matrix &MM)
Definition: df11fun.cpp:606
int indexmax() const
Definition: fvar.hpp:7218
int slicemax(void) const
Definition: fvar.hpp:6202
void allocate(void)
Initialize members but does not allocate.
Definition: dfsdmat.cpp:118
double expdev(const random_number_generator &_rng)
Description not yet available.
Definition: drangam.cpp:311
dvar_vector operator()(int i)
Definition: fvar.hpp:8228
void save_double_value(const double x)
Description not yet available.
Definition: cmpdif8.cpp:90
lvector & operator[](int i)
Definition: fvar.hpp:7555
double Psi_0
Definition: fvar.hpp:3670
preivector(ivector *_p, int _lb, int _ub)
Definition: fvar.hpp:627
dvariable invlogit(dvariable x)
Inverse logit function.
sing_val_decomp singval_decomp(const dmatrix &_a)
Singular value decomposition.
Definition: dmat42.cpp:71
double gs
Definition: fvar.hpp:4984
void slave_gradcalc(void)
banded_lower_triangular_dmatrix & operator=(const banded_lower_triangular_dmatrix &)
Assigment operator.
Definition: dmat43.cpp:19
dvector extract_column(const dmatrix &matrix, int j)
Extract copy of jth column vector from matrix m.
Definition: dmat6.cpp:34
const dvar3_array & elem(int i) const
Definition: fvar.hpp:5495
dvar3_array sub(int, int)
Description not yet available.
Definition: f3arr.cpp:37
ivector sgn(const dvector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dvect24.cpp:11
~dvar7_array()
Description not yet available.
Definition: f7arr.cpp:124
double inv_cumd_beta_stable(double a, double b, double y, double eps)
virtual double_index_guts * operator[](int i)
Definition: fvar.hpp:8638
i3_array(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: i3arr.cpp:8
dvar_vector sub(int lb, int ub)
Definition: fvar.hpp:2198
static int no_ln_det_choleski_flag
Definition: fvar.hpp:8841
double ** m
Definition: fvar.hpp:3237
int get_offset(void)
Definition: multiindex.cpp:47
int rowmax(void)
Definition: fvar.hpp:5856
dvector xb
Definition: fvar.hpp:4995
void default_evaluation4(void)
Description not yet available.
Definition: def_eval.cpp:251
virtual int indexmax(void)
Definition: fvar.hpp:8613
i5_array & operator=(const i5_array &)
friend prevariable & atan2(const prevariable &t1, const prevariable &t2)
Description not yet available.
Definition: fvar_fn1.cpp:274
mat_shapex * shape
Definition: fvar.hpp:2485
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
Holds the data for the prevariable class.
Definition: fvar.hpp:191
friend banded_lower_triangular_dmatrix value(const banded_lower_triangular_dvar_matrix &v)
Description not yet available.
Definition: fvar_m40.cpp:130
void save_dvar_matrix_position() const
Description not yet available.
Definition: cmpdif5.cpp:341
unsigned long int get_last_offset()
Definition: fvar.hpp:2095
d3_array(void)
Default constructor.
Definition: d3arr10.cpp:20
void set_gradient_stack(void(*func)(void), double *dep_addr, double *ind_addr1=NULL, double mult1=0, double *ind_addr2=NULL, double mult2=0)
Description not yet available.
Definition: fvar.hpp:1045
d3_array * t
Definition: fvar.hpp:5164
void exit_handler(int k)
Description not yet available.
Definition: signalh.cpp:20
Description not yet available.
Definition: fvar.hpp:5769
int colsize()
Definition: fvar.hpp:5301
dvar4_array & operator()(int i)
Definition: fvar.hpp:6582
void colfill(int j, const dvar_vector &v)
Fills column of a matrix with a vector (supplied)
Definition: ranfill1.cpp:118
friend double max(const dvector &)
Returns the maximum value of vector vec.
Definition: dvect7.cpp:85
friend dvar_vector elem_div(const dvar_vector &, const dvar_vector &)
Element-wise division of v1 by v2 into a dvar_vector.
Definition: fvar_a46.cpp:29
void set_value_inv_partial(const dvector &x, const dvector &v, const int &ii, int n)
Description not yet available.
Definition: setin.cpp:192
int slicesize()
Definition: fvar.hpp:5879
dvector w
Definition: fvar.hpp:3338
virtual int dimension() const
Definition: fvar.hpp:7877
void save_pointer_value(void *ptr)
Description not yet available.
Definition: cmpdif8.cpp:118
#define dmax(a, b)
Definition: cbivnorm.cpp:191
friend void df_check_derivative_values(void)
Description not yet available.
Definition: newdar.cpp:364
dvar_matrix & elem(int i)
? Retrieves an element of a dvar3_array.
Definition: fvar.hpp:4315
void deallocate(void)
Deallocate d6_array memory.
Definition: d6arr.cpp:59
double inv_cumd_logistic(const double &x)
Description not yet available.
Definition: ccumdlog.cpp:30
dvariable ln_det_choleski_error(const dvar_matrix &, int &ierr)
Description not yet available.
Definition: fvar_m51.cpp:304
friend dvar_vector sfabs(const dvar_vector &)
Description not yet available.
Definition: fvar_ar3.cpp:102
virtual int isinteger() const
Definition: fvar.hpp:7775
d3_array mfexp(const d3_array &m)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr7.cpp:10
int operator==(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:17
dmatrix a
Definition: fvar.hpp:9189
dmatrix fillout_trans(const lower_triangular_dmatrix &M)
Description not yet available.
Definition: dmat36.cpp:130
dvariable(const double t)
Creates dvariable instance from a double constant.
Definition: fvar.hpp:1552
dvar_vector_position()
Default constructor.
Definition: cmpdif2.cpp:32
void save_dvar_matrix_position() const
Description not yet available.
Definition: cmpdif11.cpp:109
long imax
Definition: fvar.hpp:3186
~i5_array()
Destructor.
Definition: i5arr.cpp:40
int j
Definition: fvar.hpp:3636
double nd2fboundp(double x, double fmin, double fmax, const double &fpen)
Scale input variable between upper and lower bounds and compute a penalty for exceeding the bounds...
Definition: boundfun.cpp:282
Description not yet available.
Definition: fvar.hpp:7500
dvector_position restore_dvector_position()
Description not yet available.
Definition: cmpdif4.cpp:84
const d4_array & operator()(int i, int j) const
Definition: fvar.hpp:6790
Description not yet available.
Definition: fvar.hpp:5161
const dvar_matrix & operator[](int i) const
Definition: fvar.hpp:4358
const d3_array & elem(int i, int j) const
Definition: fvar.hpp:6395
int ifnex
Definition: fvar.hpp:3660
void *& elem(int i)
Definition: fvar.hpp:601
unsigned long int max_last_offset
Definition: fvar.hpp:2069
d6_array & operator()(int i)
Definition: fvar.hpp:7146
d3_array & operator=(const d3_array &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr8.cpp:82
void deallocate(void)
Deallocate i4_array memory.
Definition: i4arr.cpp:216
int rowmin(void)
Definition: fvar.hpp:5852
dvar_vector & elem(int i, int j, int k)
Definition: fvar.hpp:5487
int operator!(void) const
Definition: fvar.hpp:2207
void rowfill_randn_ni(const int &i, long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:189
void * get_pointer(void)
Definition: fvar.hpp:2046
lmatrix restore_lmatrix_value(const lmatrix_position &)
double xtol
Definition: fvar.hpp:5744
void save_dmatrix_position(void) const
void write_on(const ostream &) const
Description not yet available.
Definition: fvara_io.cpp:48
dmatrix & operator--(void)
Definition: fvar.hpp:2829
int rowmin(void) const
Definition: fvar.hpp:8083
dvar3_array & operator=(const d3_array &m1)
Assign element values from scalar arr3 to dvar3_array.
Definition: f3arr13.cpp:19
double dmin
Definition: fvar.hpp:3297
dvar_vector ln_pareto_density(const dvar_vector &_y, const prevariable &alpha, const prevariable &xm)
ad_double(double _d)
Definition: fvar.hpp:8513
double sfabs(const double v1)
Description not yet available.
Definition: dvect14.cpp:20
int * ncopies
Definition: fvar.hpp:7718
void default_evaluation1(void)
Description not yet available.
Definition: def_eval.cpp:93
double & elem(int i, int j, int k, int l, int _m, int _n)
Definition: fvar.hpp:6729
dvector & operator[](int)
Definition: fvar.hpp:3087
dvector d
Definition: fvar.hpp:4996
int operator!(void) const
Definition: fvar.hpp:6087
void deallocate(void)
Description not yet available.
Definition: dfsdmat.cpp:223
int slicesize() const
Definition: fvar.hpp:5666
int colmax(void) const
Definition: fvar.hpp:4041
void shallow_copy(const d3_array &)
Shallow copy other data structure pointers.
Definition: d3arr.cpp:688
long int ic
Definition: fvar.hpp:3350
double rho_0
Definition: fvar.hpp:3681
double log_density_cauchy(const double &x)
Description not yet available.
Definition: cumd_cau.cpp:39
banded_lower_triangular_dmatrix choleski_decomp_trust_bound(const banded_symmetric_dmatrix &_M, const int &_ierr)
Description not yet available.
Definition: dmat43.cpp:41
dvar5_array & operator=(const d5_array &)
Description not yet available.
Definition: f5arr.cpp:146
dvar3_array(void)
Default constructor.
Definition: f3arr17.cpp:11
friend dvar_matrix inv(const dvar_matrix &)
Inverse of a varaiable matrix.
Definition: fvar_m15.cpp:43
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
Definition: dmat34.cpp:46
void allocate(int mmin, int mmax, int n, int m)
Definition: hs_sparse.cpp:2577
humungous_pointer ARRAY_MEMBLOCK_BASE
Definition: fvar.hpp:2074
int indexmax() const
Definition: fvar.hpp:6650
dvector coffs
Definition: fvar.hpp:5128
double randu(const random_number_generator &rng)
Uniform random number generator.
Definition: rngen.cpp:198
prescientific setscientific(void)
Description not yet available.
Definition: admanip.cpp:80
friend prevariable & tanh(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:160
double & xval()
Definition: fvar.hpp:4452
void shallow_copy(const dvar_matrix &)
Shallow copy other data structure pointers.
Definition: fvar_mat.cpp:459
int slicesize() const
Definition: fvar.hpp:6231
Description not yet available.
Definition: admodel.h:2718
dvector * xbest
Definition: fvar.hpp:3655
friend dvariable sumsq(const dvar_vector &)
Definition: fvar_ar3.cpp:96
double zz
Definition: fvar.hpp:3351
Description not yet available.
Definition: fvar.hpp:8828
void fill_randbi_ni(long int &n, double)
Description not yet available.
Definition: ranf_ni2.cpp:33
static int print_hess_and_exit_flag
Definition: fvar.hpp:8838
void df_check_derivative_values(void)
Description not yet available.
Definition: newdar.cpp:364
int & operator()(int i, int j, int k)
Definition: fvar.hpp:4147
void reset_max_last_offset()
Definition: fvar.hpp:2107
unsigned long int last_offset
Definition: fvar.hpp:2068
double dmin
Definition: fvar.hpp:5738
virtual int indexmin(void)
Definition: fvar.hpp:8609
friend double * address(const prevariable &v1)
Definition: fvar.hpp:1500
void save_dmatrix_position(void) const
Description not yet available.
Definition: fvar.hpp:7951
double bounder(double x, double min, double max, double scale)
Description not yet available.
fmmq(int nvar)
int colmin(void) const
Definition: fvar.hpp:5337
int slicemax(void) const
Definition: fvar.hpp:5325
friend char * fform(const char *, const dmatrix &)
void arr_free(double_and_int *varr)
Description not yet available.
Definition: newdar.cpp:227
dvariable cumd_bivariate_normal(const prevariable &xu, const prevariable &yu, const prevariable &rho, int nbox)
int rowmin(void) const
Definition: fvar.hpp:7592
virtual int dimension() const
Definition: fvar.hpp:7700
dvector gsave
Definition: fvar.hpp:4992
dmatrix sort(const dmatrix &m, int column, int NSTACK)
Description not yet available.
Definition: dmsort.cpp:17
long int nn
Definition: fvar.hpp:3301
dmatrix symmetrize(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat12.cpp:14
dvar_compressed_triplet(int mmin, int mmax, int n, int m)
Definition: hs_sparse.cpp:2560
dvar_matrix & operator+=(const dvar_matrix &x)
Description not yet available.
Definition: fvar_m11.cpp:17
dvar_vector & operator-=(const prevariable &d)
Substracts d from each element of dvar_vector.
Definition: fvar_a30.cpp:17
friend dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat2.cpp:13
smart_counter()
Default constructor.
Definition: indextyp.cpp:35
Description not yet available.
Definition: admodel.h:2813
int colmax(void)
Definition: fvar.hpp:6152
dvector restore_dvar_matrix_derivative_row(const dvar_matrix_position &_pos, const int &ii)
Description not yet available.
Definition: cmpdif6.cpp:216
dmatrix atlas_solve_spd_trans(const dmatrix &M, const dmatrix &x)
Description not yet available.
Definition: fvar.hpp:8354
int igwindow
Definition: fvar.hpp:5000
prnstream & endl(prnstream &)
int indexmax() const
Definition: fvar.hpp:6194
dmatrix eigenvectors(const banded_symmetric_dmatrix &_SS, const dvector &_e)
Description not yet available.
Definition: dmat28.cpp:442
void fill_randu_ni(long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:160
double fbest
Definition: fvar.hpp:3297
vector_shape(int lb, int lu)
Definition: fvar.hpp:547
ivector & operator()(void)
Definition: fvar.hpp:9230
~i3_array()
Destructor.
Definition: i3arr.cpp:13
int size() const
Definition: fvar.hpp:590
Description not yet available.
Definition: fvar.hpp:1937
d6_array * t
Definition: fvar.hpp:7057
d4_array & elem(int i, int j)
Definition: fvar.hpp:6713
double besselK(double x, int nu)
Definition: cbessel.cpp:279
double boundpin(double x, double fmin, double fmax, double s)
Scale model variable over [-1,1]; constant objects.
Definition: boundfun.cpp:378
friend dvar_matrix trans(const dvar_matrix &)
Description not yet available.
Definition: fvar_m44.cpp:19
dvar_vector operator()(int lb, int ub)
Definition: fvar.hpp:2202
independent_variables(int ncl, int ncu)
Definition: fvar.hpp:1949
dmatrix restore_dmatrix_value(const dmatrix_position &mpos)
Description not yet available.
Definition: cmpdif5.cpp:96
void allocate(void)
Does NOT allocate, but set empty i3_array.
Definition: i3arr.cpp:237
Description not yet available.
Definition: fvar.hpp:7632
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
unsigned int get_ncopies() const
Definition: fvar.hpp:4406
friend dvar_vector log(const dvar_vector &)
Description not yet available.
Definition: fvar_a29.cpp:236
prevariable(double_and_int *u)
Definition: fvar.hpp:1320
virtual ~index_guts()
Destructor.
Definition: indextyp.cpp:26
void shallow_copy(const i4_array &)
Shallow copy other data structure pointers.
Definition: i4arr.cpp:194
double gso
Definition: fvar.hpp:4984
const dvar_matrix & elem(int i, int j, int k) const
Definition: fvar.hpp:6569
double dmin
Definition: fvar.hpp:3348
double_index(double i)
Definition: fvar.hpp:8621
dvector solve_trans(const lower_triangular_dmatrix &M, const dvector &y)
Description not yet available.
Definition: dmat36.cpp:80
Description not yet available.
Definition: fvar.hpp:4902
int slicemax(void)
Definition: fvar.hpp:6136
friend dvar_vector first_difference(const dvar_vector &)
Returns a dvector containing the differences of an x(i) and x(i + 1) for i = 1 to x...
Definition: fvar_dif.cpp:15
double gam
Definition: fvar.hpp:3664
virtual ~double_index_guts()
Description not yet available.
Definition: doublind.cpp:177
int rowmax() const
Definition: fvar.hpp:2929
int operator()(void) const
Definition: fvar.hpp:609
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2c.cpp:11
dmatrix identity_matrix(int min, int max)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat17.cpp:14
dvector * d
Definition: fvar.hpp:3649
dvar5_array & operator()(int i)
Definition: fvar.hpp:6952
long int i1
Definition: fvar.hpp:3299
long ihang
Definition: fvar.hpp:3192
prevariable_position(double_and_int *p)
Definition: fvar.hpp:4448
long int n1
Definition: fvar.hpp:4983
double fbest
Definition: fvar.hpp:3348
dvector * begin() const
Definition: fvar.hpp:2900
dvar_vector & get_x(void)
Definition: fvar.hpp:9327
double avg(double x, double y)
Average of two numbers; constant objects.
Definition: dvector.cpp:42
dmatrix & hessian()
Undefined.
dvector cumd_upper_trunc_pareto(const dvector &_y, double alpha, double xm)
void dmdm_prod(void)
Description not yet available.
Definition: fvar_m14.cpp:126
int colsize() const
Definition: fvar.hpp:4305
void fill_randu(long int &n)
Fill matrix with random numbers.
Definition: ranfill.cpp:286
uostream(const char *name, int mode=ios::out|ios::binary, int prot=0664)
Definition: ufstream.cpp:27
dvector get_w(void)
Definition: fvar.hpp:9201
friend dvar_vector exp(const dvar_vector &)
Description not yet available.
Definition: fvar_a29.cpp:117
double gmax
Definition: fvar.hpp:4987
void fill_randn_ni(long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:130
int scroll_flag
Definition: fvar.hpp:3193
dvector return_choleski_decomp_solve(dcompressed_triplet &dct, dvector &eps)
Definition: hs_sparse.cpp:2670
int just_to_link_fvar1
virtual ~vector_index()
Destructor.
Definition: indextyp.cpp:191
dvector rowsum(const dmatrix &matrix)
Returns dvector where each element contains the sum total of each row in matrix.
Definition: dvect12.cpp:61
void gradfree(dlink *v)
Description not yet available.
Definition: fvar2.cpp:65
prevariable elem(int i) const
Definition: fvar.hpp:2236
void initialize(void)
Description not yet available.
Definition: dmat41.cpp:17
const dvar5_array & elem(int i) const
Definition: fvar.hpp:6927
dvar_matrix & operator/=(const prevariable &t)
Description not yet available.
Definition: fvar_m28.cpp:55
int indexmax() const
Definition: fvar.hpp:4831
d3_array sub(int, int)
Description not yet available.
Definition: d3arr.cpp:40
double var(const dvector &vec)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: cranfill.cpp:23
friend prevariable & sinh(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:244
dvar3_array & elem(int i, int j, int k, int l)
Definition: fvar.hpp:7317
int rowmin(void)
Definition: fvar.hpp:5274
ad_double & operator=(const ad_double &)=delete
friend void funnel_derivatives(void)
Description not yet available.
unsigned long int get_max_last_offset()
Definition: fvar.hpp:2103
int operator!(void) const
Definition: fvar.hpp:6362
double gs
Definition: fvar.hpp:3300
dvariable dfatan1(dvariable x, double fmin, double fmax, const prevariable &_fpen)
Scale input variable between upper and lower bounds and compute a penalty for exceeding the bounds...
Definition: boundfun.cpp:37
int rowsize() const
Definition: fvar.hpp:6236
double right_bracket
Definition: fvar.hpp:3679
double df
Definition: fvar.hpp:3348
const d3_array & operator[](int i) const
Definition: fvar.hpp:5405
int slicesize() const
Definition: fvar.hpp:5362
void arr_free_remove(arr_link *tmp)
Description not yet available.
Definition: newdar.cpp:44
banded_lower_triangular_dmatrix(const dvar_matrix_position &mpos)
Description not yet available.
Definition: dmat28.cpp:165
dependent_variables_information(int ndv)
Description not yet available.
Definition: depvars.cpp:86
dvar_vector & elem(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:6919
friend dvar_vector sin(const dvar_vector &)
Computes sin of each element in v1 to a dvar_vector.
Definition: fvar_a29.cpp:67
int row_min
Definition: fvar.hpp:2006
ad_double()=delete
const dmatrix & operator()(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:7198
void fmin2(const double &f, const independent_variables &x, const dvector &g, function_minimizer *)
Description not yet available.
Definition: xfmmtr1.cpp:105
virtual int indexmax() const
Definition: fvar.hpp:7912
virtual int indexmax(void)=0
int indexmax() const
Definition: fvar.hpp:5897
void colfill_randu(const int &j, long int &n)
Description not yet available.
Definition: ranfill2.cpp:82
void deallocate()
Deallocate dvar_matrix memory.
Definition: fvar_mat.cpp:487
#define min(a, b)
Definition: cbivnorm.cpp:188
double restore_prevariable_value()
Description not yet available.
Definition: cmpdif8.cpp:164
double rho_min
Definition: fvar.hpp:3667
int rowmax(void)
Definition: fvar.hpp:6144
friend void copy_status(const ostream &s, const dvar_vector &v)
Description not yet available.
Definition: fvar_arr.cpp:206
dvector gbest
Definition: fvar.hpp:3306
void set_value_partial(const dvar_vector &x, const dvar_vector &v, const int &ii, int n)
Description not yet available.
Definition: set.cpp:323
Description not yet available.
Definition: fvar.hpp:3398
Derived class of index types for imatrix.
Definition: fvar.hpp:7837
static int argc
Definition: fvar.hpp:8863
dmatrix get_u(void)
Definition: fvar.hpp:9197
int n
Definition: fvar.hpp:3310
unsigned int nlinks
Definition: fvar.hpp:837
void operator-=(const prevariable &t1)
Description not yet available.
Definition: fvar_o11.cpp:34
long int ib
Definition: fvar.hpp:4985
Description not yet available.
Definition: fvar.hpp:6498
dvar_matrix empirical_covariance(const dvar_matrix &v1)
Description not yet available.
Definition: fvar_ma6.cpp:128
int lb
Definition: fvar.hpp:1904
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
long int iter
Definition: fvar.hpp:3639
dvar_vector * p
Definition: fvar.hpp:1920
friend void grad_chk(void)
Description not yet available.
Definition: gradchk.cpp:18
double fa
Definition: fvar.hpp:5008
int slicemin(void) const
Definition: fvar.hpp:5626
int xm
Definition: fvar.hpp:3340
Description not yet available.
Definition: admodel.h:2675
int ir
Definition: fvar.hpp:5001
prevariable elem(int i, int j, int k, int l, int _m, int _n)
Definition: fvar.hpp:6923
timeval tv
Definition: fvar.hpp:8903
void allocate(void)
Description not yet available.
Definition: f6arr2.cpp:26
long int iu
Definition: fvar.hpp:4985
void colfill_randu_ni(const int &j, long int &n)
Description not yet available.
Definition: ranf_ni.cpp:74
dvar_matrix & elem(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:7321
ivector & colmin(void)
Definition: fvar.hpp:4863
double & operator()(int i, int j)
Definition: fvar.hpp:8030
dvar_vector & operator+=(const prevariable &d)
Adds d to each element of dvar_vector.
Definition: fvar_a30.cpp:55
dvector ga
Definition: fvar.hpp:4997
long int llog
Definition: fvar.hpp:4983
int rowmax(void) const
Definition: fvar.hpp:8087
double & elem(int i, int j, int k, int l, int _m, int _n, int _p)
Definition: fvar.hpp:7117
void fill_multinomial(const int &seed, const dvector &p)
Description not yet available.
Definition: fvar_a47.cpp:17
preshowpoint setshowpoint(void)
Description not yet available.
Definition: admanip.cpp:38
dvar3_array & elem(int i)
Definition: fvar.hpp:5479
arr_link * get_last() const
Definition: fvar.hpp:2092
ad_double(const ad_double &other)
Definition: fvar.hpp:8516
void save_dvar_vector_value() const
Saves the size, address, and value information for a dvar_vector.
Definition: cmpdif4.cpp:102
int rowmax(void) const
Definition: fvar.hpp:6210
Description not yet available.
Definition: fvar.hpp:5060
friend char * fform(const char *, const dmatrix &)
dlink ** dlink_addresses
Definition: fvar.hpp:838
Description not yet available.
Definition: fvar.hpp:4947
friend dvariable norm(const banded_symmetric_dvar_matrix &B)
Description not yet available.
Definition: fvar_m40.cpp:701
int rowsize() const
Definition: fvar.hpp:5671
dvariable inv_cumd_normal_logistic_mixture(const prevariable &_yy, double a)
Definition: cnorlogmix.cpp:87
dvector funval
Definition: fvar.hpp:3339
void allocate(void)
Does not allocate, but initializes members.
Definition: fvar_mat.cpp:479
arr_link * link_ptr
Definition: fvar.hpp:2178
virtual ~double_index()
Definition: fvar.hpp:8618
Description not yet available.
Definition: fvar.hpp:9187
void normalized_gauss_hermite(const dvector &_x, const dvector &_w)
Gauss-Hermite quadature.
Definition: gaussher.cpp:343
int slicemax(void) const
Definition: fvar.hpp:5913
vector_shapex * shape
Definition: fvar.hpp:5771
d7_array & operator=(const d7_array &)
Assign element values from other to d7_array.
Definition: d7arr.cpp:90
prevariable elem(int i, int j, int k, int l)
Definition: fvar.hpp:5491
friend uistream & operator>>(const uistream &, const dfsdmat &)
Description not yet available.
Definition: dfsdmat.cpp:300
const dvar_matrix & elem(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:7349
timeval tvold
Definition: fvar.hpp:8904
double get_elapsed_time_and_reset(void)
Returns elapsed time in milliseconds of timer object and then resets the timer to current time...
Definition: timer.cpp:31
uostream & operator<<(const char *)
Definition: fvar.hpp:3461
int rowmin(void) const
Definition: fvar.hpp:5917
dvector w
Definition: fvar.hpp:9190
void operator++(void)
Definition: multiindex.cpp:22
double colsum(const dmatrix &m, int col)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat27.cpp:10
int colsize() const
Definition: fvar.hpp:6241
const prevariable operator()(int i, int j, int k, int l, int _m, int _n, int _p) const
Definition: fvar.hpp:7425
void save_dmatrix_derivatives_na(const dvar_matrix_position &pos) const
Description not yet available.
Definition: cmpdif5.cpp:312
size_t true_length
Definition: fvar.hpp:931
int indexmin() const
Definition: fvar.hpp:6646
int m
Definition: fvar.hpp:5735
long ifn
Definition: fvar.hpp:3188
void fill_randu_ni(long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:60
unsigned int incr_ncopies(void)
Definition: fvar.hpp:543
ivector histogram(double min, double max, int nbin, const dvector &input)
Description not yet available.
Definition: histgram.cpp:17
void deallocate(void)
Deallocate dvar4_array memory.
Definition: f4arr.cpp:66
unsigned int get_ncopies() const
Definition: fvar.hpp:7229
dvariable log_der_logistic(double a, double b, const prevariable &x)
Description not yet available.
Definition: logit.cpp:35
d5_array()
Description not yet available.
Definition: d5arr3.cpp:17
double minimize(const independent_variables &x, double(*pf)(const dvar_vector &))
Minimize artibrary user-supplied function.
Definition: minim.cpp:23
double sgamma(double a, const random_number_generator &_rng)
Description not yet available.
Definition: drangam.cpp:44
struct cs_symbolic css
Definition: fvar.hpp:9404
Functions and variables for function minimizer.
Definition: fvar.hpp:3290
vcubic_spline_function(const dvector &_x, const dvar_vector &_y, double yp1=0.0, double ypn=0.0)
Description not yet available.
Definition: vspline.cpp:82
void rowshift(int min)
Description not yet available.
Definition: fvar_ma9.cpp:17
Description not yet available.
Definition: fvar.hpp:8120
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
dvar4_array sub(int, int)
Description not yet available.
Definition: f4arr.cpp:49
void create_gradfile()
Description not yet available.
Definition: gradstak.cpp:432
dvector cumd_pareto(const dvector &_y, double alpha, double xm)
arr_link * free_last
Definition: fvar.hpp:2067
Description not yet available.
Definition: fvar.hpp:622
int colmin(void)
Definition: fvar.hpp:5282
adtimer(void)
Default constructor.
Definition: timer.cpp:19
void set_gradstack_flag(char *str)
Description not yet available.
Definition: cmpdif3.cpp:82
int indexmin() const
Definition: ivector.h:99
dvector * gbest
Definition: fvar.hpp:3656
unsigned int get_ncopies() const
Definition: fvar.hpp:6246
dvar6_array & elem(int i)
Definition: fvar.hpp:7305
int smbfct_(int *neqns, ivector &xadj, ivector &adjncy, ivector &perm, ivector &invp, ivector &xlnz, int *maxlnz, ivector &xnzsub, ivector &nzsub, int *maxsub, ivector &rchlnk, ivector &mrglnk, ivector &marker, int *flag__)
void save_dmatrix_derivatives(const dvar_matrix_position &pos) const
Description not yet available.
Definition: cmpdif5.cpp:285
dmatrix choleski_decomp_error(const dmatrix &MM, int &ierror)
Description not yet available.
Definition: dmat15.cpp:111
int iu
Definition: fvar.hpp:3302
vector_shape * shape
Definition: fvar.hpp:571
#define M
Definition: rngen.cpp:57
int itn
Definition: fvar.hpp:3353
dvector * m
Definition: fvar.hpp:2824
friend prevariable & asin(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:191
ptr_vector ptr
Definition: fvar.hpp:4850
i3_index(i3_array &v)
Definition: fvar.hpp:7873
dfsdmat h
Definition: fvar.hpp:3293
void default_evaluation(void)
Description not yet available.
Definition: def_eval.cpp:61
static int no_pvm_flag
Definition: fvar.hpp:8839
double rho_1
Definition: fvar.hpp:3673
Description not yet available.
Definition: fvar.hpp:9345
const d3_array & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:7130
humungous_pointer ARRAY_MEMBLOCK_SAVE
Definition: fvar.hpp:2075
ad_double(const double &_d, const adkludge &)
Definition: fvar.hpp:8510
int frp_flag
Definition: fvar.hpp:3662
Description not yet available.
Definition: fvar.hpp:497
int slicemin() const
Definition: fvar.hpp:3826
banded_symmetric_dvar_matrix(int _min, int _max, int _bw)
Description not yet available.
Definition: fvar_m40.cpp:102
const dvar5_array & elem(int i, int j) const
Definition: fvar.hpp:7337
dvector xsave
Definition: fvar.hpp:4991
Description not yet available.
Definition: fvar.hpp:1901
static _THREAD gradient_structure * _instance
imatrix & operator[](int i)
Definition: fvar.hpp:4123
int rowmax(void) const
Definition: fvar.hpp:4049
long int np
Definition: fvar.hpp:3352
void allocate(int, int)
Allocate array [ncl,...,nch].
Definition: ptr_vec.cpp:131
friend ostream & operator<<(const ostream &, const dvar_matrix_position &)
void deallocate(void)
Deallocates i5_array memory if no copies exists.
Definition: i5arr.cpp:144
int hslicemax() const
Definition: fvar.hpp:5905
virtual int indexmin() const
Definition: fvar.hpp:7881
#define OFF_T
Definition: fvar.hpp:74
virtual index_guts * operator[](int i)
Definition: fvar.hpp:7895
int colmin(void) const
Definition: fvar.hpp:2939
int indexmax() const
Definition: fvar.hpp:6816
dmatrix & operator-=(const dmatrix &t)
Substract element-wise matrix values other from dmatrix.
Definition: dmat4.cpp:100
dmatrix outer_prod(const dvector &v1, const dvector &v2)
Description not yet available.
Definition: dmat23.cpp:17
void insert_identifier_string(const char *s)
Description not yet available.
Definition: newdar.cpp:336
int shared_memory
Definition: fvar.hpp:3240
int size()
Definition: fvar.hpp:5874
void rowfill_seqadd(const int &, double, double)
Fills vector with a sequence of the form base, base+offset, base+2*offset,...
Definition: ranfill1.cpp:96
d5_array & elem(int i, int j)
Definition: fvar.hpp:7097
friend dvariable norm2(const dvar_vector &)
Description not yet available.
Definition: fvar_ar3.cpp:87
double * getminp(void)
Definition: fvar.hpp:3249
dmatrix restore_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Definition: cmpdif5.cpp:70
int indexmax() const
Definition: fvar.hpp:7764
~d4_array()
Destructor.
Definition: d4arr.cpp:132
double stmin
Definition: fvar.hpp:5012
int indexmin() const
Definition: fvar.hpp:7028
friend dvar_vector fabs(const dvar_vector &)
Description not yet available.
Definition: fvar_ar3.cpp:17
virtual double_index_guts * operator[](int i)
Definition: fvar.hpp:8690
friend prevariable & cos(const prevariable &t1)
Description not yet available.
Definition: fvar_fn.cpp:178
int istart
Definition: fvar.hpp:5003
void df_check_derivative_values_indexed_break(void)
Description not yet available.
Definition: newdar.cpp:479
int indexmax() const
Definition: ivector.h:104
lmatrix_position restore_lmatrix_position(void)
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:2819
char * ddlist_space
Definition: fvar.hpp:839
void rowfill_randn_ni(const int &i, long int &n)
Description not yet available.
Definition: ranf_ni.cpp:189
i4_array()
Default constructor.
Definition: i4arr.cpp:26
long int ic
Definition: fvar.hpp:4983
d4_array & elem(int i)
Definition: fvar.hpp:6371
int slicemin(void) const
Definition: fvar.hpp:6198
dvector * h
Definition: fvar.hpp:3647
prevariable_position restore_prevariable_position(void)
int indexmin(void) const
Definition: fvar.hpp:8131
double betai(const double a, const double b, const double x, int maxit)
Incomplete beta function for constant objects.
Definition: cbetai.cpp:21
banded_symmetric_dmatrix & operator=(const banded_symmetric_dmatrix &)
Description not yet available.
Definition: dmat28.cpp:365
dmatrix column_vector(const dvector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dvect13.cpp:10
Description not yet available.
Definition: fvar.hpp:5730
double dgs
Definition: fvar.hpp:3351
Description not yet available.
Definition: fvar.hpp:1284
void shallow_copy(const d6_array &)
Shallow copy other data structure pointers.
Definition: d6arr.cpp:42
dvar_matrix sub(int, int)
Description not yet available.
Definition: fvar_mat.cpp:153
int use_control_c
Definition: fvar.hpp:3199
void ad_getcd(const adstring &s)
Description not yet available.
Definition: makesub.cpp:56
void shift(int)
Description not yet available.
Definition: dmat28.cpp:125
friend void gradcalc(int nvar, const dvector &g)
Definition: sgradclc.cpp:77
int operator!(void) const
Definition: fvar.hpp:6534
void write_on(const ostream &) const
Description not yet available.
Definition: fvarm_io.cpp:49
friend double & value(const prevariable &v1)
Definition: fvar.hpp:1495
void allocate(void)
Description not yet available.
Definition: f5arr3.cpp:26
lmatrix_position(const lmatrix &)
four_array_shape * shape
Definition: fvar.hpp:5163
unsigned int get_ncopies() const
Definition: fvar.hpp:7466
ptr_vector & operator=(const ptr_vector &t)
Copy values from _t to this.
Definition: ptr_vec.cpp:87
unsigned int hslicesize() const
Definition: fvar.hpp:5660
int quit_flag
Definition: fvar.hpp:3195
void initialize(void)
Initializes all elements of d3_array to zero.
Definition: d3arr.cpp:705
static ad_double make_ad_double(double _d)
Definition: fvar.hpp:8521
ivector lb
Definition: fvar.hpp:4888
void fill_randn_ni(long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:116
double cc
Definition: fvar.hpp:5006
dfunction_tweaker(double eps, double mult)
Description not yet available.
Definition: dftweak.cpp:17
dmatrix * end() const
Definition: fvar.hpp:3813
dvar4_array * t
Definition: fvar.hpp:6501
int index_min
Definition: fvar.hpp:2482
virtual int indexmin(void)
Definition: fvar.hpp:8646
unsigned long * mt
the array for the state vector
Definition: fvar.hpp:7953
const dvar4_array & elem(int i) const
Definition: fvar.hpp:6561
void set_value(const dvar_matrix &x, const dvar_vector &v, const int &_ii, double s)
Description not yet available.
Definition: set.cpp:235
Description not yet available.
Definition: fvar.hpp:4197
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: i4arr.cpp:9
unsigned int ncopies
Copy counter to enable shallow copies.
Definition: vector_shapex.h:79
unsigned int k
Definition: fvar.hpp:5019
dvector xbest
Definition: fvar.hpp:5741
AD_LONG_INT & operator[](int i)
Definition: fvar.hpp:742
int indexmax(void) const
Definition: fvar.hpp:8135
grad_stack_entry * ptr_first
Definition: fvar.hpp:924
double_and_int * v
pointer to the data
Definition: fvar.hpp:1333
double norm2(const d3_array &a)
Return sum of squared elements in a.
Definition: d3arr2a.cpp:167
Description not yet available.
Definition: fvar.hpp:5124
spdll_exception(int _e=0)
Definition: fvar.hpp:7941
matrix_index(const imatrix &v)
Definition: fvar.hpp:7845
virtual int isdouble_(void) const
Definition: fvar.hpp:8604
dmatrix xstep
Definition: fvar.hpp:3341
dvector & elem(int i)
Definition: fvar.hpp:3011
double gys
Definition: fvar.hpp:4984
const dvar_vector operator()(int i) const
Definition: fvar.hpp:8236
int disk_save_flag
Definition: fvar.hpp:3235
dfsdmat()
Default constructor.
Definition: dfsdmat.cpp:109
void rowfill_seqadd(const int &, double, double)
Fills dmatrix row at index with elements with values starting from base and incremented by offset...
Definition: cranfill.cpp:148
dmatrix MAT(const dvector &v, int n, int m)
The MAT operator is the inverse of the VEC operator.
Definition: dmat29.cpp:45
dvector & elem(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:6725
double fill_seqadd(double, double)
Description not yet available.
Definition: dmat21.cpp:35
void fill_randn_ni(long int &n)
Description not yet available.
Definition: ranf_ni.cpp:130
dvector gold
Definition: fvar.hpp:3346
dvariable(const int &t)
Creates dvariable instance from a int constant.
Definition: fvar.hpp:1565
random_number_generator(const int seed)
Constructor for random_number_generator class.
Definition: rngen.cpp:70
dmatrix orthpoly(int n, int deg)
Description not yet available.
Definition: orthpoly.cpp:17
int save_identifier_string(const char *)
Writes a gradient stack verification string.
Definition: cmpdif2.cpp:315
const dmatrix & operator()(int i, int j, int k, int l) const
Definition: fvar.hpp:6798
double robust_normal_logistic_mixture_deviate(double x, double spread)
Description not yet available.
Definition: cnorlogmix.cpp:118
i4_array * t
Definition: fvar.hpp:6070
void colfill(int j, const dvector &v)
Fills dmatrix column at index column with values from vec.
Definition: cranfill.cpp:123
~dmatrix()
Destructor.
Definition: dmat.cpp:326
void restore(void)
Restore values to file.
Definition: dfsdmat.cpp:367
Description not yet available.
Definition: fvar.hpp:9293
long ihang
Definition: fvar.hpp:3641
int operator!(void) const
Definition: fvar.hpp:7508
dvector restore_dvar_vector_value(const dvar_vector_position &tmp)
Restores the size, address, and value information for a dvar_vector.
Definition: cmpdif4.cpp:227
int rowmin(void)
Definition: fvar.hpp:5579
int maxfn_flag
Definition: fvar.hpp:3687
const dvar_vector & elem(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:6943
fmmt1(int nvar, int _xm=7)
Description not yet available.
Definition: fmmt1.cpp:35
unsigned int ncopies
Definition: fvar.hpp:2034
~dfsdmat()
Destructor.
Definition: dfsdmat.cpp:214
double ln_det(const dmatrix &m1, int &sgn)
Compute log determinant of a constant matrix.
Definition: dmat3.cpp:536
int colmin(void) const
Definition: fvar.hpp:7584
Description not yet available.
Definition: dfpool.h:106
void set_value_inv(const dvar_matrix &x, const dvector &v, const int &ii, double s)
Description not yet available.
Definition: setin.cpp:412
virtual ~matrix_index()
Destructor.
Definition: indextyp.cpp:536
friend prevariable & log10(const prevariable &t1)
Description not yet available.
Definition: fvar_fn.cpp:210
void restore_variables()
Restore variables from buffer.
Definition: ddlist.cpp:155
static cifstream * global_datafile
Definition: fvar.hpp:8856
long int n1
Definition: fvar.hpp:3299
index_type operator[](int i)
Description not yet available.
Definition: indextyp.cpp:169
double dftinv(double x, double fmin, double fmax)
Inverse of dvariable dfatan1(dvariable x, double fmin, double fmax, const prevariable&amp; _fpen) ...
Definition: boundfun.cpp:66
const dmatrix & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:6742
Description not yet available.
Definition: fvar.hpp:5110
double & elem(int i, int j)
Definition: fvar.hpp:3015
void ad_begin_funnel(void)
Description not yet available.
Definition: xgradclc.cpp:386
dvector restore_dvar_vector_der_nozero(const dvar_vector_position &tmp)
Description not yet available.
Definition: cmpdif5.cpp:185
int nvar
Definition: fvar.hpp:5746
int option_match(int argc, char *argv[], const char *string)
Checks if the program has been invoked with a particular command line argument (&quot;string&quot;).
Definition: optmatch.cpp:25
int dcheck_flag
Definition: fvar.hpp:3198
int colsize()
Definition: fvar.hpp:5616
void save_dvar_matrix_position() const
Description not yet available.
Definition: cmpdif11.cpp:100
mat_shapex(const void *m)
Definition: fvar.hpp:2035
dvar_vector & operator--(void)
Definition: fvar.hpp:2184
adstring str(double x, int minwidth=17, int decplaces=-1)
Convert x to adstring with minimum width and total number of decimal places.
Definition: str.cpp:25
void operator/=(const prevariable &d)
Description not yet available.
Definition: f7arr1.cpp:72
int ireturn
Definition: fvar.hpp:3661
static char option_flags[]
Definition: fvar.hpp:8862
void initialize()
Description not yet available.
Definition: multiindex.cpp:65
int indexmin() const
Definition: fvar.hpp:5305
void save_ad_pointer(void *p)
Description not yet available.
Definition: cmpdif3.cpp:226
friend ostream & operator<<(const ostream &, const pre_column_print &)
Description not yet available.
Definition: dvect23.cpp:17
virtual int indexmin(void)
Definition: fvar.hpp:8698
int operator!(void) const
Definition: fvar.hpp:3253
int indexmax() const
Definition: fvar.hpp:2921
~dvar_vector()
Destructor.
Definition: fvar_ar1.cpp:10
double & operator()(const int &i)
Get element i from dvar_vector_position.
Definition: cmpdif2.cpp:62
std::ostream & get_output_stream()
Definition: adglobl.cpp:45
unsigned int rowsize() const
Definition: fvar.hpp:2578
int slicemin(void)
Definition: fvar.hpp:5266
double gys
Definition: fvar.hpp:3300
Description not yet available.
Definition: fvar.hpp:5138
double mult1
First mutiplicand in chain rule multipication.
Definition: fvar.hpp:901
void initialize()
Initialize all elements of i3_array to zero.
Definition: i3arr.cpp:243
dvector column_value(const dvar_matrix &m, int i)
Description not yet available.
Definition: fvar_ar7.cpp:57
void initialize()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: f5arr.cpp:12
dlink * create()
Return new unlinked node.
Definition: ddlist.cpp:75
void fill_randu(long int &n)
int colmin(void)
Definition: fvar.hpp:5860
int rowmin(void) const
Definition: fvar.hpp:5329
int indexmin() const
Definition: fvar.hpp:2287
dvector csolve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
Definition: dmat34.cpp:32
int admin(int i, int j)
Definition: fvar.hpp:8987
void save_lmatrix_position(void)
dvariable & operator=(const double x)
Assigns a value to a dvariable object.
Definition: fvar.hpp:1595
prevariable & operator+=(const prevariable &)
Prevariable addition assignment operator.
Definition: fvar_op9.cpp:36
dvector_position(void)
Default constructor.
Definition: cmpdif2.cpp:95
double_and_int * v
Definition: fvar.hpp:4442
int iu
Definition: fvar.hpp:3353
Description not yet available.
Definition: fvar.hpp:2001
Description not yet available.
Definition: fvar.hpp:3335
void fill_seqadd(const AD_LONG_INT &, const AD_LONG_INT &)
Fills ivector elements with values starting from base and incremented by offset.
Definition: cranfill.cpp:88
double alpha
Definition: fvar.hpp:4984
void initialize(void)
Description not yet available.
Definition: fvar_a24.cpp:17
void * trueptr
Definition: fvar.hpp:2033
const int output
Definition: fvar.hpp:9505
void operator/=(const prevariable &d)
Description not yet available.
Definition: f6arr1.cpp:90
int operator!(void) const
Definition: fvar.hpp:2503
d6_array & operator=(const d6_array &)
Assigns element values from other to d6_array.
Definition: d6arr.cpp:93
int index_min
Definition: fvar.hpp:2176
virtual int indexmin() const
Definition: fvar.hpp:7908
void rowfill(int j, const dvar_vector &v)
Fills row of a matrix with a vector (supplied)
Definition: ranfill1.cpp:137
Float betacf(Float a, Float b, Float x, int MAXIT)
Definition: betacf_val.hpp:13
friend prevariable & operator+(const prevariable &v1, const prevariable &v2)
Description not yet available.
Definition: fvar_opr.cpp:50
int ad_kill_flag
Definition: newdar.cpp:23
virtual ~ad_comm()
Destructor.
Definition: model7.cpp:555
void shallow_copy(const d7_array &)
Shallow copy other data structure pointers.
Definition: d7arr.cpp:42
void put_address(unsigned int &i, double *iaddress)
Definition: fvar.hpp:1296
double sig
Definition: fvar.hpp:3351
void save_d3_array_position() const
Description not yet available.
Definition: cmpdif6.cpp:59
dvar_matrix tensor_prod(const dvar_matrix &a, const dvar_matrix &b)
The tensor product of two dvar_matrixes.
Definition: tensprod.cpp:24
prevariable & operator=(const prevariable &)
Assigns a value to a prevariable object.
Definition: fvar_o10.cpp:61
int operator<=(const prevariable &v1) const
Description not yet available.
Definition: fvar_opr.cpp:92
int rowsize() const
Definition: fvar.hpp:5367
int indexmax(void) const
Definition: fvar.hpp:2572
int scroll_flag
Definition: fvar.hpp:3635
double stepbd
Definition: fvar.hpp:5013
double lower_triangular_ln_det(const dmatrix &m)
double gs
Definition: fvar.hpp:3351
Holds &quot;shape&quot; information for vector objects.
Definition: vector_shapex.h:46
const dvar_vector & elem(int i, int j, int k) const
Definition: fvar.hpp:5503
friend char * fform(const char *, const dvar_vector &)
int maxd
Definition: fvar.hpp:9225
void deallocate(void)
Deallocate d5_array memory.
Definition: d5arr.cpp:67
dvariable ghk_choleski_m(const dvar_vector &upper, const dvar_matrix &ch, const dmatrix &eps)
Description not yet available.
Definition: v_ghk.cpp:136
double fbest
Definition: fvar.hpp:3682
void save_variables()
Save variables to a buffer.
Definition: sgradclc.cpp:353
int indexmin() const
Definition: fvar.hpp:6475
int traceflag
Definition: fvar1.cpp:18
int indexmin() const
Definition: fvar.hpp:4932
friend prevariable & sin(const prevariable &t1)
Description not yet available.
Definition: fvar_fn.cpp:65
dmatrix make_dmatrix(dcompressed_triplet &M)
Definition: hs_sparse.cpp:202
d3_array & elem(int i, int j, int k, int l)
Definition: fvar.hpp:7105
dvector & elem(int i, int j, int k, int l, int _m, int _n)
Definition: fvar.hpp:7113
double * initpointer(void)
Definition: fvar.hpp:2347
unsigned int size() const
Definition: fvar.hpp:6820
~d3_array()
Destructor.
Definition: d3arr.cpp:748
d3_array cos(const d3_array &arr3)
Returns d3_array results with computed cos from elements in arr3.
Definition: d3arr2a.cpp:58
int indexmax() const
Definition: fvar.hpp:557
int & gradfile_handle()
Definition: gradstak.cpp:534
void shallow_copy(const d5_array &)
Shallow copy pointers from other data structure.
Definition: d5arr.cpp:50
const d5_array & elem(int i, int j) const
Definition: fvar.hpp:7122
Description not yet available.
friend banded_lower_triangular_dmatrix restore_banded_lower_triangular_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Definition: cmpdif11.cpp:78
int ib
Definition: fvar.hpp:3302
void initialize()
Description not yet available.
Definition: d4arr.cpp:534
void * farptr_norm(void *)
virtual int indexmax(void)
Definition: fvar.hpp:8702
void save_dvar_vector_position() const
Description not yet available.
Definition: cmpdif3.cpp:210
dvector coffs
Definition: fvar.hpp:5114
unsigned long int number_arr_links
Definition: fvar.hpp:2071
dvector xrho
Definition: fvar.hpp:3342
long int icc
Definition: fvar.hpp:3301
void funnel_gradcalc()
Definition: xgradclc.cpp:86
int n
Definition: fvar.hpp:3241
dvar_matrix()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_mat.cpp:15
istream & operator>>(const istream &input, const d3_array &arr3)
Read values from input stream into arr3.
Definition: d3_io.cpp:60
Description not yet available.
Definition: dfpool.h:56
sdmatrix()
Default constructor.
Definition: sdmat.cpp:23
const prevariable operator()(int k, int i, int j) const
Definition: fvar.hpp:4343
void fill_randn_ni(long int &n)
const index_type * a
Definition: fvar.hpp:7640
void deallocate(void)
Deallocates d4_array memory.
Definition: d4arr.cpp:107
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int rowmax(void) const
Definition: fvar.hpp:4295
double gasdev(const random_number_generator &_rng)
Description not yet available.
Definition: drangam.cpp:292
dvector xsave
Definition: fvar.hpp:3307
grad_stack_entry * ptr
Definition: fvar.hpp:934
void ** v
Definition: fvar.hpp:570
dmatrix orthpoly_constant_begin_end(int n, int deg, int nconst_begin, int enddeg, int nconst_end)
Description not yet available.
Definition: orthpoly.cpp:143
void arr_free_add(arr_link *tmp)
Description not yet available.
Definition: newdar.cpp:68
imatrix & elem(int i, int j)
Definition: fvar.hpp:5817
ostream & operator<<(const ostream &_s, preshowpoint p)
Description not yet available.
Definition: admanip.cpp:48
friend void df_check_derivative_values_indexed_break(void)
Description not yet available.
Definition: newdar.cpp:479
int slicemin(void) const
Definition: fvar.hpp:5909
long int ic
Definition: fvar.hpp:3299
dvector_index(const dvector &v)
Description not yet available.
Definition: doublind.cpp:190
void operator/=(const prevariable &d)
Description not yet available.
Definition: f5arr2.cpp:72
friend void copy_status(const ostream &s, const dvar_matrix &m1)
Description not yet available.
Definition: fvar_mat.cpp:584
double eps
Definition: fvar.hpp:5743
friend double norm2(const banded_symmetric_dmatrix &B)
Definition: dmat38.cpp:239
void operator*=(const prevariable &v1)
Description not yet available.
Definition: fvar_op5.cpp:122
dmatrix diagonal_matrix(const dvector &v)
unsigned int colsize() const
Definition: fvar.hpp:7606
dvar3_array * t
Definition: fvar.hpp:5436
d5_array & operator()(int i)
Definition: fvar.hpp:6754
d4_array & operator[](int i)
Definition: fvar.hpp:6416
friend char * fform(const char *, const prevariable &)
AD_LONG_INT & operator()(int i)
Definition: fvar.hpp:746
ivector ub
Definition: fvar.hpp:4889
vector_shape * shape
Definition: fvar.hpp:6500
void allocate(void)
Description not yet available.
Definition: d5arr3.cpp:26
int colmin(void)
Definition: fvar.hpp:5587
void save_dmatrix_position() const
Saves size and address information for a dmatrix to adjoint data file.
Definition: cmpdif6.cpp:27
const prevariable elem(int i, int j, int k, int l, int _m, int _n, int _p) const
Definition: fvar.hpp:7357
int J
Definition: fvar.hpp:3637
long ihflag
Definition: fvar.hpp:3191
int read_grad_stack_buffer(OFF_T &lpos)
Description not yet available.
Definition: gst_read.cpp:76
void default_evaluation4ind(void)
Description not yet available.
Definition: def_eval.cpp:205
d3_array & elem(int i)
Definition: fvar.hpp:5220
double * xadr()
Definition: fvar.hpp:1410
long int iv
Definition: fvar.hpp:4985
void allocate(void)
Does not allocte, but initialize class members.
Definition: f3arr17.cpp:18
lower_triangular_dmatrix lower_triangular_choleski_decomp_positive(const dmatrix &MM, const int &_ierr)
Description not yet available.
Definition: dmat35.cpp:171
banded_symmetric_dmatrix(void)
Definition: fvar.hpp:8012
virtual index_guts * operator[](int i)
Description not yet available.
Definition: indextyp.cpp:526
int indexmax() const
Definition: fvar.hpp:5309
banded_symmetric_dmatrix sub(int l, int u)
Description not yet available.
Definition: dmat28.cpp:402
dvar_matrix & operator=(const dvar_matrix &)
Assigns other values to dvar_matrix.
Definition: fvar_mat.cpp:515
int operator>(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:44
int operator<=(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:26
dvector inv_cumd_upper_trunc_pareto(const dvector &_y, double alpha, double xmin, double xmax)
friend class qd3_array
Definition: fvar.hpp:3716
virtual ~dvariable()
Destructor; frees memory on gradient stack.
Definition: fvar.hpp:1587
double dgs
Definition: fvar.hpp:3300
double_index_type operator()(int i)
Description not yet available.
Definition: doublind.cpp:136
friend prevariable & sfabs(const prevariable &t1)
Smooth absolute value.
Definition: fvar_fn.cpp:125
double regression(const dvector &obs, const dvector &pred)
Description not yet available.
Definition: cregress.cpp:17
void allocate(void)
Description not yet available.
Definition: f7arr2.cpp:26
int colsize()
Definition: fvar.hpp:5889
mat_shape * shape
Definition: fvar.hpp:7504
dvector * funval
Definition: fvar.hpp:3643
const dvar3_array & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:7345
vector_shape * shape
Definition: fvar.hpp:7056
char var_store_file_name[61]
Definition: fvar.hpp:938
int indexmax() const
Definition: fvar.hpp:6479
friend void gradloop()
dvariable & operator=(const prevariable &other)
Assigns a value to a dvariable object.
Definition: fvar.hpp:1606
void rowshift(int min)
Changes the range of valid indices for the rows.
Definition: dmat9.cpp:48
friend banded_symmetric_dmatrix restore_banded_symmetric_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Definition: cmpdif11.cpp:55
double randn(const random_number_generator &rng)
Normal number generator.
Definition: rngen.cpp:183
size_t pos(const adstring &substr, const adstring &s)
Definition: string3.cpp:56
dvar7_array & operator=(const d7_array &)
Description not yet available.
Definition: f7arr.cpp:161
prevariable elem(int i, int j, int k, int l, int _m, int _n, int _p)
Definition: fvar.hpp:7329
friend dvar_vector operator*(const dvar_vector &, const dvar_matrix &)
Description not yet available.
Definition: fvar_m23.cpp:20
int rowmax(void)
Definition: fvar.hpp:5278
void fill(const char *s)
Description not yet available.
Definition: ivec4.cpp:28
Description not yet available.
Definition: fvar.hpp:9410
double randpoisson(double xm, const random_number_generator &rng)
Poisson random deviates.
Definition: dranpois.cpp:37
int mti
mti==N+1 means mt[N] is not initialized
Definition: fvar.hpp:7954
int colsize()
Definition: fvar.hpp:6178
Link list.
Definition: fvar.hpp:834
int & rowmax(void)
Definition: fvar.hpp:4859
dvector xx
Definition: fvar.hpp:3356
int size() const
Definition: fvar.hpp:5937
void shallow_copy(const dvar3_array &)
Shallow copy other data structure pointers.
Definition: f3arr.cpp:653
Support functions for factor.
vector_range_exception(int i, int imin, int imax)
Description not yet available.
Definition: except.cpp:17
ivector index
Definition: fvar.hpp:9227
ivector restore_ivector_value(const ivector_position &tmp)
Description not yet available.
Definition: cmpdif4.cpp:198
independent_variables(unsigned int sz, double *x)
Definition: fvar.hpp:1954
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
int colsize(void) const
Definition: fvar.hpp:3864
void read_from(const istream &)
Description not yet available.
Definition: dmat_io.cpp:91
#define w
const dvar6_array & elem(int i) const
Definition: fvar.hpp:7333
int i
Definition: fvar.hpp:4986
index_type(const int x)
Description not yet available.
Definition: indextyp.cpp:78
int hslicemax() const
Definition: fvar.hpp:5624
int indexmin() const
Definition: fvar.hpp:7451
double minimize(const independent_variables &x, double(*pf)(const dvar_vector &))
dmatrix & operator++(void)
Definition: fvar.hpp:2836
double inv_cumd_cauchy(const double &x)
Description not yet available.
Definition: cumd_cau.cpp:49
int operator!(void) const
Definition: fvar.hpp:3953
double eps
Definition: ftweak.cpp:13
double crit1
Definition: fvar.hpp:3672
three_array_shape * shape
Definition: fvar.hpp:3947
pre_double_index_type(const double_index_type *_a, int _i)
Definition: fvar.hpp:8490
int indexmin(void) const
Definition: fvar.hpp:7995
const dvector & operator()(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:6802
lvector * m
Definition: fvar.hpp:7503
const dvar3_array & elem(int i, int j) const
Definition: fvar.hpp:6565
dvar_vector ln_pareto_upper_trunc_density(const dvar_vector &y, const prevariable &alpha, const prevariable &xmin, const prevariable &xmax)
int diagco
Definition: fvar.hpp:5736
int operator!(void) const
Definition: fvar.hpp:5185
dvector restore_dvar_vector_derivatives(const dvar_vector_position &tmp)
Description not yet available.
Definition: cmpdif5.cpp:150
char gradfile_name[61]
Definition: fvar.hpp:935
long int ifn
Definition: fvar.hpp:3638
void save_int_value(int x)
Description not yet available.
Definition: cmpdif8.cpp:104
dvariable dfboundp(const prevariable &x, double fmin, double fmax)
Computes the derivative of dvariable boundp(const prevariable&amp; x, double fmin, double fmax...
Definition: boundfun.cpp:170
~index_type()
Destructor.
Definition: indextyp.cpp:125
void shallow_copy(const dvar_vector &)
Shallow copy other data structure pointers.
Definition: fvar_ar1.cpp:59
dvariable mf_upper_bound(const prevariable &x, double M, prevariable &fpen)
Description not yet available.
Definition: mfupper.cpp:17
void initialize()
Initialize all elements of d5_array to zero.
Definition: d5arr.cpp:117
dvector * theta
Definition: fvar.hpp:3654
int is
Definition: fvar.hpp:3353
Description not yet available.
Definition: admodel.h:2873
unsigned int get_ncopies() const
Definition: fvar.hpp:5684
Description not yet available.
Definition: fvar.hpp:6067
double z
Definition: fvar.hpp:4984
d4_array & operator=(const d4_array &)
Assigns element values from other to d4_array.
Definition: d4arr.cpp:141
void restore_variables()
Restore variables from buffer.
Definition: sgradclc.cpp:360
double ln_det_choleski(const banded_symmetric_dmatrix &MM, int &ierr)
Definition: dmat38.cpp:218
void colfill_randu(const int &j, long int &n)
Fill random numbers into specified column j of matrix.
Definition: ranfill.cpp:204
dvector * end() const
Definition: fvar.hpp:2904
unsigned int get_ncopies() const
Definition: fvar.hpp:4089
const double & elem_value(int i, int j) const
Definition: fvar.hpp:2681
Description not yet available.
Definition: fvar.hpp:8960
dmatrix get_v(void)
Definition: fvar.hpp:9205
~d7_array()
Destructor.
Definition: d7arr.cpp:83
virtual int indexmin() const =0
dmatrix & operator[](int i)
Definition: fvar.hpp:3934
int integer() const
Definition: indextyp.cpp:181
dvariable operator()(const prevariable &)
Description not yet available.
Definition: dftweak.cpp:51
long int ib
Definition: fvar.hpp:3352
dvector gsave
Definition: fvar.hpp:3308
void shift(int)
Description not yet available.
Definition: dmat28.cpp:115
void deallocate(void)
Deallocate dvar7_array memory.
Definition: f7arr.cpp:96
double fy
Definition: fvar.hpp:4984
double alpha
Definition: fvar.hpp:3300
int slicemin(void) const
Definition: fvar.hpp:5321
friend prevariable & exp(const prevariable &t1)
Compute exponential variable.
Definition: fvar_fn1.cpp:22
void save_d3_array_value() const
Description not yet available.
Definition: cmpdif5.cpp:46
char * address
Definition: lbfgs.cpp:32
double & elem(int i, int j, int k, int l)
Definition: fvar.hpp:5232
int indexmax() const
Definition: fvar.hpp:4025
double & operator()(int k, int i, int j)
Definition: fvar.hpp:3922
void set_value_inv_exp(const prevariable &x, const dvector &_v, const int &_ii, double fmin, double fmax, double s)
double logistic(double a, double b, const double &x)
arr_list()
Definition: fvar.hpp:2078
d7_array()
Description not yet available.
Definition: d7arr2.cpp:18
dvector extract_row(const dmatrix &matrix, int i)
Returns a copied row for matrix at i.
Definition: dmat6.cpp:66
dvector w
Definition: fvar.hpp:5733
double & elem(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:6387
static int bandwidth
Definition: fvar.hpp:8837
Description not yet available.
Definition: fvar.hpp:6331
unsigned int size_count(const dvector &x)
Returns total size of elements in vector x.
Definition: dsize.cpp:17
d3_array & elem(int i, int j, int k)
Definition: fvar.hpp:6717
~sdmatrix()
Destructor.
Definition: sdmat.cpp:73
unsigned int get_ncopies() const
Definition: fvar.hpp:7043
uistream(const char *name, int mode=ios::in|ios::binary, int prot=0664)
Description not yet available.
Definition: ufstream.cpp:54
dvariable boundp(const prevariable &x, double fmin, double fmax, const prevariable &_fpen, double s)
Compute penalty for exceeding bounds on parameter; variable ojbects.
Definition: boundfun.cpp:89
double cumd_exponential(double x)
Description not yet available.
Definition: ccumdexp.cpp:26
void colshift(int min)
Description not yet available.
Definition: dmat9.cpp:68
const dmatrix & elem(int i, int j) const
Definition: fvar.hpp:5240
void fill_randn(long int &n)
Description not yet available.
Definition: ranfill2.cpp:172
dvector & elem(int i, int j, int k, int l)
Definition: fvar.hpp:6383
int operator!=(const prevariable &v1) const
Description not yet available.
Definition: fvar_opr.cpp:128
dvector w
Definition: fvar.hpp:4979
dvector sinh(const dvector &vec)
Returns dvector with hyperbolic sine for each value of vec.
Definition: dvect6.cpp:84
int slicemax() const
Definition: fvar.hpp:4033
dvariable dtweedie(const double y, dvariable &mu, dvariable &phi, dvariable &p, const bool use_log)
dtweedie is a wrapper to _dtweedie using ADMB data types.
Definition: dtweedie.cpp:59
double & elem(int i, int j)
Definition: fvar.hpp:3277
dvector choleski_solve_error(dmatrix M, dvector &v, int &ierror)
Description not yet available.
Definition: dmat37.cpp:198
prevariable()=delete
Default constructor.
int slicesize()
Definition: fvar.hpp:6168
fmm_control()
Default constructor.
Definition: fmm_cont.cpp:83
void shallow_copy(const dmatrix &)
Shallow copy values and dimensions from other to dmatrix.
Definition: dmat.cpp:307
friend class dd3_array
Definition: fvar.hpp:3715
void rowfill_randn(const int &i, long int &n)
Description not yet available.
Definition: ranfill2.cpp:154
unsigned int size() const
Definition: fvar.hpp:7459
dvar_vector & elem(int i, int j, int k, int l)
Definition: fvar.hpp:6553
dvector xx
Definition: fvar.hpp:3305
void read_from(const istream &)
double min_improve
Definition: fvar.hpp:3196
i4_array & elem(int i)
Definition: fvar.hpp:6248
double df
Definition: fvar.hpp:3297
int indexmax() const
Definition: fvar.hpp:7032
int slicemax(void)
Definition: fvar.hpp:5270
ivector_position restore_ivector_position()
Description not yet available.
Definition: cmpdif4.cpp:45
void * restore_pointer_value()
Description not yet available.
Definition: cmpdif8.cpp:212
void rowfill_randn(const int &i, long int &n)
Fill random numbers into specified row i of matrix.
Definition: ranfill.cpp:315
void colfill_seqadd_ni(const int &, double, double)
void save_dmatrix_value() const
Description not yet available.
Definition: cmpdif11.cpp:46
void shallow_copy(const dvar6_array &)
Shallow copy other data structure pointers.
Definition: f6arr.cpp:39
int cmp(hs_symbolic &S)
double dgs
Definition: fvar.hpp:4984
int colsize() const
Definition: fvar.hpp:5952
virtual int isinteger() const
Definition: fvar.hpp:7696
double_index_type operator[](int i)
Description not yet available.
Definition: doublind.cpp:127
dmatrix v
Definition: fvar.hpp:9191
Description not yet available.
Definition: admodel.h:1850
int tmp_file
Definition: fvar.hpp:3234
friend void gradloop()
unsigned int slicesize() const
Definition: fvar.hpp:4277
size_t length
Definition: fvar.hpp:930
friend void gradcalc(int nvar, const dvector &g)
Definition: sgradclc.cpp:77
void reset_gradient_stack(void)
Rewind buffer.
Definition: sgradclc.cpp:367
static streampos change_datafile_name(const adstring &s, const streampos &off=0)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: model17.cpp:15
Description not yet available.
Definition: fvar.hpp:4975
double sign(const double x)
The sign of a number.
Definition: gaussher.cpp:25
double * maxp
Definition: fvar.hpp:3239
Description not yet available.
Definition: df12fun.h:54
double & operator()(int i)
Definition: fvar.hpp:9366
three_array_shape * shape
Definition: fvar.hpp:4200
void shallow_copy(const dvar5_array &)
Shallow copy other data structure pointers.
Definition: f5arr.cpp:59
unsigned int rowsize() const
Definition: fvar.hpp:2934
prevariable operator()(int i, int j)
Definition: fvar.hpp:2667
void set_gradient_stack0(void(*func)(void), double *dep_addr)
Description not yet available.
Definition: gradstak.cpp:565
double converge_flag
Definition: fvar.hpp:3668
void operator/=(double d)
Divide all elements of d7_array by divisor.
Definition: d7arr1.cpp:27
double cumd_cauchy(const double &x)
Description not yet available.
Definition: cumd_cau.cpp:17
int quit_flag
Definition: fvar.hpp:3642
Description not yet available.
Definition: fvar.hpp:7262
int size()
Definition: fvar.hpp:6163
const dvector operator()(int i) const
Definition: fvar.hpp:8172
dvariable & operator=(const dvariable &other)
Definition: fvar.hpp:1611
~dvar4_array()
Destructor.
Definition: f4arr.cpp:91
unsigned int get_ncopies() const
Definition: fvar.hpp:2765
predvector(dvector *_p, int _lb, int _ub)
Definition: fvar.hpp:1906
int indexmin() const
Definition: fvar.hpp:3818
Description not yet available.
Definition: fvar.hpp:3516
double fy
Definition: fvar.hpp:3351
int * v
Definition: ivector.h:55
int indexmin() const
Definition: fvar.hpp:7214
dvariable(const dvariable &t)
Copy constructor for dvariable object; deep copy.
Definition: fvar.hpp:1540
#define AD_LONG_INT
Definition: fvar.hpp:81
const d3_array & operator()(int i, int j, int k) const
Definition: fvar.hpp:6794
double * ptr
Definition: fvar.hpp:3236
unsigned int get_ncopies() const
Definition: fvar.hpp:6662
ivector cp
Definition: fvar.hpp:9422
const dmatrix & elem(int i, int j, int k) const
Definition: fvar.hpp:6399
d4_array sub(int, int)
Description not yet available.
Definition: d4arr.cpp:64
friend void default_evaluation(void)
Description not yet available.
Definition: def_eval.cpp:61
void fill(const char *)
Fill allocated dmatrix with values from input parameter s.
Definition: dmat10.cpp:29
double cumbvn(const double &x, const double &y, const double &rho)
Cumulative bivariate normal distribution.
Definition: cbivnorm.cpp:267
void deallocate()
Deallocate dvar_vector memory.
Definition: fvar_ar1.cpp:15
friend dmatrix operator+(const dmatrix &, const dmatrix &)
Description not yet available.
Definition: dmat16.cpp:40
double dot(const dmatrix &M, const dmatrix &d2)
Description not yet available.
Definition: orthply2.cpp:88
int _GRADFILE_PTR
Definition: fvar.hpp:942
double alpha
Definition: fvar.hpp:3351
friend dvariable norm(const dvar_matrix &)
Description not yet available.
Definition: fvar_ma3.cpp:67
dvector operator()(int i)
Definition: fvar.hpp:8034
dvar4_array()
Default Constructor.
Definition: f4arr3.cpp:14
dvar_vector & elem(int i) const
Definition: fvar.hpp:2515
unsigned int ncopies
Definition: fvar.hpp:5140
double cumd_norm_logistic(double _x, double p)
Description not yet available.
Definition: ccumdlog.cpp:78
double cumd_logistic(const double &x)
Description not yet available.
Definition: ccumdlog.cpp:13
friend banded_symmetric_dmatrix value(const banded_symmetric_dvar_matrix &v)
Description not yet available.
Definition: fvar_m40.cpp:114
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
dmatrix & elem(int k)
Definition: fvar.hpp:3870
int rowsize() const
Definition: fvar.hpp:5947
dvar_vector ln_upper_trunc_pareto_density(const dvar_vector &_y, const prevariable &alpha, const prevariable &xm)
dvector xold
Definition: fvar.hpp:3345
dvariable cumd_normal_cauchy_mixture(const prevariable &_x, double _a)
double gl2
Definition: fvar.hpp:5018
double rho_i
Definition: fvar.hpp:3676
dvector column(const dmatrix &matrix, int j)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat6.cpp:13
vector_shape_pool(const size_t n)
Definition: fvar.hpp:484
dvar_vector & operator=(const dvar_vector &t)
Assign values from other t to dvar_vector.
Definition: fvar_a20.cpp:31
double tot
Definition: fvar.hpp:3300
double_and_int * va
Definition: fvar.hpp:2175
int colsize() const
Definition: fvar.hpp:5676
friend dvar_vector second_difference(const dvar_vector &)
void default_evaluation4m(void)
Description not yet available.
Definition: def_eval.cpp:265
int operator<(const prevariable &v1) const
Description not yet available.
Definition: fvar_opr.cpp:101
double fill_seqadd(double, double)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr9.cpp:15
void write_on(const ostream &) const
dvar_vector & operator()(int i)
Definition: fvar.hpp:2776
void save_dmatrix_value(void) const
void nograd_assign_column(const dvar_matrix &m, const dvector &v, const int &ii)
Description not yet available.
Definition: cmpdif6.cpp:389
int rowsize()
Definition: fvar.hpp:5296
prevariable_position restore_prevariable_position()
Description not yet available.
Definition: cmpdif8.cpp:39
int indexmin() const
Definition: fvar.hpp:4956
d4_array & operator()(int i)
Definition: fvar.hpp:6412
dvector xa
Definition: fvar.hpp:4994
void(* exitptr)(int)
Definition: fvar.hpp:180
void RETURN_ARRAYS_INCREMENT(void)
Increments gradient_structure::RETURN_ARRAYS_PTR.
Definition: gradstrc.cpp:474
int col_min
Definition: fvar.hpp:2008
dvariable(const prevariable &t)
Constructor for dvariable object from its base class; deep copy.
Definition: fvar.hpp:1579
virtual double_index_guts * operator[](int i)
Description not yet available.
Definition: doublind.cpp:218
friend void gradcalc(int nvar, const dvector &g)
Definition: sgradclc.cpp:77
const dvector operator()(int i) const
Definition: fvar.hpp:8042
void read_from(const istream &)
Description not yet available.
Definition: fvara_io.cpp:94
unsigned int slicesize() const
Definition: fvar.hpp:3853
int make_sub_directory(const char *s)
Create a sub directory s.
Definition: makesub.cpp:95
const dvar_vector & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:6573
void va13c(const dvector &x, double f, const dvector &g)
int hslicemin() const
Definition: fvar.hpp:5901
long int iconv
Definition: fvar.hpp:3299
const double * initpointer(void) const
Definition: fvar.hpp:2351
unsigned long int get_number_arr_links()
Definition: fvar.hpp:2099
Description not yet available.
Definition: fvar.hpp:2064
double log_density_poisson(double x, double mu)
Log Poisson density; constant objects.
Definition: cnegbin.cpp:61
void initialize()
Initializes elements of i4_array to zero.
Definition: i4arr.cpp:15
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
double df
Definition: fvar.hpp:5738
void fill_seqadd(double, double)
Description not yet available.
Definition: ranfill1.cpp:33
Description not yet available.
Definition: fvar.hpp:8534
int operator!(void) const
Definition: fvar.hpp:605
void set_gradient_stack2(void(*func)(void), double *dep_addr, double *ind_addr1, double mult1)
Description not yet available.
Definition: fvar.hpp:1202
dvector VEC(const dmatrix &_m)
The VEC operator concatenates the columns of matrix M into a column vector.
Definition: dmat29.cpp:17
unsigned int slicesize() const
Definition: fvar.hpp:4054
dvector * g2
Definition: fvar.hpp:3651
double_and_int *& get_v()
Definition: fvar.hpp:1419
Stores integer.
Definition: fvar.hpp:7654
dvar_vector_position restore_dvar_vector_position()
Description not yet available.
Definition: cmpdif4.cpp:65
dvector * left_bracket_gradient
Definition: fvar.hpp:3644
int rowmin(void) const
Definition: fvar.hpp:4045
static cifstream * global_parfile
Definition: fvar.hpp:8857
void save_double_derivative(const double x, const prevariable_position &_pos)
Description not yet available.
Definition: cmpdif8.cpp:28
i3_array & operator[](int j)
Definition: fvar.hpp:5987
dvariable(kkludge_object)
Specialized constructor that does not create unnecessary entries in the gradient structure; see funct...
Definition: fvar.hpp:1570
Description not yet available.
Definition: fvar.hpp:3944
friend double ln_det(const dmatrix &m1, int &sgn)
Compute log determinant of a constant matrix.
Definition: dmat3.cpp:536
void rowfill_randu_ni(const int &i, long int &n)
Description not yet available.
Definition: ranf_ni.cpp:88
static int no_atlas_flag
Definition: fvar.hpp:8840
vector_shape * shape
Definition: fvar.hpp:7264
static _THREAD grad_stack * GRAD_STACK1
void colshift(int min)
Description not yet available.
Definition: fvar_ma9.cpp:28
dvector gb
Definition: fvar.hpp:4998
long iprint
Definition: fvar.hpp:3183
#define max(a, b)
Definition: cbivnorm.cpp:189
friend prevariable & acos(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:175
Description not yet available.
Definition: fvar.hpp:766
double & xvalue()
Return the value of the variable.
Definition: fvar.hpp:202
void check_choleski_decomp(const banded_symmetric_dvar_matrix &MM, int &ierr)
friend prevariable & cosh(const prevariable &t1)
Description not yet available.
Definition: fvar_fn1.cpp:259
const d4_array & elem(int i, int j, int k) const
Definition: fvar.hpp:7126
dvector diag
Definition: fvar.hpp:5742
int operator!(void) const
Definition: fvar.hpp:5458
void report_gradstack_flag(void)
Description not yet available.
Definition: cmpdif3.cpp:36
unsigned int size() const
Definition: fvar.hpp:6654
int operator!(void) const
Definition: fvar.hpp:3733
d3_array_position restore_d3_array_position()
Description not yet available.
Definition: cmpdif6.cpp:89
int hslicemin() const
Definition: fvar.hpp:5313
int n
Definition: fvar.hpp:3361
ivector * p
Definition: fvar.hpp:624
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
long int llog
Definition: fvar.hpp:3350
Description not yet available.
Definition: fvar.hpp:3727
friend void default_evaluation(void)
Description not yet available.
Definition: def_eval.cpp:61
void deallocate()
Description not yet available.
Definition: lmat.cpp:168
dvariable posfun2(const dvariable &x, const double eps, const prevariable &pen)
Retuns a positive function of the argument and sets a penalty for .
Definition: posfunv.cpp:88
void save_dmatrix_derivatives(const dvar_matrix_position &_pos, const double x, const int &i, int &j)
Description not yet available.
Definition: cmpdif5.cpp:265
const dvar4_array & elem(int i, int j) const
Definition: fvar.hpp:6931
void free()
Description not yet available.
Definition: humung.cpp:34
void fill(const char *)
Fill values of dvar_matrix with text input from s with format rowmin...rowmax where ith row is {colmi...
Definition: fvar_m10.cpp:50
ad_integer(const int _d)
Definition: fvar.hpp:7668
int index_max
Definition: fvar.hpp:2483
dvariable ghk_choleski_m_cauchy(const dvar_vector &upper, const dvar_matrix &ch, const dmatrix &eps)
Description not yet available.
Definition: v_ghk.cpp:217
dvar7_array()
Description not yet available.
Definition: f7arr2.cpp:17
Class object for init_bounded_number vector.
Definition: admodel.h:2915
void fill_randn(long int &n)
Description not yet available.
Definition: ranfill2.cpp:208
dmatrix orthpoly_constant_begin(int n, int deg, int nconst)
Description not yet available.
Definition: orthpoly.cpp:75
const dmatrix & elem(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:7134
double_and_int * va
Definition: fvar.hpp:4825
void colfill_randu_ni(const int &j, long int &n)
Description not yet available.
Definition: ranf_ni2.cpp:74
double cumd_norm(const double &x)
Culative normal distribution; constant objects.
Definition: cumdist.cpp:90
friend void reset_gradient_stack(void)
Rewind buffer.
Definition: sgradclc.cpp:367
prevariable operator()(int i)
Definition: fvar.hpp:9312
dvector * right_bracket_gradient
Definition: fvar.hpp:3645
friend double sumsq(const dmatrix &)
Calls norm2.
Definition: dmat2.cpp:69
int slicemax(void)
Definition: fvar.hpp:5848
int & elem(int i, int j, int k, int l)
Definition: fvar.hpp:5825
void initialize()
Description not yet available.
Definition: f6arr.cpp:18
double gys
Definition: fvar.hpp:3351
void fill_randpoisson(double lambda, const random_number_generator &rng)
Description not yet available.
Definition: franpois.cpp:17
prefixed setfixed(void)
Description not yet available.
Definition: admanip.cpp:59
ivector as_factor(const dvector &v, const double eps)
Definition: factors.cpp:34
friend void funnel_gradcalc(void)
Description not yet available.
Definition: xgradclc.cpp:76
double beta_deviate(double a, double b, double x, double eps)
Description not yet available.
Definition: cbetdev.cpp:14
double log_density_negbinomial(double x, double mu, double tau)
Log negative bionomial density; constant objects.
Definition: cnegbin.cpp:22
dmatrix & operator+=(const dmatrix &t)
Add element-wise matrix values other to dmatrix.
Definition: dmat4.cpp:73
int rowmax() const
Definition: imatrix.h:150
long int i1
Definition: fvar.hpp:3350
uistream & operator>>(int &)
Definition: ufstream.cpp:59
void initialize()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d6arr.cpp:13
dvar_matrix & operator*=(const prevariable &t)
Description not yet available.
Definition: fvar_m28.cpp:135
void tracing_message(int traceflag, const char *s)
Description not yet available.
Definition: newfmin.cpp:94
void fill_randu(const random_number_generator &rng)
Description not yet available.
Definition: rngen.cpp:304
dvector operator&(const dvector &a, const dvector &b)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dvect15.cpp:17
int j
Definition: fvar.hpp:3353
friend double sumsq(const banded_symmetric_dmatrix &B)
virtual index_guts * operator[](int)=0
~d5_array()
Destructor.
Definition: d5arr.cpp:91
int colsize() const
Definition: fvar.hpp:4064
ptr_vector ptr
Definition: fvar.hpp:7486
dvector return_choleski_factor_solve(hs_smatrix *PL, dvector &eps)
Definition: hs_sparse.cpp:2693
ptr_vector()
Default constructor.
Definition: ptr_vec.cpp:118
int i
Definition: fvar.hpp:3302
const double & operator()(int i, int j) const
Definition: fvar.hpp:8168
d4_array()
Default constructor.
Definition: d4arr3.cpp:9
int indexmax() const
Definition: fvar.hpp:4913
banded_lower_triangular_dmatrix restore_banded_lower_triangular_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Definition: cmpdif11.cpp:78
double_and_int * gradnew()
Creates an entry in the gradient structure linked list.
Definition: fvar2.cpp:36
double dmin
Definition: fvar.hpp:4982
virtual int dimension() const
Definition: fvar.hpp:7821
dvar6_array & operator=(const d6_array &)
Description not yet available.
Definition: f6arr.cpp:126
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat7.cpp:12
const dvar3_array & elem(int i, int j, int k) const
Definition: fvar.hpp:6935
grad_stack_entry * ptr_last
Definition: fvar.hpp:925
void operator/=(double d)
Divides all elements of d6_array by divisor.
Definition: d6arr1.cpp:28
double log_negbinomial_density(double x, double mu, double tau)
pre_zero_print zero_print(const dvector &v)
Description not yet available.
Definition: dvect23.cpp:62
void(* func)(void)
&lt; Pointer to function (if any) to be used for derivative calculation
Definition: fvar.hpp:898
int operator>=(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:35
friend void make_indvar_list(int, dvariable *)
friend dvariable ln_det(const dvar_matrix &, int &sgn)
The implementation of this algorithm was inspired by &quot;Numerical Recipes in C&quot;, 2nd edition...
int indexmin() const
Definition: fvar.hpp:5621
void check_derivative_values_break(const char *s, int i, int b)
Description not yet available.
Definition: newdar.cpp:348
long int itn
Definition: fvar.hpp:3301
int slicemax(void) const
Definition: fvar.hpp:5630
friend char * fform(const char *, const dvar_matrix &)
int hslicemin() const
Definition: fvar.hpp:5623
double *& get_v(void)
Definition: dvector.h:148
int colmax(void) const
Definition: fvar.hpp:5341
void spdll_exit(int)
Definition: gradstrc.cpp:55
Description not yet available.
dvector_position operator()(int i)
Description not yet available.
Definition: cmpdif2.cpp:155
hs_smatrix * return_choleski_decomp(dcompressed_triplet &st)
Definition: hs_sparse.cpp:2636
prevariable_position(const prevariable &x)
Definition: fvar.hpp:4444
double fp
Definition: fvar.hpp:3665
friend double norm2(const dmatrix &)
Norm squared of a matrix; constant object.
Definition: dmat2.cpp:50
static unsigned int wd_flag
Definition: fvar.hpp:8864
dvar_vector & operator*=(const prevariable &d)
Description not yet available.
Definition: fvar_a56.cpp:30
double * dep_addr
Pointer to dependent variable.
Definition: fvar.hpp:899
int indexmin(void) const
Definition: fvar.hpp:2568
Description not yet available.
Definition: fvar.hpp:8661
int ireturn
Definition: fvar.hpp:3197
prevariable operator()(int i, int j)
Definition: fvar.hpp:8224
lvector & operator()(int i)
Definition: fvar.hpp:7547
int colmax(void)
Definition: fvar.hpp:5864
void fill_randnegbinomial(double lambda, double tau, const random_number_generator &rng)
Description not yet available.
Definition: vrannegbin.cpp:15
double dff
Definition: fvar.hpp:5007
Description not yet available.
Definition: fvar.hpp:8601
int rowsize()
Definition: fvar.hpp:6173
dmatrix_position(const dmatrix &)
Description not yet available.
Definition: cmpdif2.cpp:214
lvector & operator=(const lvector &t)
Description not yet available.
Definition: lvector.cpp:99
void increment_current_gradfile_ptr(void)
If there is another file set the handle to point to it otherwise we are out of room.
Definition: gradstak.cpp:503
Description not yet available.
Definition: fvar.hpp:5039
double inv_cumd_normal_mixture(double yy, double a)
Description not yet available.
Definition: cnormmix.cpp:90
double normal_tail_right(const double &x)
Description not yet available.
Definition: cumdist.cpp:20
const prevariable elem(int i, int j, int k, int l, int _m) const
Definition: fvar.hpp:6577
friend void gradloop()
long iexit
Definition: fvar.hpp:3189
void fill_randn(long int &n)
friend dvar_vector operator+(const dvar_vector &, const dvar_vector &)
Description not yet available.
Definition: fvar_a17.cpp:25
int _VARSSAV_PTR
Definition: fvar.hpp:945
virtual ~dvector_index()
Destructor.
Definition: doublind.cpp:144
int indexmax() const
Definition: fvar.hpp:2292
int indexmin() const
Definition: fvar.hpp:4272
double minimize(const independent_variables &x, double(*pf)(const dvar_vector &))
size_t total() const
Definition: fvar.hpp:1026
ivector ub
Definition: fvar.hpp:7485
friend void cleanup_temporary_files()
Close gradient and variable files and free gradient structure memory.
Definition: gradstrc.cpp:192
friend prevariable & operator*(const prevariable &v1, const prevariable &v2)
Description not yet available.
Definition: fvar_opr.cpp:65
dvector restore_dvector_value(const dvector_position &tmp)
Restores the size, address, and value information for a dvector.
Definition: cmpdif4.cpp:174
friend dvar_matrix operator-(double, const dvar_matrix &)
Description not yet available.
Definition: fvar_m27.cpp:667
dvar5_array & elem(int i, int j)
Definition: fvar.hpp:7309
d4_array vale(d4_array &)
int rowmin() const
Definition: fvar.hpp:2925
~dvar3_array()
Destructor.
Definition: f3arr.cpp:670
int rowmax(void)
Definition: fvar.hpp:5583
void deallocate()
Deallocate dvar3_array memory.
Definition: f3arr.cpp:675
void check_derivative_values(const char *s)
Description not yet available.
Definition: newdar.cpp:306
int rowmin(void) const
Definition: fvar.hpp:4291
multi_index(int min, int max, int dim)
Description not yet available.
Definition: multiindex.cpp:17
int np
Definition: fvar.hpp:3302
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16
Description not yet available.
Definition: fvar.hpp:8564
void initialize()
Initialize i5_array elements with zeros.
Definition: i5arr.cpp:232
void deallocate()
Description not yet available.
Definition: sdmat.cpp:85
dmatrix & hessian()
int hslicesize() const
Definition: fvar.hpp:5933
Description not yet available.
Definition: fvar.hpp:480
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
int isfv
Definition: fvar.hpp:5002
double min_improve
Definition: fvar.hpp:3633
df1_one_variable inv(const df1_one_variable &x)
Definition: df11fun.cpp:384
friend dvariable norm(const dvar_vector &)
Description not yet available.
Definition: fvar_ar3.cpp:69
double_and_int * get_va() const
Definition: fvar.hpp:2246
friend dvar_matrix operator+(const dvar_matrix &, const dvar_matrix &)
Description not yet available.
Definition: fvar_ma2.cpp:44
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13
dvariable ghk_choleski_m_logistic(const dvar_vector &upper, const dvar_matrix &ch, const dmatrix &eps)
Description not yet available.
Definition: v_ghk.cpp:254
dmatrix choleski_decomp_positive(const dmatrix &MM, double bound)
Description not yet available.
Definition: dmat35.cpp:33
int ad_printf(FILE *stream, const char *format, Args...args)
Definition: fvar.hpp:9487
banded_symmetric_dmatrix restore_banded_symmetric_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Definition: cmpdif11.cpp:55
void initialize()
Description not yet available.
Definition: f7arr.cpp:18
const prevariable operator()(int i, int j) const
Definition: fvar.hpp:8232
dmatrix & operator/=(double d)
Divide value to all elements in dmatrix.
Definition: dmat22.cpp:35
double fbest
Definition: fvar.hpp:5738
int rowmax(void) const
Definition: fvar.hpp:8007
const double & elem(int i, int j, int k, int l, int _m, int _n, int _p) const
Definition: fvar.hpp:7142
double inv_cumd_norm_logistic(double x, double p)
Description not yet available.
Definition: ccumdlog.cpp:39
dvector * p
Definition: fvar.hpp:1903
dmatrix & elem(int i, int j, int k, int l, int _m)
Definition: fvar.hpp:7109
void allocate(void)
Does not really allocate, but empties the array.
Definition: lvector.cpp:176
int ub
Definition: fvar.hpp:626
double ddouble(void) const
Description not yet available.
Definition: doublind.cpp:38
Description not yet available.
Definition: fvar.hpp:8065
void save_prevariable_position() const
Description not yet available.
Definition: cmpdif8.cpp:56
d4_array orthpoly2(int n, int m, int d1, int d2)
Description not yet available.
Definition: orthply2.cpp:17
vector_shapex * shape
Definition: fvar.hpp:2179
void fill_randu(long int &n)
Description not yet available.
Definition: ranfill2.cpp:32
double fourth(const double m)
Fourth power of a number; constant objects.
Definition: dvector.cpp:704
double x
&lt; value of the variable
Definition: fvar.hpp:195
prevariable(const prevariable &other)
Copy Constructor.
Definition: fvar.hpp:1331
dvar4_array & elem(int i, int j, int k)
Definition: fvar.hpp:7313
int bandwidth(void) const
Definition: fvar.hpp:7991
double log_gamma_density(double x, double r, double mu)
Log gamma probability density function; constant objects.
Definition: cgamdens.cpp:35
long int reset_gs_stack(void)
three_array_shape(int sl, int sh)
Stores dimensions for dvar3_array.
Definition: d3arr.cpp:758
int operator>=(const prevariable &v1) const
Description not yet available.
Definition: fvar_opr.cpp:119
int operator!(void) const
Definition: fvar.hpp:6892
const d4_array & elem(int i) const
Definition: fvar.hpp:6391
predvar_vector(dvar_vector *_p, int _lb, int _ub)
Definition: fvar.hpp:1923
dvector acos(const dvector &vec)
Returns dvector with principal value of the arc cosine of vec, expressed in radians.
Definition: dvect6.cpp:244
~ptr_vector()
Destructor.
Definition: ptr_vec.cpp:39
void deallocate(void)
Deallocates d3_array memory.
Definition: d3arr.cpp:723
imatrix & elem(int i)
Definition: fvar.hpp:4091
double & operator()(int i, int j, int k, int l, int _m, int _n)
Definition: fvar.hpp:6778
int slicesize()
Definition: fvar.hpp:5291
int index_max
Definition: fvar.hpp:2177
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17
virtual void get_slave_assignments(void)
unsigned int size() const
Definition: fvar.hpp:6483
int colmax(void) const
Definition: fvar.hpp:2943
friend void default_evaluation3ind(void)
Description not yet available.
Definition: def_eval.cpp:174
ad_integer make_ad_integer(int _d)
Definition: fvar.hpp:7673
void allocate()
dvariable robust_regression(const dvector &obs, const dvar_vector &pred, double a=0.7)
Description not yet available.
Definition: newreg2.cpp:58
const dvector & elem(int i, int j, int k, int l) const
Definition: fvar.hpp:6403
int col_max
Definition: fvar.hpp:2009
virtual int indexmax() const
Definition: fvar.hpp:7829
void read_from(const istream &s)
Description not yet available.
Definition: lvect_io.cpp:109
void initialize(void)
Description not yet available.
Definition: fvar_m40.cpp:89
dvar_matrix use_shape(const dvar_matrix &m)
Description not yet available.
Definition: fvar_m27.cpp:73
int operator>(const prevariable &v1) const
Description not yet available.
Definition: fvar_opr.cpp:110
mat_shapex()
Definition: fvar.hpp:2040
dvar_vector * m
Definition: fvar.hpp:2484
friend void default_evaluation4ind(void)
Description not yet available.
Definition: def_eval.cpp:205
int size(void)
Definition: fvar.hpp:3257
dvector h
Definition: fvar.hpp:4978
prevariable operator()(int i, int j)
Definition: fvar.hpp:8098
vector_shape * shape
Definition: fvar.hpp:6675
double gamma_deviate(double _x, double _a)
dvar3_array & operator[](int i)
Definition: fvar.hpp:5520
int rowmin(void) const
Definition: fvar.hpp:5634
void default_evaluation0(void)
Description not yet available.
Definition: def_eval.cpp:126
int colmax(void) const
Definition: fvar.hpp:2556
dvector asin(const dvector &vec)
Returns dvector with principal value of the arc sine of vec, expressed in radians.
Definition: dvect6.cpp:229
vector_shape(const vector_shape &)=delete
pre_index_type(const index_type *_a, int _i)
Definition: fvar.hpp:7643
Description not yet available.
Definition: fvar.hpp:4843
double fill_seqadd(double, double)
Description not yet available.
Definition: f3arr16.cpp:17
void rowfill_randu(const int &i, long int &n)
Fill random numbers into specified row i of matrix.
Definition: ranfill.cpp:218
unsigned int colsize() const
Definition: fvar.hpp:2584
virtual int isdouble(void) const
Definition: fvar.hpp:8541
dvar_matrix & elem(int i, int j)
Definition: fvar.hpp:5483
dvector lower_triagnular_solve_trans(const dmatrix &M, const dvector &y)
int indexmin() const
Definition: fvar.hpp:7760
int rowmax(void) const
Definition: fvar.hpp:5638
void allocate(const lmatrix &dm)
Description not yet available.
Definition: lmat6.cpp:19
virtual int indexmax() const
Definition: fvar.hpp:7788
void rowfill_randu(const int &i, long int &n)
Description not yet available.
Definition: ranfill2.cpp:100
const double & elem_value(int i, int j) const
Definition: fvar.hpp:8250
void deallocate(void)
Definition: hs_sparse.cpp:2601
friend dmatrix operator-(const dmatrix &, const dmatrix &)
Description not yet available.
Definition: dmat16.cpp:17