Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Private Attributes
DoubleMatArrayParam Class Reference

#include <DoubleMatArrayParam.h>

Inheritance diagram for DoubleMatArrayParam:
Param Object

Public Member Functions

 DoubleMatArrayParam ()
 
 DoubleMatArrayParam (int enum_type, IssmDouble **array, int M, int *mdim_array, int *ndim_array)
 
 ~DoubleMatArrayParam ()
 
Paramcopy ()
 
void DeepEcho ()
 
void Echo ()
 
int Id ()
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
int ObjectEnum ()
 
void GetParameterValue (bool *pbool)
 
void GetParameterValue (int *pinteger)
 
void GetParameterValue (int **pintarray, int *pM)
 
void GetParameterValue (int **pintarray, int *pM, int *pN)
 
void GetParameterValue (IssmDouble *pIssmDouble)
 
void GetParameterValue (IssmDouble *pdouble, IssmDouble time)
 
void GetParameterValue (char **pstring)
 
void GetParameterValue (char ***pstringarray, int *pM)
 
void GetParameterValue (IssmDouble **pIssmDoublearray, int *pM)
 
void GetParameterValue (IssmDouble **pIssmDoublearray, int *pM, int *pN)
 
void GetParameterValue (IssmDouble ***parray, int *pM, int **pmdims, int **pndims)
 
void GetParameterValue (Vector< IssmDouble > **pvec)
 
void GetParameterValue (Matrix< IssmDouble > **pmat)
 
void GetParameterValue (FILE **pfid)
 
void GetParameterValue (DataSet **pdataset)
 
int InstanceEnum ()
 
void SetEnum (int enum_in)
 
void SetValue (bool boolean)
 
void SetValue (int integer)
 
void SetValue (IssmDouble scalar)
 
void SetValue (char *string)
 
void SetValue (char **stringarray, int M)
 
void SetValue (IssmDouble *IssmDoublearray, int M)
 
void SetValue (IssmDouble *IssmDoublearray, int M, int N)
 
void SetValue (int *intarray, int M)
 
void SetValue (int *intarray, int M, int N)
 
void SetValue (Vector< IssmDouble > *vec)
 
void SetValue (Matrix< IssmDouble > *mat)
 
void SetValue (FILE *fid)
 
void SetValue (IssmDouble **array, int M, int *mdim_array, int *ndim_array)
 
- Public Member Functions inherited from Param
virtual ~Param ()
 
virtual void GetParameterValue (IssmDouble *pdouble, int row, IssmDouble time)
 
virtual void SetValue (DataSet *dataset)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 

Private Attributes

int enum_type
 
IssmDouble ** array
 
int M
 
int * mdim_array
 
int * ndim_array
 

Detailed Description

Definition at line 20 of file DoubleMatArrayParam.h.

Constructor & Destructor Documentation

◆ DoubleMatArrayParam() [1/2]

DoubleMatArrayParam::DoubleMatArrayParam ( )

Definition at line 18 of file DoubleMatArrayParam.cpp.

18  {/*{{{*/
19  return;
20 }

◆ DoubleMatArrayParam() [2/2]

DoubleMatArrayParam::DoubleMatArrayParam ( int  enum_type,
IssmDouble **  array,
int  M,
int *  mdim_array,
int *  ndim_array 
)

Definition at line 22 of file DoubleMatArrayParam.cpp.

22  {/*{{{*/
23 
24  int i;
25  IssmDouble* matrix=NULL;
26  int m,n;
27 
28  enum_type=in_enum_type;
29  M=in_M;
30  if(M){
31  array=xNew<IssmDouble*>(M);
32  mdim_array=xNew<int>(M);
33  ndim_array=xNew<int>(M);
34 
35  for(i=0;i<M;i++){
36  m=in_mdim_array[i];
37  n=in_ndim_array[i];
38 
39  mdim_array[i]=m;
40  ndim_array[i]=n;
41 
42  if(m*n){
43  matrix=xNew<IssmDouble>(m*n);
44  xMemCpy<IssmDouble>(matrix,in_array[i],m*n);
45  }
46  else{
47  matrix=NULL;
48  }
49  array[i]=matrix;
50  }
51  }
52  else{
53  array=NULL;
54  mdim_array=NULL;
55  ndim_array=NULL;
56  }
57 }

