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
RevLine 
[8600]1/*!\file IntMatParam.c
2 * \brief: implementation of the IntMatParam object
3 */
4
5/*header files: */
[12365]6/*{{{*/
[8600]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*/
[12365]23/*FUNCTION IntMatParam::IntMatParam(){{{*/
[8600]24IntMatParam::IntMatParam(){
25 return;
26}
27/*}}}*/
[12365]28/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{*/
[8600]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
[12451]35 value=xNew<int>(M*N);
[12474]36 xMemCpy<int>(value,in_value,M*N);
[8600]37}
38/*}}}*/
[12365]39/*FUNCTION IntMatParam::~IntMatParam(){{{*/
[8600]40IntMatParam::~IntMatParam(){
[12451]41 xDelete<int>(value);
[8600]42 return;
43}
44/*}}}*/
45
46/*Object virtual functions definitions:*/
[12365]47/*FUNCTION IntMatParam::Echo {{{*/
[8600]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/*}}}*/
[12365]56/*FUNCTION IntMatParam::DeepEcho{{{*/
[8600]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/*}}}*/
[12365]71/*FUNCTION IntMatParam::Id{{{*/
[8600]72int IntMatParam::Id(void){ return -1; }
73/*}}}*/
[12365]74/*FUNCTION IntMatParam::MyRank{{{*/
[8600]75int IntMatParam::MyRank(void){
76 extern int my_rank;
77 return my_rank;
78}
79/*}}}*/
[12365]80/*FUNCTION IntMatParam::ObjectEnum{{{*/
[9883]81int IntMatParam::ObjectEnum(void){
[8600]82
83 return IntMatParamEnum;
84
85}
86/*}}}*/
[12365]87/*FUNCTION IntMatParam::copy{{{*/
[8600]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: */
[12365]96/*FUNCTION IntMatParam::GetParameterValue{{{*/
[8600]97void IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
98 int* output=NULL;
99
[12451]100 output=xNew<int>(M*N);
[12474]101 xMemCpy<int>(output,value,M*N);
[8600]102
103 /*Assign output pointers:*/
104 if(pM) *pM=M;
105 if(pN) *pN=N;
106 *pintarray=output;
107}
108/*}}}*/
[12365]109/*FUNCTION IntMatParam::GetParameterName{{{*/
[11202]110void IntMatParam::GetParameterName(char**pname){
111 EnumToStringx(pname,this->enum_type);
[8600]112}
113/*}}}*/
[12365]114/*FUNCTION IntMatParam::SetValue{{{*/
[8600]115void IntMatParam::SetValue(int* intarray,int in_M,int in_N){
116
117 /*avoid leak: */
[12451]118 xDelete<int>(this->value);
[8600]119
[12451]120 this->value=xNew<int>(in_M*in_N);
[12474]121 xMemCpy<int>(this->value,intarray,in_M*in_N);
[8600]122
123 this->M=in_M;
124 this->N=in_N;
125}
126/*}}}*/
[12365]127/*FUNCTION IntMatParam::UnitConversion{{{*/
[9356]128void IntMatParam::UnitConversion(int direction_enum){
129 /*do nothing, no unit conversion*/
130}
131/*}}}*/
Note: See TracBrowser for help on using the repository browser.