1 | /*!\file IntMatParam.c
|
---|
2 | * \brief: implementation of the IntMatParam object
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*header files: */
|
---|
6 | /*{{{*/
|
---|
7 | #ifdef HAVE_CONFIG_H
|
---|
8 | #include <config.h>
|
---|
9 | #else
|
---|
10 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
11 | #endif
|
---|
12 |
|
---|
13 | #include "../classes.h"
|
---|
14 | #include "shared/shared.h"
|
---|
15 | /*}}}*/
|
---|
16 |
|
---|
17 | /*IntMatParam constructors and destructor*/
|
---|
18 | /*FUNCTION IntMatParam::IntMatParam(){{{*/
|
---|
19 | IntMatParam::IntMatParam(){
|
---|
20 | return;
|
---|
21 | }
|
---|
22 | /*}}}*/
|
---|
23 | /*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{*/
|
---|
24 | IntMatParam::IntMatParam(int in_enum_type,int* in_value, int in_M,int in_N){
|
---|
25 |
|
---|
26 | enum_type=in_enum_type;
|
---|
27 | M=in_M;
|
---|
28 | N=in_N;
|
---|
29 |
|
---|
30 | value=xNew<int>(M*N);
|
---|
31 | xMemCpy<int>(value,in_value,M*N);
|
---|
32 | }
|
---|
33 | /*}}}*/
|
---|
34 | /*FUNCTION IntMatParam::~IntMatParam(){{{*/
|
---|
35 | IntMatParam::~IntMatParam(){
|
---|
36 | xDelete<int>(value);
|
---|
37 | return;
|
---|
38 | }
|
---|
39 | /*}}}*/
|
---|
40 |
|
---|
41 | /*Object virtual functions definitions:*/
|
---|
42 | /*FUNCTION IntMatParam::Echo {{{*/
|
---|
43 | void IntMatParam::Echo(void){
|
---|
44 |
|
---|
45 | _printString_("IntMatParam:" << "\n");
|
---|
46 | _printString_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")" << "\n");
|
---|
47 | _printString_(" matrix size: " << this->M << "x" << this->N << "\n");
|
---|
48 |
|
---|
49 | }
|
---|
50 | /*}}}*/
|
---|
51 | /*FUNCTION IntMatParam::DeepEcho{{{*/
|
---|
52 | void IntMatParam::DeepEcho(void){
|
---|
53 |
|
---|
54 | int i,j;
|
---|
55 |
|
---|
56 | _printString_("IntMatParam:" << "\n");
|
---|
57 | _printString_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")" << "\n");
|
---|
58 | _printString_(" matrix size: " << this->M << "x" << this->N << "\n");
|
---|
59 | for(i=0;i<this->M;i++){
|
---|
60 | for(i=0;i<this->N;i++){
|
---|
61 | _printString_("(" << i << "," << j << ") " << *(this->value+N*i+j) << "\n");
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 | /*}}}*/
|
---|
66 | /*FUNCTION IntMatParam::Id{{{*/
|
---|
67 | int IntMatParam::Id(void){ return -1; }
|
---|
68 | /*}}}*/
|
---|
69 | /*FUNCTION IntMatParam::ObjectEnum{{{*/
|
---|
70 | int IntMatParam::ObjectEnum(void){
|
---|
71 |
|
---|
72 | return IntMatParamEnum;
|
---|
73 |
|
---|
74 | }
|
---|
75 | /*}}}*/
|
---|
76 | /*FUNCTION IntMatParam::copy{{{*/
|
---|
77 | Object* IntMatParam::copy() {
|
---|
78 |
|
---|
79 | return new IntMatParam(this->enum_type,this->value,this->M,this->N);
|
---|
80 |
|
---|
81 | }
|
---|
82 | /*}}}*/
|
---|
83 |
|
---|
84 | /*IntMatParam virtual functions definitions: */
|
---|
85 | /*FUNCTION IntMatParam::GetParameterValue{{{*/
|
---|
86 | void IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
|
---|
87 | int* output=NULL;
|
---|
88 |
|
---|
89 | output=xNew<int>(M*N);
|
---|
90 | xMemCpy<int>(output,value,M*N);
|
---|
91 |
|
---|
92 | /*Assign output pointers:*/
|
---|
93 | if(pM) *pM=M;
|
---|
94 | if(pN) *pN=N;
|
---|
95 | *pintarray=output;
|
---|
96 | }
|
---|
97 | /*}}}*/
|
---|
98 | /*FUNCTION IntMatParam::GetParameterName{{{*/
|
---|
99 | void IntMatParam::GetParameterName(char**pname){
|
---|
100 | EnumToStringx(pname,this->enum_type);
|
---|
101 | }
|
---|
102 | /*}}}*/
|
---|
103 | /*FUNCTION IntMatParam::SetValue{{{*/
|
---|
104 | void IntMatParam::SetValue(int* intarray,int in_M,int in_N){
|
---|
105 |
|
---|
106 | /*avoid leak: */
|
---|
107 | xDelete<int>(this->value);
|
---|
108 |
|
---|
109 | this->value=xNew<int>(in_M*in_N);
|
---|
110 | xMemCpy<int>(this->value,intarray,in_M*in_N);
|
---|
111 |
|
---|
112 | this->M=in_M;
|
---|
113 | this->N=in_N;
|
---|
114 | }
|
---|
115 | /*}}}*/
|
---|
116 | /*FUNCTION IntMatParam::UnitConversion{{{*/
|
---|
117 | void IntMatParam::UnitConversion(int direction_enum){
|
---|
118 | /*do nothing, no unit conversion*/
|
---|
119 | }
|
---|
120 | /*}}}*/
|
---|