◆ ~DoubleMatArrayParam()

DoubleMatArrayParam::~DoubleMatArrayParam ( )

Definition at line 59 of file DoubleMatArrayParam.cpp.

59  {/*{{{*/
60 
61  int i;
62  IssmDouble* matrix=NULL;
63 
64  xDelete<int>(mdim_array);
65  xDelete<int>(ndim_array);
66 
67  for(i=0;i<M;i++){
68  matrix=array[i];
69  xDelete<IssmDouble>(matrix);
70  }
71 
72  xDelete<IssmDouble*>(array);
73  return;
74 }

Member Function Documentation

◆ copy()

Param * DoubleMatArrayParam::copy ( void  )
virtual

Implements Param.

Definition at line 78 of file DoubleMatArrayParam.cpp.

78  {/*{{{*/
79 
80  return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
81 
82 }

◆ DeepEcho()

void DoubleMatArrayParam::DeepEcho ( void  )
virtual

Implements Param.

Definition at line 84 of file DoubleMatArrayParam.cpp.

84  {/*{{{*/
85 
86  int i,j,k;
87  int m,n;
88  IssmDouble* matrix=NULL;
89 
90  _printf_("DoubleMatArrayParam:\n");
91  _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
92  _printf_(" array size: " << this->M << "\n");
93  for(i=0;i<M;i++){
94  _printf_(" array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):\n");
95  matrix=array[i];
96  m=mdim_array[i];
97  n=ndim_array[i];
98 
99  for(j=0;j<m;j++){
100  _printf_(" ");
101  for(k=0;k<n;k++)_printf_(*(matrix+n*j+k) << " ");
102  _printf_("\n");
103  }
104  }
105 }

◆ Echo()

void DoubleMatArrayParam::Echo ( void  )
virtual

Implements Param.

Definition at line 107 of file DoubleMatArrayParam.cpp.

107  {/*{{{*/
108 
109  _printf_("DoubleMatArrayParam:\n");
110  _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
111  _printf_(" array size: " << this->M << "\n");
112  _printf_(" array pointer: " << this->array << "\n");
113 
114 }

◆ Id()

int DoubleMatArrayParam::Id ( void  )
virtual

Implements Object.

Definition at line 116 of file DoubleMatArrayParam.cpp.

116 { return -1; }/*{{{*/

◆ Marshall()

void DoubleMatArrayParam::Marshall ( char **  pmarshalled_data,
int *  pmarshalled_data_size,
int  marshall_direction 
)
virtual

Implements Param.

Definition at line 118 of file DoubleMatArrayParam.cpp.

118  { /*{{{*/
119 
121 
123  MARSHALLING(M);
124  if(M){
127  if(marshall_direction==MARSHALLING_BACKWARD && M) array=xNew<IssmDouble*>(M);
128  for(int i=0;i<M;i++){
130  }
131  }
132  else{
133  array=NULL;
134  mdim_array=NULL;
135  ndim_array=NULL;
136  }
137 
138 }

◆ ObjectEnum()

int DoubleMatArrayParam::ObjectEnum ( void  )
virtual

Implements Param.

Definition at line 140 of file DoubleMatArrayParam.cpp.

140  {/*{{{*/
141 
143 
144 }

◆ GetParameterValue() [1/15]

void DoubleMatArrayParam::GetParameterValue ( bool *  pbool)
inlinevirtual

Implements Param.

Definition at line 44 of file DoubleMatArrayParam.h.

44 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a bool");}

◆ GetParameterValue() [2/15]

void DoubleMatArrayParam::GetParameterValue ( int *  pinteger)
inlinevirtual

Implements Param.

Definition at line 45 of file DoubleMatArrayParam.h.

