ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmpdif9.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <fvar.hpp>
12 
13 #ifdef __TURBOC__
14  #pragma hdrstop
15 #endif
16 
21 {
23 }
25 {
26  for (int i=m.rowmin();i<=m.rowmax();++i)
27  {
28  save_ivector_value(m(i));
30  }
31 }
36 {
38 }
40 {
41  imatrix_position tmp(m);
42  constexpr size_t wsize=sizeof(int);
43  constexpr size_t wsize1=sizeof(void*);
44 
45  int min=m.rowmin();
46  int max=m.rowmax();
47  for (int i=min;i<=max;++i)
48  {
49  fwrite(&(tmp.lb(i)),wsize);
50  fwrite(&(tmp.ub(i)),wsize);
51  fwrite(&(tmp.ptr(i)),wsize1);
52  }
53  fwrite(&(tmp.row_min),wsize);
54  fwrite(&(tmp.row_max),wsize);
55 }
60 {
62 }
64 {
65  constexpr size_t wsize=sizeof(int);
66  constexpr size_t wsize1=sizeof(void*);
67 
68  int min;
69  int max;
70  fread(&max,wsize);
71  fread(&min,wsize);
72  imatrix_position tmp(min,max);
73  for (int i=max;i>=min;i--)
74  {
75  fread(&(tmp.ptr(i)),wsize1);
76  fread(&(tmp.ub(i)),wsize);
77  fread(&(tmp.lb(i)),wsize);
78  }
79  return tmp;
80 }
86 {
88 }
90 {
91  // restores the size, address, and value information for a dvar_matrix
92  // the size, address, and value information for a dvar_matrix
93  imatrix out(mpos);
94  int min=out.rowmin();
95  int max=out.rowmax();
96  for (int i=max;i>=min;i--)
97  {
99  out(i)=restore_ivector_value(vpos);
100  }
101  return out;
102 }
ptr_vector ptr
Definition: imatrix.h:55
Description not yet available.
Definition: imatrix.h:69
ivector ub
Definition: imatrix.h:54
Description not yet available.
Definition: imatrix.h:48
void save_ivector_position(const ivector &v)
Definition: cmpdif3.cpp:198
void save_imatrix_position(const imatrix &m)
Definition: cmpdif9.cpp:39
ivector_position restore_ivector_position()
Definition: cmpdif4.cpp:49
imatrix restore_imatrix_value(const imatrix_position &mpos)
Description not yet available.
Definition: cmpdif9.cpp:85
int rowmin() const
Definition: imatrix.h:146
imatrix restore_imatrix_value(const imatrix_position &mpos)
Definition: cmpdif9.cpp:89
ivector lb
Definition: imatrix.h:53
#define min(a, b)
Definition: cbivnorm.cpp:188
Description not yet available.
Definition: fvar.hpp:4947
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
imatrix_position restore_imatrix_position()
Reads and restores back the size and address information for a imatrix.
Definition: cmpdif9.cpp:59
static _THREAD DF_FILE * fp
ivector restore_ivector_value(const ivector_position &tmp)
Definition: cmpdif4.cpp:202
void fwrite(const void *s, const size_t num_bytes)
Reads num_bytes from s and writes to buffer.
Definition: df_file.cpp:296
void fread(void *s, const size_t num_bytes)
Reads num_bytes from buffer and copies to s.
Definition: df_file.cpp:270
void save_imatrix_position()
Saves the size and address information for a imatrix.
Definition: cmpdif9.cpp:35
void save_imatrix_value(const imatrix &m)
Definition: cmpdif9.cpp:24
void save_imatrix_value()
Saves the size, address, and value information for a imatrix.
Definition: cmpdif9.cpp:20
#define max(a, b)
Definition: cbivnorm.cpp:189
int rowmax() const
Definition: imatrix.h:150
imatrix_position restore_imatrix_position()
Definition: cmpdif9.cpp:63
void save_ivector_value(const ivector &v)
Definition: cmpdif4.cpp:152