Source Code (Use browser search to find items of interest.)

Class Index

kspread'KStats (./koffice/kspread/plugins/calculator/stats.h:33)

class KStats
{

public:

    KStats();
    ~KStats();

public:

    void clearAll();
    void enterData(CALCAMNT data);
    void clearLast();
    CALCAMNT min();
    CALCAMNT max();
    CALCAMNT sum();
    CALCAMNT mul();
    CALCAMNT sum_of_squares();
    CALCAMNT mean();
    CALCAMNT median();
    CALCAMNT std_kernel();
    CALCAMNT std();
    CALCAMNT sample_std();
    int	     count();
    bool     error();

private:

    QList<CALCAMNT> data;
    bool error_flag;

};


kspread'KStats::KStats() (./koffice/kspread/plugins/calculator/stats.cpp:31)

KStats::KStats(){

  error_flag = FALSE;
  data.setAutoDelete(TRUE);

}


kspread'KStats::~KStats() (./koffice/kspread/plugins/calculator/stats.cpp:38)

KStats::~KStats(){

  data.clear();

}


kspread'KStats::clearAll() (./koffice/kspread/plugins/calculator/stats.cpp:44)

void KStats::clearAll(){

  data.clear();

}


kspread'KStats::enterData() (./koffice/kspread/plugins/calculator/stats.cpp:50)

void KStats::enterData(CALCAMNT _data){

  CALCAMNT *newdata;
  newdata = new CALCAMNT;
  *newdata = _data;
  data.append(newdata);

#ifdef DEBUG_STATS
  printf("Added %Lg\n",*newdata);
  printf("count %d\n",data.count());
#endif

}



kspread'KStats::clearLast() (./koffice/kspread/plugins/calculator/stats.cpp:65)

void KStats::clearLast(){


 data.removeLast();
#ifdef DEBUG_STATS
printf("count %d\n",data.count());
#endif


}


kspread'KStats::sum() (./koffice/kspread/plugins/calculator/stats.cpp:76)

CALCAMNT KStats::sum(){

  CALCAMNT result = 0.0;
  CALCAMNT *dp;
  for ( dp=data.first(); dp != 0; dp=data.next() ){

    result += *dp;

  }

#ifdef DEBUG_STATS
  printf("Sum %Lg\n",result);
#endif

  return result;
}


kspread'KStats::min() (./koffice/kspread/plugins/calculator/stats.cpp:93)

CALCAMNT KStats::min()
{
  printf("MIIINNNN\n");

  if ( data.count() == 0 )
    return 0.0;

  printf("1\n");

  CALCAMNT result = *(data.first());
  printf("result=%f\n",result);

  CALCAMNT *dp = data.next();
  for ( ; dp != 0; dp=data.next() )
    if ( *dp < result )
      result = *dp;

  printf("Return\n");

  return result;
}


kspread'KStats::max() (./koffice/kspread/plugins/calculator/stats.cpp:115)

CALCAMNT KStats::max()
{
  if ( data.count() == 0 )
    return 0.0;

  CALCAMNT result = *(data.first());
  CALCAMNT *dp = data.next();
  for ( ; dp != 0; dp=data.next() )
    if ( *dp > result )
      result = *dp;

  return result;
}


kspread'KStats::mul() (./koffice/kspread/plugins/calculator/stats.cpp:129)

CALCAMNT KStats::mul(){

  CALCAMNT result = 1.0;
  CALCAMNT *dp;
  for ( dp=data.first(); dp != 0; dp=data.next() ){

    result *= *dp;

  }

  return result;
}


kspread'KStats::median() (./koffice/kspread/plugins/calculator/stats.cpp:142)

CALCAMNT KStats::median(){

  int index;
  CALCAMNT result;
  CALCAMNT *dp;
  int bound = 0;

  MyList list;

  for ( dp=data.first(); dp != 0; dp=data.next() ){
    list.inSort(dp);
  }

#ifdef DEBUG_STATS
  for(int l = 0; l < (int)list.count();l++){

    printf("Sorted %Lg\n",*list.at(l));

  }
#endif

  bound = list.count();

  if (bound == 0){
    error_flag = TRUE;
    return 0.0;
  }

  if ( bound == 1)
    return *list.at(0);

  if( bound % 2){  // odd

    index = (bound - 1 ) / 2 + 1;
    result =  *list.at(index - 1 );
  }
  else { // even

    index = bound / 2;
    result = ((*list.at(index - 1))  + (*list.at(index)))/2;
 }

  return result;

}




kspread'KStats::std_kernel() (./koffice/kspread/plugins/calculator/stats.cpp:190)

CALCAMNT KStats::std_kernel(){

  CALCAMNT result = 0.0;
  CALCAMNT _mean;

  _mean = mean();

  CALCAMNT *dp;
  for ( dp=data.first(); dp != 0; dp=data.next() ){

    result += (*dp - _mean) * (*dp - _mean);

  }

#ifdef DEBUG_STATS
  printf("std_kernel %Lg\n",result);
#endif

  return result;

}



kspread'KStats::sum_of_squares() (./koffice/kspread/plugins/calculator/stats.cpp:213)

CALCAMNT KStats::sum_of_squares(){

  CALCAMNT result = 0.0;
  CALCAMNT *dp;
  for ( dp=data.first(); dp != 0; dp=data.next() ){

    result += (*dp) * (*dp);

  }

#ifdef DEBUG_STATS
  printf("Sum of Squares %Lg\n",result);
#endif

  return result;

}


kspread'KStats::mean() (./koffice/kspread/plugins/calculator/stats.cpp:231)

CALCAMNT KStats::mean(){

  CALCAMNT result = 0.0;

  if(data.count() == 0){
    error_flag = TRUE;
    return 0.0;
  }

  result = sum()/data.count();

#ifdef DEBUG_STATS
  printf("mean: %Lg\n",result);
#endif

  return result;

}


kspread'KStats::std() (./koffice/kspread/plugins/calculator/stats.cpp:250)

CALCAMNT KStats::std(){

  CALCAMNT result = 0.0;

  if(data.count() == 0){
    error_flag = TRUE;

#ifdef DEBUG_STATS
    printf("set stats error\n");
#endif

    return 0.0;
  }

  result = SQRT(std_kernel());

#ifdef DEBUG_STATS
  printf ("data.count %d\n",data.count());
#endif

  result = result/data.count();

#ifdef DEBUG_STATS
  printf("std: %Lg\n",result);
#endif

  return result;

}


kspread'KStats::sample_std() (./koffice/kspread/plugins/calculator/stats.cpp:280)

CALCAMNT KStats::sample_std(){

  CALCAMNT result = 0.0;

  if(data.count() < 2 ){
    error_flag = TRUE;
    return 0.0;
  }

  result = SQRT(std_kernel());
  result = result/(data.count() - 1);
#ifdef DEBUG_STATS
  printf("sample std: %Lg\n",result);
#endif
  return result;

}


kspread'KStats::count() (./koffice/kspread/plugins/calculator/stats.cpp:298)

int  KStats::count(){

  return data.count();

}


kspread'KStats::error() (./koffice/kspread/plugins/calculator/stats.cpp:304)

bool KStats::error(){

  bool value;
  value = error_flag;
  error_flag = FALSE;

  return value;

}