45 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return an integer");}

◆ GetParameterValue() [3/15]

void DoubleMatArrayParam::GetParameterValue ( int **  pintarray,
int *  pM 
)
inlinevirtual

Implements Param.

Definition at line 46 of file DoubleMatArrayParam.h.

46 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return an array of integers");}

◆ GetParameterValue() [4/15]

void DoubleMatArrayParam::GetParameterValue ( int **  pintarray,
int *  pM,
int *  pN 
)
inlinevirtual

Implements Param.

Definition at line 47 of file DoubleMatArrayParam.h.

47 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return an array of integers");}

◆ GetParameterValue() [5/15]

void DoubleMatArrayParam::GetParameterValue ( IssmDouble pIssmDouble)
inlinevirtual

Implements Param.

Definition at line 48 of file DoubleMatArrayParam.h.

48 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a IssmDouble");}

◆ GetParameterValue() [6/15]

void DoubleMatArrayParam::GetParameterValue ( IssmDouble pdouble,
IssmDouble  time 
)
inlinevirtual

Implements Param.

Definition at line 49 of file DoubleMatArrayParam.h.

49 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");}

◆ GetParameterValue() [7/15]

void DoubleMatArrayParam::GetParameterValue ( char **  pstring)
inlinevirtual

Implements Param.

Definition at line 50 of file DoubleMatArrayParam.h.

50 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a string");}

◆ GetParameterValue() [8/15]

void DoubleMatArrayParam::GetParameterValue ( char ***  pstringarray,
int *  pM 
)
inlinevirtual

Implements Param.

Definition at line 51 of file DoubleMatArrayParam.h.

51 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a string array");}

◆ GetParameterValue() [9/15]

void DoubleMatArrayParam::GetParameterValue ( IssmDouble **  pIssmDoublearray,
int *  pM 
)
inlinevirtual

Implements Param.

Definition at line 52 of file DoubleMatArrayParam.h.

52 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a IssmDouble array");}

◆ GetParameterValue() [10/15]

void DoubleMatArrayParam::GetParameterValue ( IssmDouble **  pIssmDoublearray,
int *  pM,
int *  pN 
)
inlinevirtual

Implements Param.

Definition at line 53 of file DoubleMatArrayParam.h.

53 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a IssmDouble array");}

◆ GetParameterValue() [11/15]

void DoubleMatArrayParam::GetParameterValue ( IssmDouble ***  parray,
int *  pM,
int **  pmdims,
int **  pndims 
)
virtual

Implements Param.

Definition at line 148 of file DoubleMatArrayParam.cpp.

148  {/*{{{*/
149 
150  int i,m,n;
151  IssmDouble* matrix=NULL;
152  IssmDouble* out_matrix=NULL;
153 
154  /*output: */
155  IssmDouble** out_array=NULL;
156  int out_M;
157  int* out_mdim_array=NULL;
158  int* out_ndim_array=NULL;
159 
160  out_M=this->M;
161  if(out_M){
162  out_array=xNew<IssmDouble*>(M);
163  out_mdim_array=xNew<int>(M);
164  out_ndim_array=xNew<int>(M);
165 
166  xMemCpy<int>(out_mdim_array,this->mdim_array,M);
167  xMemCpy<int>(out_ndim_array,this->ndim_array,M);
168 
169  for(i=0;i<this->M;i++){
170  matrix=this->array[i];
171  m=this->mdim_array[i];
172  n=this->ndim_array[i];
173 
174  if(m*n){
175  out_matrix=xNew<IssmDouble>(m*n);
176  xMemCpy<IssmDouble>(out_matrix,matrix,m*n);
177  }
178  else{
179  out_matrix=NULL;
180  }
181  out_array[i]=out_matrix;
182  }
183  }
184  else{
185  out_array=NULL;
186  out_matrix=NULL;
187  out_ndim_array=NULL;
188  }
189 
190  /*Assign output pointers:*/
191  if(pout_M) *pout_M=out_M;
192  if(pout_mdim_array) *pout_mdim_array=out_mdim_array;
193  if(pout_ndim_array) *pout_ndim_array=out_ndim_array;
194  *pout_array=out_array;
195 
196 }

