source: issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp@ 15099

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

CHG: greatly simplified the shared/io/Print routines. Replaced
_printf_ by _pprintString_ , then replaced all _printLine_ by _printString_
and _pprintLine_ by _pprintString_
We will then replace the _printString_ by _printf_ and _pprintString_ by _printf0_

File size: 2.8 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
[15012]13#include "../classes.h"
14#include "shared/shared.h"
[8600]15/*}}}*/
16
17/*IntMatParam constructors and destructor*/
[12365]18/*FUNCTION IntMatParam::IntMatParam(){{{*/
[8600]19IntMatParam::IntMatParam(){
20 return;
21}
22/*}}}*/
[12365]23/*FUNCTION IntMatParam::IntMatParam(int enum_type,IssmIntMat value){{{*/
[8600]24IntMatParam::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
[12451]30 value=xNew<int>(M*N);
[12474]31 xMemCpy<int>(value,in_value,M*N);
[8600]32}
33/*}}}*/
[12365]34/*FUNCTION IntMatParam::~IntMatParam(){{{*/
[8600]35IntMatParam::~IntMatParam(){
[12451]36 xDelete<int>(value);
[8600]37 return;
38}
39/*}}}*/
40
41/*Object virtual functions definitions:*/
[12365]42/*FUNCTION IntMatParam::Echo {{{*/
[8600]43void IntMatParam::Echo(void){
44
[15099]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");
[8600]48
49}
50/*}}}*/
[12365]51/*FUNCTION IntMatParam::DeepEcho{{{*/
[8600]52void IntMatParam::DeepEcho(void){
53
54 int i,j;
[13622]55
[15099]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");
[8600]59 for(i=0;i<this->M;i++){
60 for(i=0;i<this->N;i++){
[15099]61 _printString_("(" << i << "," << j << ") " << *(this->value+N*i+j) << "\n");
[8600]62 }
63 }
64}
65/*}}}*/
[12365]66/*FUNCTION IntMatParam::Id{{{*/
[8600]67int IntMatParam::Id(void){ return -1; }
68/*}}}*/
[12365]69/*FUNCTION IntMatParam::ObjectEnum{{{*/
[9883]70int IntMatParam::ObjectEnum(void){
[8600]71
72 return IntMatParamEnum;
73
74}
75/*}}}*/
[12365]76/*FUNCTION IntMatParam::copy{{{*/
[8600]77Object* IntMatParam::copy() {
[13622]78
[8600]79 return new IntMatParam(this->enum_type,this->value,this->M,this->N);
80
81}
82/*}}}*/
83
84/*IntMatParam virtual functions definitions: */
[12365]85/*FUNCTION IntMatParam::GetParameterValue{{{*/
[8600]86void IntMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){
87 int* output=NULL;
88
[12451]89 output=xNew<int>(M*N);
[12474]90 xMemCpy<int>(output,value,M*N);
[8600]91
92 /*Assign output pointers:*/
93 if(pM) *pM=M;
94 if(pN) *pN=N;
95 *pintarray=output;
96}
97/*}}}*/
[12365]98/*FUNCTION IntMatParam::GetParameterName{{{*/
[11202]99void IntMatParam::GetParameterName(char**pname){
100 EnumToStringx(pname,this->enum_type);
[8600]101}
102/*}}}*/
[12365]103/*FUNCTION IntMatParam::SetValue{{{*/
[8600]104void IntMatParam::SetValue(int* intarray,int in_M,int in_N){
105
106 /*avoid leak: */
[12451]107 xDelete<int>(this->value);
[8600]108
[12451]109 this->value=xNew<int>(in_M*in_N);
[12474]110 xMemCpy<int>(this->value,intarray,in_M*in_N);
[8600]111
112 this->M=in_M;
113 this->N=in_N;
114}
115/*}}}*/
[12365]116/*FUNCTION IntMatParam::UnitConversion{{{*/
[9356]117void IntMatParam::UnitConversion(int direction_enum){
118 /*do nothing, no unit conversion*/
119}
120/*}}}*/
Note: See TracBrowser for help on using the repository browser.