Commit 2f07adf4edb3f64c2888bb8e030f011043f29b83
1 parent
2ed0b752
Exists in
master
and in
70 other branches
us ok
Showing
1 changed file
with
320 additions
and
309 deletions
Show diff stats
src/ExternLib/StatisticProcesses/MinMaxMeanStatistic.hh
... | ... | @@ -47,8 +47,8 @@ namespace AMDA { |
47 | 47 | */ |
48 | 48 | typedef typename TParamData::ElementType ElementType; |
49 | 49 | |
50 | - | |
51 | - using TimeDataList = std::vector<std::pair<double, ElementType>>; | |
50 | + | |
51 | + using TimeDataList = std::vector<std::pair<double, ElementType>>; | |
52 | 52 | |
53 | 53 | MinMaxMeanStatisticOperation(StatisticProcess& process, |
54 | 54 | TimeIntervalListSPtr pTimeIntervalList, TParamData ¶m, FUNC_TYPE funcType) : |
... | ... | @@ -131,7 +131,9 @@ namespace AMDA { |
131 | 131 | finalizeKurtosisResult(StatisticOperation<TResultData>::_resultData); |
132 | 132 | } else if (_funcType == FT_FIRST_VALUE) { |
133 | 133 | finalizeFirstValueResult(StatisticOperation<TResultData>::_resultData); |
134 | - }else if (_funcType == FT_LAST_VALUE) { | |
134 | + }else if (_funcType == FT_MIDDLE_VALUE) { | |
135 | + finalizeMiddleValueResult(StatisticOperation<TResultData>::_resultData); | |
136 | + } else if (_funcType == FT_LAST_VALUE) { | |
135 | 137 | finalizeLastValueResult(StatisticOperation<TResultData>::_resultData); |
136 | 138 | } |
137 | 139 | } |
... | ... | @@ -403,12 +405,11 @@ namespace AMDA { |
403 | 405 | } |
404 | 406 | } |
405 | 407 | // fill timeDataList |
406 | - for (int i = 0; i < a.size(); i++) { | |
407 | - std::vector<Type> vec; | |
408 | - vec.push_back(a[i]); | |
409 | - _timeDataList.push_back(std::make_pair(time, vec)); | |
410 | - vec.clear(); | |
411 | - } | |
408 | + std::vector<Type> vec; | |
409 | + for (int i = 0; i < a.size(); i++) | |
410 | + vec.push_back(a[i]); | |
411 | + _timeDataList.push_back(std::make_pair(time, vec)); | |
412 | + vec.clear(); | |
412 | 413 | } |
413 | 414 | |
414 | 415 | template<typename Type> |
... | ... | @@ -503,7 +504,6 @@ namespace AMDA { |
503 | 504 | } |
504 | 505 | } |
505 | 506 | |
506 | - /* | |
507 | 507 | template<typename Type> |
508 | 508 | void finalizeMiddleValueResult(Type & a) { |
509 | 509 | if (_timeDataList.size() == 0) |
... | ... | @@ -512,7 +512,17 @@ namespace AMDA { |
512 | 512 | a._result = _timeDataList[0].second; |
513 | 513 | return; |
514 | 514 | } else { |
515 | - a._result = getMiddleValue(_timeDataList); | |
515 | + double middeTime = (_timeDataList.front().first + _timeDataList.back().first) / 2; | |
516 | + for (int i = 0; i < _timeDataList.size(); i++) { | |
517 | + if (_timeDataList[i].first == middeTime) { | |
518 | + a._result = _timeDataList[i].second; | |
519 | + return; | |
520 | + } else if (_timeDataList[i].first > middeTime) { | |
521 | + a._result = _timeDataList[i - 1].second + (_timeDataList[i].second - _timeDataList[i - 1].second)* | |
522 | + ((middeTime - _timeDataList[i - 1].first) / (_timeDataList[i].first - _timeDataList[i - 1].first)); | |
523 | + return; | |
524 | + } | |
525 | + } | |
516 | 526 | } |
517 | 527 | } |
518 | 528 | |
... | ... | @@ -520,319 +530,320 @@ namespace AMDA { |
520 | 530 | void finalizeMiddleValueResult(std::vector<Type> & a) { |
521 | 531 | |
522 | 532 | //vector of pair <time dataScalar> |
523 | - std::vector<std::pair<double, Type>> timeDataList; | |
524 | - for (int i = 0; i < a.size(); i++) { | |
533 | + std::vector<std::pair<double, double>> timeDataList; | |
534 | + for (int i = 0; i < a.size(); i++) { | |
525 | 535 | for (auto val : _timeDataList) { |
526 | - if (!isNAN(val.second[i])){ | |
527 | - | |
528 | - timeDataList.push_back(std::make_pair(val.first, val.second[i])); | |
529 | - } | |
530 | - } | |
531 | - if (timeDataList.size() == 0) | |
532 | - continue; | |
533 | - a[i].result = getMiddleValue(timeDataList); | |
534 | - timeDataList.clear(); | |
535 | - } | |
536 | - } | |
537 | - | |
538 | - | |
539 | - template<typename Type> | |
540 | - Type getMiddleValue(std::vector<std::pair<double, StatisticDataScalar<Type> >> time1DDataList) { | |
541 | - if (time1DDataList.size() == 1) { | |
542 | - return time1DDataList[0].second; | |
543 | - } | |
544 | - double middeTime = (time1DDataList.front().first + time1DDataList.back().first) / 2; | |
545 | - for (int i = 0; i < time1DDataList.size(); i++) { | |
546 | - if (time1DDataList[i].first == middeTime) { | |
547 | - return time1DDataList[i].second; | |
548 | - } else if (time1DDataList[i].first > middeTime) { | |
549 | - return time1DDataList[i - 1].second + (time1DDataList[i].second - time1DDataList[i - 1].second)* | |
550 | - ((middeTime - time1DDataList[i - 1].first) / (time1DDataList[i].first - time1DDataList[i - 1].first)); | |
551 | - | |
536 | + if (!isNAN(val.second[i])) | |
537 | + timeDataList.push_back(std::make_pair(val.first, (double) val.second[i])); | |
552 | 538 | } |
539 | + | |
540 | + if (timeDataList.size() == 0) | |
541 | + continue; | |
542 | + a[i]._result = getMiddleValue(timeDataList); | |
543 | + timeDataList.clear(); | |
544 | + } | |
545 | + } | |
546 | + | |
547 | + | |
548 | + double getMiddleValue(std::vector<std::pair<double, double >> time1DDataList) { | |
549 | + if (time1DDataList.size() == 1) { | |
550 | + return time1DDataList[0].second; | |
551 | + } | |
552 | + double middeTime = (time1DDataList.front().first + time1DDataList.back().first) / 2; | |
553 | + double res = std::numeric_limits<double>::quiet_NaN(); | |
554 | + for (int i = 0; i < time1DDataList.size(); i++) { | |
555 | + if (time1DDataList[i].first == middeTime) { | |
556 | + res= time1DDataList[i].second; | |
557 | + break; | |
558 | + } else if (time1DDataList[i].first > middeTime) { | |
559 | + res = time1DDataList[i - 1].second + (time1DDataList[i].second - time1DDataList[i - 1].second)* | |
560 | + ((middeTime - time1DDataList[i - 1].first) / (time1DDataList[i].first - time1DDataList[i - 1].first)); | |
561 | + break; | |
553 | 562 | } |
554 | 563 | } |
555 | -*/ | |
556 | - template<typename Type> | |
557 | - void finalizeVarianceResult(Type & a) { | |
558 | - if (_dataList.size() == 0) | |
564 | + return res; | |
565 | + } | |
566 | + | |
567 | + template<typename Type> | |
568 | + void finalizeVarianceResult(Type & a) { | |
569 | + if (_dataList.size() == 0) | |
570 | + return; | |
571 | + double accum = 0.0; | |
572 | + std::for_each(std::begin(_dataList), std::end(_dataList), [&](const double d) { | |
573 | + accum += (d - _mean) * (d - _mean); | |
574 | + }); | |
575 | + a._result = accum / (_dataList.size()); | |
576 | + _standardDeviation = sqrt(a._result); | |
577 | + } | |
578 | + | |
579 | + template<typename Type> | |
580 | + void finalizeVarianceResult(std::vector<Type> & a) { | |
581 | + for (int i = 0; i < a.size(); i++) { | |
582 | + if (_dataList[i].size() == 0) | |
559 | 583 | return; |
560 | 584 | double accum = 0.0; |
561 | - std::for_each(std::begin(_dataList), std::end(_dataList), [&](const double d) { | |
562 | - accum += (d - _mean) * (d - _mean); | |
585 | + std::for_each(std::begin(_dataList[i]), std::end(_dataList[i]), [&](const double d) { | |
586 | + accum += (d - _mean[i]) * (d - _mean[i]); | |
563 | 587 | }); |
564 | - a._result = accum / (_dataList.size()); | |
565 | - _standardDeviation = sqrt(a._result); | |
566 | - } | |
567 | - | |
568 | - template<typename Type> | |
569 | - void finalizeVarianceResult(std::vector<Type> & a) { | |
570 | - for (int i = 0; i < a.size(); i++) { | |
571 | - if (_dataList[i].size() == 0) | |
572 | - return; | |
573 | - double accum = 0.0; | |
574 | - std::for_each(std::begin(_dataList[i]), std::end(_dataList[i]), [&](const double d) { | |
575 | - accum += (d - _mean[i]) * (d - _mean[i]); | |
576 | - }); | |
577 | - a[i]._result = accum / (_dataList[i].size()); | |
578 | - _standardDeviation.push_back(sqrt(a[i]._result)); | |
579 | - } | |
580 | - } | |
581 | - | |
582 | - template<typename Type> | |
583 | - void finalizeSkewnessResult(Type & a) { | |
584 | - int n = _dataList.size(); | |
588 | + a[i]._result = accum / (_dataList[i].size()); | |
589 | + _standardDeviation.push_back(sqrt(a[i]._result)); | |
590 | + } | |
591 | + } | |
592 | + | |
593 | + template<typename Type> | |
594 | + void finalizeSkewnessResult(Type & a) { | |
595 | + int n = _dataList.size(); | |
596 | + if (n == 0) | |
597 | + return; | |
598 | + double accum = 0.0; | |
599 | + std::for_each(std::begin(_dataList), std::end(_dataList), [&](const double d) { | |
600 | + accum += (d - _mean) * (d - _mean) * (d - _mean); | |
601 | + }); | |
602 | + a._result = n / ((double) (n - 1)*(n - 2)) * accum / pow(_standardDeviation, 3); | |
603 | + } | |
604 | + | |
605 | + template<typename Type> | |
606 | + void finalizeSkewnessResult(std::vector<Type> & a) { | |
607 | + for (int i = 0; i < a.size(); i++) { | |
608 | + int n = _dataList[i].size(); | |
585 | 609 | if (n == 0) |
586 | 610 | return; |
587 | 611 | double accum = 0.0; |
588 | - std::for_each(std::begin(_dataList), std::end(_dataList), [&](const double d) { | |
589 | - accum += (d - _mean) * (d - _mean) * (d - _mean); | |
612 | + std::for_each(std::begin(_dataList[i]), std::end(_dataList[i]), [&](const double d) { | |
613 | + accum += (d - _mean[i]) * (d - _mean[i]) * (d - _mean[i]); | |
590 | 614 | }); |
591 | - a._result = n / ((double) (n - 1)*(n - 2)) * accum / pow(_standardDeviation, 3); | |
592 | - } | |
593 | - | |
594 | - template<typename Type> | |
595 | - void finalizeSkewnessResult(std::vector<Type> & a) { | |
596 | - for (int i = 0; i < a.size(); i++) { | |
597 | - int n = _dataList[i].size(); | |
598 | - if (n == 0) | |
599 | - return; | |
600 | - double accum = 0.0; | |
601 | - std::for_each(std::begin(_dataList[i]), std::end(_dataList[i]), [&](const double d) { | |
602 | - accum += (d - _mean[i]) * (d - _mean[i]) * (d - _mean[i]); | |
603 | - }); | |
604 | - a[i]._result = n / ((double) (n - 1)*(n - 2)) * accum / pow(_standardDeviation[i], 3); | |
605 | - } | |
606 | - } | |
607 | - | |
608 | - template<typename Type> | |
609 | - void finalizeKurtosisResult(Type & a) { | |
610 | - int n = _dataList.size(); | |
615 | + a[i]._result = n / ((double) (n - 1)*(n - 2)) * accum / pow(_standardDeviation[i], 3); | |
616 | + } | |
617 | + } | |
618 | + | |
619 | + template<typename Type> | |
620 | + void finalizeKurtosisResult(Type & a) { | |
621 | + int n = _dataList.size(); | |
622 | + if (n == 0) | |
623 | + return; | |
624 | + double accum = 0.0; | |
625 | + std::for_each(std::begin(_dataList), std::end(_dataList), [&](const double d) { | |
626 | + accum += (d - _mean) * (d - _mean) * (d - _mean) * (d - _mean) / pow(_standardDeviation, 4); | |
627 | + }); | |
628 | + a._result = n * (n + 1) / ((double) (n - 1)*(n - 2)*(n - 3)) * accum - 3 * (n - 1)*(n - 1) / ((double) (n - 2)*(n - 3)); | |
629 | + } | |
630 | + | |
631 | + template<typename Type> | |
632 | + void finalizeKurtosisResult(std::vector<Type> & a) { | |
633 | + for (int i = 0; i < a.size(); i++) { | |
634 | + int n = _dataList[i].size(); | |
611 | 635 | if (n == 0) |
612 | 636 | return; |
613 | 637 | double accum = 0.0; |
614 | - std::for_each(std::begin(_dataList), std::end(_dataList), [&](const double d) { | |
615 | - accum += (d - _mean) * (d - _mean) * (d - _mean) * (d - _mean) / pow(_standardDeviation, 4); | |
638 | + std::for_each(std::begin(_dataList[i]), std::end(_dataList[i]), [&](const double d) { | |
639 | + accum += (d - _mean[i]) * (d - _mean[i]) * (d - _mean[i]) * (d - _mean[i]) / pow(_standardDeviation[i], 4); | |
616 | 640 | }); |
617 | - a._result = n * (n + 1) / ((double) (n - 1)*(n - 2)*(n - 3)) * accum - 3 * (n - 1)*(n - 1) / ((double) (n - 2)*(n - 3)); | |
618 | - } | |
619 | - | |
620 | - template<typename Type> | |
621 | - void finalizeKurtosisResult(std::vector<Type> & a) { | |
622 | - for (int i = 0; i < a.size(); i++) { | |
623 | - int n = _dataList[i].size(); | |
624 | - if (n == 0) | |
625 | - return; | |
626 | - double accum = 0.0; | |
627 | - std::for_each(std::begin(_dataList[i]), std::end(_dataList[i]), [&](const double d) { | |
628 | - accum += (d - _mean[i]) * (d - _mean[i]) * (d - _mean[i]) * (d - _mean[i]) / pow(_standardDeviation[i], 4); | |
629 | - }); | |
630 | - a[i]._result = n * (n + 1) / ((double) (n - 1)*(n - 2)*(n - 3)) * accum - 3 * (n - 1)*(n - 1) / ((double) (n - 2)*(n - 3)); | |
631 | - } | |
632 | - } | |
633 | - | |
634 | - /** | |
635 | - * @brief real ParamData Input | |
636 | - */ | |
637 | - TParamData& _paramInput; | |
638 | - | |
639 | - TimeIntervalListSPtr _timeIntervalList; | |
640 | - | |
641 | - TimeIntervalList::iterator _currentTimeInterval; | |
642 | - | |
643 | - ElementType _val; | |
644 | - | |
645 | - ElementType _mean; | |
646 | - | |
647 | - ElementType _standardDeviation; | |
648 | - | |
649 | - std::vector<ElementType> _dataList; | |
650 | - | |
651 | - /* | |
652 | - * vector of pair<time, data> | |
653 | - */ | |
654 | - TimeDataList _timeDataList; | |
655 | - | |
656 | - | |
657 | - FUNC_TYPE _funcType; | |
658 | - | |
659 | - std::stringstream _dimDef; | |
660 | - }; | |
661 | - | |
662 | - class CreateMinMaxMeanStatistic : public VisitorOfParamData { | |
663 | - public: | |
664 | - | |
665 | - /** | |
666 | - * @brief constructor | |
667 | - */ | |
668 | - CreateMinMaxMeanStatistic(StatisticProcess& pProcess, | |
669 | - TimeIntervalListSPtr pTimeIntervalList, | |
670 | - ParamData ¶mData, FUNC_TYPE type) : | |
671 | - _process(pProcess), _timeIntervalList(pTimeIntervalList), | |
672 | - _paramData(paramData), _operation(NULL), _type(type) { | |
673 | - _paramData.accept(*this); | |
674 | - } | |
675 | - | |
676 | - StatisticOperationBase* getStatisticOperation(void) { | |
677 | - return _operation; | |
678 | - } | |
679 | - | |
680 | - /** | |
681 | - * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) | |
682 | - */ | |
683 | - virtual void visit(ParamDataScalaireShort *) { | |
684 | - _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireShort, StatisticDataScalar<short>>(_process, | |
685 | - _timeIntervalList, dynamic_cast<ParamDataScalaireShort &> (_paramData), _type); | |
686 | - } | |
687 | - | |
688 | - /** | |
689 | - * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) | |
690 | - */ | |
691 | - virtual void visit(ParamDataScalaireFloat *) { | |
692 | - _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireFloat, StatisticDataScalar<float>>(_process, | |
693 | - _timeIntervalList, dynamic_cast<ParamDataScalaireFloat &> (_paramData), _type); | |
694 | - } | |
695 | - | |
696 | - /** | |
697 | - * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) | |
698 | - */ | |
699 | - virtual void visit(ParamDataScalaireDouble *) { | |
700 | - _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireDouble, StatisticDataScalar<double>>(_process, | |
701 | - _timeIntervalList, dynamic_cast<ParamDataScalaireDouble &> (_paramData), _type); | |
702 | - } | |
703 | - | |
704 | - /** | |
705 | - * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) | |
706 | - */ | |
707 | - virtual void visit(ParamDataScalaireLongDouble *) { | |
708 | - _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireLongDouble, StatisticDataScalar<long double>>(_process, | |
709 | - _timeIntervalList, dynamic_cast<ParamDataScalaireLongDouble &> (_paramData), _type); | |
710 | - } | |
711 | - | |
712 | - /** | |
713 | - * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) | |
714 | - */ | |
715 | - virtual void visit(ParamDataScalaireInt *) { | |
716 | - _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireInt, StatisticDataScalar<int>>(_process, | |
717 | - _timeIntervalList, dynamic_cast<ParamDataScalaireInt &> (_paramData), _type); | |
718 | - } | |
719 | - | |
720 | - /** | |
721 | - * @overload VisitorOfParamData::visit(ParamDataLogicalData *) | |
722 | - */ | |
723 | - virtual void visit(ParamDataLogicalData *) { | |
724 | - BOOST_THROW_EXCEPTION( | |
725 | - AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) | |
726 | - << AMDA::ex_msg( | |
727 | - "CreateStatistic operation not supported")); | |
728 | - } | |
729 | - | |
730 | - /** | |
731 | - * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) | |
732 | - */ | |
733 | - virtual void visit(ParamDataTab1DShort *) { | |
734 | - _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DShort, StatisticDataVector<short>>(_process, | |
735 | - _timeIntervalList, dynamic_cast<ParamDataTab1DShort &> (_paramData), _type); | |
736 | - } | |
737 | - | |
738 | - /** | |
739 | - * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) | |
740 | - */ | |
741 | - virtual void visit(ParamDataTab1DFloat *) { | |
742 | - _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DFloat, StatisticDataVector<float>>(_process, | |
743 | - _timeIntervalList, dynamic_cast<ParamDataTab1DFloat &> (_paramData), _type); | |
744 | - } | |
745 | - | |
746 | - /** | |
747 | - * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) | |
748 | - */ | |
749 | - virtual void visit(ParamDataTab1DDouble *) { | |
750 | - _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DDouble, StatisticDataVector<double>>(_process, | |
751 | - _timeIntervalList, dynamic_cast<ParamDataTab1DDouble &> (_paramData), _type); | |
752 | - } | |
753 | - | |
754 | - /** | |
755 | - * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) | |
756 | - */ | |
757 | - virtual void visit(ParamDataTab1DLongDouble *) { | |
758 | - _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DLongDouble, StatisticDataVector<long double>>(_process, | |
759 | - _timeIntervalList, dynamic_cast<ParamDataTab1DLongDouble &> (_paramData), _type); | |
760 | - } | |
761 | - | |
762 | - /** | |
763 | - * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) | |
764 | - */ | |
765 | - virtual void visit(ParamDataTab1DInt *) { | |
766 | - _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DInt, StatisticDataVector<int>>(_process, | |
767 | - _timeIntervalList, dynamic_cast<ParamDataTab1DInt &> (_paramData), _type); | |
768 | - } | |
769 | - | |
770 | - /** | |
771 | - * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) | |
772 | - */ | |
773 | - virtual void visit(ParamDataTab1DLogicalData *) { | |
774 | - BOOST_THROW_EXCEPTION( | |
775 | - AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) | |
776 | - << AMDA::ex_msg( | |
777 | - "CreateStatistic operation not supported")); | |
778 | - } | |
779 | - | |
780 | - /** | |
781 | - * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) | |
782 | - */ | |
783 | - virtual void visit(ParamDataTab2DShort *) { | |
784 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DShort data not supported")); | |
785 | - } | |
786 | - | |
787 | - /** | |
788 | - * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) | |
789 | - */ | |
790 | - virtual void visit(ParamDataTab2DFloat *) { | |
791 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DFloat data not supported")); | |
792 | - } | |
793 | - | |
794 | - /** | |
795 | - * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) | |
796 | - */ | |
797 | - virtual void visit(ParamDataTab2DDouble *) { | |
798 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DDouble data not supported")); | |
799 | - } | |
800 | - | |
801 | - /** | |
802 | - * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) | |
803 | - */ | |
804 | - virtual void visit(ParamDataTab2DLongDouble *) { | |
805 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLongDouble data not supported")); | |
806 | - } | |
807 | - | |
808 | - /** | |
809 | - * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) | |
810 | - */ | |
811 | - virtual void visit(ParamDataTab2DInt *) { | |
812 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DInt data not supported")); | |
813 | - } | |
814 | - | |
815 | - /** | |
816 | - * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) | |
817 | - */ | |
818 | - virtual void visit(ParamDataTab2DLogicalData *) { | |
819 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLogicalData data not supported")); | |
820 | - } | |
821 | - | |
822 | - private: | |
823 | - StatisticProcess& _process; | |
824 | - | |
825 | - TimeIntervalListSPtr& _timeIntervalList; | |
826 | - | |
827 | - ParamData &_paramData; | |
828 | - | |
829 | - StatisticOperationBase *_operation; | |
830 | - | |
831 | - FUNC_TYPE _type; | |
832 | - }; | |
833 | - | |
834 | - } /* namespace MinMaxMean */ | |
835 | - } /* namespace Statistic */ | |
641 | + a[i]._result = n * (n + 1) / ((double) (n - 1)*(n - 2)*(n - 3)) * accum - 3 * (n - 1)*(n - 1) / ((double) (n - 2)*(n - 3)); | |
642 | + } | |
643 | + } | |
644 | + | |
645 | + /** | |
646 | + * @brief real ParamData Input | |
647 | + */ | |
648 | + TParamData& _paramInput; | |
649 | + | |
650 | + TimeIntervalListSPtr _timeIntervalList; | |
651 | + | |
652 | + TimeIntervalList::iterator _currentTimeInterval; | |
653 | + | |
654 | + ElementType _val; | |
655 | + | |
656 | + ElementType _mean; | |
657 | + | |
658 | + ElementType _standardDeviation; | |
659 | + | |
660 | + std::vector<ElementType> _dataList; | |
661 | + | |
662 | + /* | |
663 | + * vector of pair<time, data> | |
664 | + */ | |
665 | + TimeDataList _timeDataList; | |
666 | + | |
667 | + | |
668 | + FUNC_TYPE _funcType; | |
669 | + | |
670 | + std::stringstream _dimDef; | |
671 | + }; | |
672 | + | |
673 | + class CreateMinMaxMeanStatistic : public VisitorOfParamData { | |
674 | + public: | |
675 | + | |
676 | + /** | |
677 | + * @brief constructor | |
678 | + */ | |
679 | + CreateMinMaxMeanStatistic(StatisticProcess& pProcess, | |
680 | + TimeIntervalListSPtr pTimeIntervalList, | |
681 | + ParamData ¶mData, FUNC_TYPE type) : | |
682 | + _process(pProcess), _timeIntervalList(pTimeIntervalList), | |
683 | + _paramData(paramData), _operation(NULL), _type(type) { | |
684 | + _paramData.accept(*this); | |
685 | + } | |
686 | + | |
687 | + StatisticOperationBase* getStatisticOperation(void) { | |
688 | + return _operation; | |
689 | + } | |
690 | + | |
691 | + /** | |
692 | + * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) | |
693 | + */ | |
694 | + virtual void visit(ParamDataScalaireShort *) { | |
695 | + _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireShort, StatisticDataScalar<short>>(_process, | |
696 | + _timeIntervalList, dynamic_cast<ParamDataScalaireShort &> (_paramData), _type); | |
697 | + } | |
698 | + | |
699 | + /** | |
700 | + * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) | |
701 | + */ | |
702 | + virtual void visit(ParamDataScalaireFloat *) { | |
703 | + _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireFloat, StatisticDataScalar<float>>(_process, | |
704 | + _timeIntervalList, dynamic_cast<ParamDataScalaireFloat &> (_paramData), _type); | |
705 | + } | |
706 | + | |
707 | + /** | |
708 | + * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) | |
709 | + */ | |
710 | + virtual void visit(ParamDataScalaireDouble *) { | |
711 | + _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireDouble, StatisticDataScalar<double>>(_process, | |
712 | + _timeIntervalList, dynamic_cast<ParamDataScalaireDouble &> (_paramData), _type); | |
713 | + } | |
714 | + | |
715 | + /** | |
716 | + * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) | |
717 | + */ | |
718 | + virtual void visit(ParamDataScalaireLongDouble *) { | |
719 | + _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireLongDouble, StatisticDataScalar<long double>>(_process, | |
720 | + _timeIntervalList, dynamic_cast<ParamDataScalaireLongDouble &> (_paramData), _type); | |
721 | + } | |
722 | + | |
723 | + /** | |
724 | + * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) | |
725 | + */ | |
726 | + virtual void visit(ParamDataScalaireInt *) { | |
727 | + _operation = new MinMaxMeanStatisticOperation<ParamDataScalaireInt, StatisticDataScalar<int>>(_process, | |
728 | + _timeIntervalList, dynamic_cast<ParamDataScalaireInt &> (_paramData), _type); | |
729 | + } | |
730 | + | |
731 | + /** | |
732 | + * @overload VisitorOfParamData::visit(ParamDataLogicalData *) | |
733 | + */ | |
734 | + virtual void visit(ParamDataLogicalData *) { | |
735 | + BOOST_THROW_EXCEPTION( | |
736 | + AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) | |
737 | + << AMDA::ex_msg( | |
738 | + "CreateStatistic operation not supported")); | |
739 | + } | |
740 | + | |
741 | + /** | |
742 | + * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) | |
743 | + */ | |
744 | + virtual void visit(ParamDataTab1DShort *) { | |
745 | + _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DShort, StatisticDataVector<short>>(_process, | |
746 | + _timeIntervalList, dynamic_cast<ParamDataTab1DShort &> (_paramData), _type); | |
747 | + } | |
748 | + | |
749 | + /** | |
750 | + * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) | |
751 | + */ | |
752 | + virtual void visit(ParamDataTab1DFloat *) { | |
753 | + _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DFloat, StatisticDataVector<float>>(_process, | |
754 | + _timeIntervalList, dynamic_cast<ParamDataTab1DFloat &> (_paramData), _type); | |
755 | + } | |
756 | + | |
757 | + /** | |
758 | + * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) | |
759 | + */ | |
760 | + virtual void visit(ParamDataTab1DDouble *) { | |
761 | + _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DDouble, StatisticDataVector<double>>(_process, | |
762 | + _timeIntervalList, dynamic_cast<ParamDataTab1DDouble &> (_paramData), _type); | |
763 | + } | |
764 | + | |
765 | + /** | |
766 | + * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) | |
767 | + */ | |
768 | + virtual void visit(ParamDataTab1DLongDouble *) { | |
769 | + _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DLongDouble, StatisticDataVector<long double>>(_process, | |
770 | + _timeIntervalList, dynamic_cast<ParamDataTab1DLongDouble &> (_paramData), _type); | |
771 | + } | |
772 | + | |
773 | + /** | |
774 | + * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) | |
775 | + */ | |
776 | + virtual void visit(ParamDataTab1DInt *) { | |
777 | + _operation = new MinMaxMeanStatisticOperation<ParamDataTab1DInt, StatisticDataVector<int>>(_process, | |
778 | + _timeIntervalList, dynamic_cast<ParamDataTab1DInt &> (_paramData), _type); | |
779 | + } | |
780 | + | |
781 | + /** | |
782 | + * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) | |
783 | + */ | |
784 | + virtual void visit(ParamDataTab1DLogicalData *) { | |
785 | + BOOST_THROW_EXCEPTION( | |
786 | + AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) | |
787 | + << AMDA::ex_msg( | |
788 | + "CreateStatistic operation not supported")); | |
789 | + } | |
790 | + | |
791 | + /** | |
792 | + * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) | |
793 | + */ | |
794 | + virtual void visit(ParamDataTab2DShort *) { | |
795 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DShort data not supported")); | |
796 | + } | |
797 | + | |
798 | + /** | |
799 | + * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) | |
800 | + */ | |
801 | + virtual void visit(ParamDataTab2DFloat *) { | |
802 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DFloat data not supported")); | |
803 | + } | |
804 | + | |
805 | + /** | |
806 | + * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) | |
807 | + */ | |
808 | + virtual void visit(ParamDataTab2DDouble *) { | |
809 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DDouble data not supported")); | |
810 | + } | |
811 | + | |
812 | + /** | |
813 | + * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) | |
814 | + */ | |
815 | + virtual void visit(ParamDataTab2DLongDouble *) { | |
816 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLongDouble data not supported")); | |
817 | + } | |
818 | + | |
819 | + /** | |
820 | + * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) | |
821 | + */ | |
822 | + virtual void visit(ParamDataTab2DInt *) { | |
823 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DInt data not supported")); | |
824 | + } | |
825 | + | |
826 | + /** | |
827 | + * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) | |
828 | + */ | |
829 | + virtual void visit(ParamDataTab2DLogicalData *) { | |
830 | + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLogicalData data not supported")); | |
831 | + } | |
832 | + | |
833 | + private: | |
834 | + StatisticProcess& _process; | |
835 | + | |
836 | + TimeIntervalListSPtr& _timeIntervalList; | |
837 | + | |
838 | + ParamData &_paramData; | |
839 | + | |
840 | + StatisticOperationBase *_operation; | |
841 | + | |
842 | + FUNC_TYPE _type; | |
843 | + }; | |
844 | + | |
845 | + } /* namespace MinMaxMean */ | |
846 | +} /* namespace Statistic */ | |
836 | 847 | } /* namespace AMDA */ |
837 | 848 | |
838 | 849 | #endif /* MINMAXMEANSTATISTIC_HH_ */ | ... | ... |