◆ GetParameterValue() [12/15]

void DoubleMatArrayParam::GetParameterValue ( Vector< IssmDouble > **  pvec)
inlinevirtual

Implements Param.

Definition at line 55 of file DoubleMatArrayParam.h.

55 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a Vec");}

◆ GetParameterValue() [13/15]

void DoubleMatArrayParam::GetParameterValue ( Matrix< IssmDouble > **  pmat)
inlinevirtual

Implements Param.

Definition at line 56 of file DoubleMatArrayParam.h.

56 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a Mat");}

◆ GetParameterValue() [14/15]

void DoubleMatArrayParam::GetParameterValue ( FILE **  pfid)
inlinevirtual

Implements Param.

Definition at line 57 of file DoubleMatArrayParam.h.

57 {_error_("Param "<< EnumToStringx(enum_type) << "cannot return a FILE");}

◆ GetParameterValue() [15/15]

void DoubleMatArrayParam::GetParameterValue ( DataSet **  pdataset)
inlinevirtual

Implements Param.

Definition at line 58 of file DoubleMatArrayParam.h.

58 {_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}

◆ InstanceEnum()

int DoubleMatArrayParam::InstanceEnum ( )
inlinevirtual

Implements Param.

Definition at line 59 of file DoubleMatArrayParam.h.

59 {return enum_type;}

◆ SetEnum()

void DoubleMatArrayParam::SetEnum ( int  enum_in)
inlinevirtual

Implements Param.

Definition at line 61 of file DoubleMatArrayParam.h.

61 {this->enum_type = enum_in;};

◆ SetValue() [1/13]

void DoubleMatArrayParam::SetValue ( bool  boolean)
inlinevirtual

Implements Param.

Definition at line 62 of file DoubleMatArrayParam.h.

62 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a boolean");}

◆ SetValue() [2/13]

void DoubleMatArrayParam::SetValue ( int  integer)
inlinevirtual

Implements Param.

Definition at line 63 of file DoubleMatArrayParam.h.

63 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold an integer");}

◆ SetValue() [3/13]

void DoubleMatArrayParam::SetValue ( IssmDouble  scalar)
inlinevirtual

Implements Param.

Definition at line 64 of file DoubleMatArrayParam.h.

64 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a scalar");}

◆ SetValue() [4/13]

void DoubleMatArrayParam::SetValue ( char *  string)
inlinevirtual

Implements Param.

Definition at line 65 of file DoubleMatArrayParam.h.

65 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a string");}

◆ SetValue() [5/13]

void DoubleMatArrayParam::SetValue ( char **  stringarray,
int  M 
)
inlinevirtual

Implements Param.

Definition at line 66 of file DoubleMatArrayParam.h.

66 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a string array");}

◆ SetValue() [6/13]

void DoubleMatArrayParam::SetValue ( IssmDouble IssmDoublearray,
int  M 
)
inlinevirtual

Implements Param.

Definition at line 67 of file DoubleMatArrayParam.h.

67 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a IssmDouble vec array");}

◆ SetValue() [7/13]

void DoubleMatArrayParam::SetValue ( IssmDouble IssmDoublearray,
int  M,
int  N 
)
inlinevirtual

Implements Param.

Definition at line 68 of file DoubleMatArrayParam.h.

68 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a IssmDouble mat array");}

◆ SetValue() [8/13]

void DoubleMatArrayParam::SetValue ( int *  intarray,
int  M 
)
inlinevirtual

Implements Param.

Definition at line 69 of file DoubleMatArrayParam.h.

69 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a int vec array");}

◆ SetValue() [9/13]

void DoubleMatArrayParam::SetValue ( int *  intarray,
int  M,
int  N 
)
inlinevirtual

Implements Param.

Definition at line 70 of file DoubleMatArrayParam.h.

