source: issm/trunk-jpl/src/c/objects/Params/IntMatParam.cpp@ 12474

Last change on this file since 12474 was 12474, checked in by utke, 13 years ago

type renames + one type bug fixed in DoubleMatArrayParam.cpp:225/226

File size: 2.9 KB
Line 
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 <stdio.h>
14#include <string.h>
15#include "../objects.h"
16#include "../../EnumDefinitions/EnumDefinitions.h"
17#include "../../shared/shared.h"
18#include "../../Container/Container.h"
19#include "../../include/include.h"
20/*}}}*/
21
22/*IntMatParam constructors and destructor*/
23/*FUNCTION IntMatParam::IntMatParam(){{{*/
24IntMatParam::IntMatParam(){
25 return;
26}
27/*}}}*/
28/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{*/
29IntMatParam::IntMatParam(int in_enum_type,int* in_value, int in_M,int in_N){
30
31 enum_type=in_enum_type;
32 M=in_M;
33 N=in_N;
34
35 value=xNew<int>(M*N);
36 xMemCpy<int>(value,in_value,M*N);
37}
38/*}}}*/
39/*FUNCTION IntMatParam::~IntMatParam(){{{*/
40IntMatParam::~IntMatParam(){
41 xDelete<int>(value);
42 return;
43}
44/*}}}*/
45
46/*Object virtual functions definitions:*/
47/*FUNCTION IntMatParam::Echo {{{*/
48void IntMatParam::Echo(void){
49
50 printf("IntMatParam:\n");
51 printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
52 printf(" matrix size: %ix%i\n",this->M,this->N);
53
54}
55/*}}}*/
56/*FUNCTION IntMatParam::DeepEcho{{{*/
57void IntMatParam::DeepEcho(void){
58
59 int i,j;
60
61 printf("IntMatParam:\n");
62 printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
63 printf(" matrix size: %ix%i\n",this->M,this->N);
64 for(i=0;i<this->M;i++){
65 for(i=0;i<this->N;i++){
66 printf("(%i,%i) %i\n",i,j,*(this->value+N*i+j));
67 }
68 }
69}
70/*}}}*/
71/*FUNCTION IntMatParam::Id{{{*/
72int IntMatParam::Id(void){ return -1; }
73/*}}}*/
74/*FUNCTION IntMatParam::MyRank{{{*/
75int IntMatParam::MyRank(void){
76 extern int my_rank;
77 return my_rank;
78}
79/*}}}*/
80/*FUNCTION IntMatParam::ObjectEnum{{{*/
81int IntMatParam::ObjectEnum(void){
82
83 return IntMatParamEnum;
84
85}
86/*}}}*/
87/*FUNCTION IntMatParam::copy{{{*/
88Object* IntMatParam::copy() {
89
90 return new IntMatParam(this->enum_type,this->value,this->M,this->N);
91
92}
93/*}}}*/
94
95/*IntMatParam virtual functions definitions: */
96/*FUNCTION IntMatParam::GetParameterValue{{{*/
97void IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
98 int* output=NULL;
99
100 output=xNew<int>(M*N);
101 xMemCpy<int>(output,value,M*N);
102
103 /*Assign output pointers:*/
104 if(pM) *pM=M;
105 if(pN) *pN=N;
106 *pintarray=output;
107}
108/*}}}*/
109/*FUNCTION IntMatParam::GetParameterName{{{*/
110void IntMatParam::GetParameterName(char**pname){
111 EnumToStringx(pname,this->enum_type);
112}
113/*}}}*/
114/*FUNCTION IntMatParam::SetValue{{{*/
115void IntMatParam::SetValue(int* intarray,int in_M,int in_N){
116
117 /*avoid leak: */
118 xDelete<int>(this->value);
119
120 this->value=xNew<int>(in_M*in_N);
121 xMemCpy<int>(this->value,intarray,in_M*in_N);
122
123 this->M=in_M;
124 this->N=in_N;
125}
126/*}}}*/
127/*FUNCTION IntMatParam::UnitConversion{{{*/
128void IntMatParam::UnitConversion(int direction_enum){
129 /*do nothing, no unit conversion*/
130}
131/*}}}*/
Note: See TracBrowser for help on using the repository browser.