달력

122025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

ResultUnit.cpp

Programs 2014. 8. 14. 20:16

#include "Inc.hpp"

//----------------------------------------------------------------
//ResultUnit 클래스 함수들
//----------------------------------------------------------------

void ResultUnit::Init(long period, long fieldnum, short keynum, char** key)
{
    this->Period   = period;
    this->FieldNum = fieldnum;
    this->KeyNum   = keynum;

    Key = new char* [KeyNum];
    for(int i=0; i<KeyNum; i++)
    {
        Key[i] = new char [30];
        strcpy(Key[i], key[i]);
    }
   
    value = new double* [Period];
    for(int i=0; i<Period; i++)
    {
        value[i] = new double [FieldNum];

        for(int j=0; j<FieldNum; j++)
        {
            value[i][j] = 0.0;
        }
    }
}

ResultUnit::~ResultUnit()
{
    for(int i=0; i<KeyNum; i++)
    {
        delete [] Key[i];
    }
    delete [] Key;

    for(int i=0; i<Period; i++)
    {
        delete [] value[i];
    }
    delete [] value;
}

bool ResultUnit::GroupCmp(char** key)
{
    for(int i=0; i<KeyNum; i++)
    {
        if(strcmp(key[i], this->Key[i])!=0) return false;
    }
   
    return true;
}

void ResultUnit::Save(double** result)
{
    for(int i=0; i<Period; i++)
    {
        for(int j=0; j<FieldNum; j++)
        {
            value[i][j] += result[i][j];
        }
    }
}

 

'Programs' 카테고리의 다른 글

ModelEV.cpp  (2) 2014.08.14
GrpKeyTable.cpp  (0) 2014.08.14
FieldInfoSet.cpp  (0) 2014.08.14
Inc.hpp  (0) 2014.08.14
Group.cpp  (0) 2014.08.14
Posted by Analytical Warrior
|