70 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a int mat array");}

◆ SetValue() [10/13]

void DoubleMatArrayParam::SetValue ( Vector< IssmDouble > *  vec)
inlinevirtual

Implements Param.

Definition at line 71 of file DoubleMatArrayParam.h.

71 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a Vec");}

◆ SetValue() [11/13]

void DoubleMatArrayParam::SetValue ( Matrix< IssmDouble > *  mat)
inlinevirtual

Implements Param.

Definition at line 72 of file DoubleMatArrayParam.h.

72 {_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a Mat");}

◆ SetValue() [12/13]

void DoubleMatArrayParam::SetValue ( FILE *  fid)
inlinevirtual

Implements Param.

Definition at line 73 of file DoubleMatArrayParam.h.

73 {_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}

◆ SetValue() [13/13]

void DoubleMatArrayParam::SetValue ( IssmDouble **  array,
int  M,
int *  mdim_array,
int *  ndim_array 
)
virtual

Implements Param.

Definition at line 198 of file DoubleMatArrayParam.cpp.

198  {/*{{{*/
199 
200  int i,m,n;
201  IssmDouble* in_matrix=NULL;
202  IssmDouble* matrix=NULL;
203 
204  /*avoid leak: */
205  xDelete<int>(mdim_array);
206  xDelete<int>(ndim_array);
207  for(i=0;i<M;i++){
208  matrix=array[i];
209  xDelete<IssmDouble>(matrix);
210  }
211  xDelete<IssmDouble*>(array);
212 
213  /*copy data: */
214  this->M=in_M;
215  this->array=xNew<IssmDouble*>(M);
216  this->mdim_array=xNew<int>(M);
217  this->ndim_array=xNew<int>(M);
218 
219  xMemCpy<int>(this->mdim_array,in_mdim_array,M);
220  xMemCpy<int>(this->ndim_array,in_ndim_array,M);
221 
222  for(i=0;i<M;i++){
223  in_matrix=in_array[i];
224  m=in_mdim_array[i];
225  n=in_ndim_array[i];
226 
227  matrix=xNew<IssmDouble>(m*n);
228  xMemCpy<IssmDouble>(matrix,in_matrix,m*n);
229 
230  this->array[i]=matrix;
231  }
232 
233 }

Field Documentation

◆ enum_type

int DoubleMatArrayParam::enum_type
private

Definition at line 23 of file DoubleMatArrayParam.h.

◆ array

IssmDouble** DoubleMatArrayParam::array
private

Definition at line 24 of file DoubleMatArrayParam.h.

◆ M

int DoubleMatArrayParam::M
private

Definition at line 25 of file DoubleMatArrayParam.h.

◆ mdim_array

int* DoubleMatArrayParam::mdim_array
private

Definition at line 26 of file DoubleMatArrayParam.h.

◆ ndim_array

int* DoubleMatArrayParam::ndim_array
private

Definition at line 27 of file DoubleMatArrayParam.h.


The documentation for this class was generated from the following files:
IssmDouble
double IssmDouble
Definition: types.h:37
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
DoubleMatArrayParam::array
IssmDouble ** array
Definition: DoubleMatArrayParam.h:24
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
DoubleMatArrayParam::mdim_array
int * mdim_array
Definition: DoubleMatArrayParam.h:26
MARSHALLING_BACKWARD
@ MARSHALLING_BACKWARD
Definition: Marshalling.h:10
DoubleMatArrayParamEnum
@ DoubleMatArrayParamEnum
Definition: EnumDefinitions.h:1044
DoubleMatArrayParam::enum_type
int enum_type
Definition: DoubleMatArrayParam.h:23
DoubleMatArrayParam::DoubleMatArrayParam
DoubleMatArrayParam()
Definition: DoubleMatArrayParam.cpp:18
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DoubleMatArrayParam::M
int M
Definition: DoubleMatArrayParam.h:25
DoubleMatArrayParam::ndim_array
int * ndim_array
Definition: DoubleMatArrayParam.h:27