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

Last change on this file since 12014 was 12014, checked in by Eric.Larour, 13 years ago

Removing some unused SERIAL code

File size: 3.0 KB
RevLine 
[8600]1/*!\file IntMatParam.c
2 * \brief: implementation of the IntMatParam object
3 */
4
5/*header files: */
6/*{{{1*/
7#ifdef HAVE_CONFIG_H
[9320]8 #include <config.h>
[8600]9#else
10#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11#endif
12
[9320]13#include <stdio.h>
[8600]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(){{{1*/
24IntMatParam::IntMatParam(){
25 return;
26}
27/*}}}*/
28/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{1*/
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=(int*)xmalloc(M*N*sizeof(int));
36 memcpy(value,in_value,M*N*sizeof(int));
37}
38/*}}}*/
39/*FUNCTION IntMatParam::~IntMatParam(){{{1*/
40IntMatParam::~IntMatParam(){
41 xfree((void**)&value);
42 return;
43}
44/*}}}*/
45
46/*Object virtual functions definitions:*/
47/*FUNCTION IntMatParam::Echo {{{1*/
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{{{1*/
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++){
[11197]66 printf("(%i,%i) %i\n",i,j,*(this->value+N*i+j));
[8600]67 }
68 }
69}
70/*}}}*/
71/*FUNCTION IntMatParam::Id{{{1*/
72int IntMatParam::Id(void){ return -1; }
73/*}}}*/
74/*FUNCTION IntMatParam::MyRank{{{1*/
75int IntMatParam::MyRank(void){
76 extern int my_rank;
77 return my_rank;
78}
79/*}}}*/
[9883]80/*FUNCTION IntMatParam::ObjectEnum{{{1*/
81int IntMatParam::ObjectEnum(void){
[8600]82
83 return IntMatParamEnum;
84
85}
86/*}}}*/
87/*FUNCTION IntMatParam::copy{{{1*/
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{{{1*/
97void IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
98 int* output=NULL;
99
100 output=(int*)xmalloc((int)(M*N*sizeof(int)));
101 memcpy(output,value,M*N*sizeof(int));
102
103 /*Assign output pointers:*/
104 if(pM) *pM=M;
105 if(pN) *pN=N;
106 *pintarray=output;
107}
108/*}}}*/
109/*FUNCTION IntMatParam::GetParameterName{{{1*/
[11202]110void IntMatParam::GetParameterName(char**pname){
111 EnumToStringx(pname,this->enum_type);
[8600]112}
113/*}}}*/
114/*FUNCTION IntMatParam::SetValue{{{1*/
115void IntMatParam::SetValue(int* intarray,int in_M,int in_N){
116
117 /*avoid leak: */
118 xfree((void**)&this->value);
119
120 this->value=(int*)xmalloc(in_M*in_N*sizeof(int));
121 memcpy(this->value,intarray,in_M*in_N*sizeof(int));
122
123 this->M=in_M;
124 this->N=in_N;
125}
126/*}}}*/
[9356]127/*FUNCTION IntMatParam::UnitConversion{{{1*/
128void IntMatParam::UnitConversion(int direction_enum){
129 /*do nothing, no unit conversion*/
130}
131/*}}}*/
Note: See TracBrowser for help on using the repository browser.