You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@madlib.apache.org by ri...@apache.org on 2016/02/29 20:49:46 UTC
incubator-madlib git commit: Hello World: Fix 'this' pointer errors
Repository: incubator-madlib
Updated Branches:
refs/heads/master 0545cdfc4 -> bca52f8c3
Hello World: Fix 'this' pointer errors
JIRA: MADLIB-967
This commit closes #20
Prev commit (0545cdf) closes #23
Project: http://git-wip-us.apache.org/repos/asf/incubator-madlib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-madlib/commit/bca52f8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-madlib/tree/bca52f8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-madlib/diff/bca52f8c
Branch: refs/heads/master
Commit: bca52f8c3ff91e8271d5e69fa6647a1561a957be
Parents: 0545cdf
Author: Babak Alipour <ba...@gmail.com>
Authored: Mon Feb 29 11:46:13 2016 -0800
Committer: Rahul Iyer <ri...@pivotal.io>
Committed: Mon Feb 29 11:49:24 2016 -0800
----------------------------------------------------------------------
examples/hello_world/non-iterative/avg_var.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/bca52f8c/examples/hello_world/non-iterative/avg_var.cpp
----------------------------------------------------------------------
diff --git a/examples/hello_world/non-iterative/avg_var.cpp b/examples/hello_world/non-iterative/avg_var.cpp
index 92ccd5e..bd60143 100644
--- a/examples/hello_world/non-iterative/avg_var.cpp
+++ b/examples/hello_world/non-iterative/avg_var.cpp
@@ -36,10 +36,10 @@ namespace hello_world {
template <class Handle>
class AvgVarTransitionState {
- template <class OtherHandle>
+ template <class OtherHandle>
friend class AvgVarTransitionState;
- public:
+public:
AvgVarTransitionState(const AnyType &inArray)
: mStorage(inArray.getAs<Handle>()) {
@@ -59,17 +59,17 @@ class AvgVarTransitionState {
/**
* @brief Update state with a new data point
*/
- template <class OtherHandle>
- AvgVarTransitionState &operator+=(const double x){
+ AvgVarTransitionState & operator+=(const double x){
double diff = (x - avg);
double normalizer = static_cast<double>(numRows + 1);
// online update mean
- this.avg += diff / normalizer;
+ this->avg += diff / normalizer;
// online update variance
double new_diff = (x - avg);
- double a = static_cast<double>(state.numRows) / normalizer;
- this.var = (var * a) + (diff * new_diff) / normalizer;
+ double a = static_cast<double>(this->numRows) / normalizer;
+ this->var = (var * a) + (diff * new_diff) / normalizer;
+ return *this;
}
/**
@@ -98,8 +98,8 @@ class AvgVarTransitionState {
double a_ = avg_ - totalAvg;
numRows += numRows_;
- this.var = (w * var) + (w_ * var_) + (w * a * a) + (w_ * a_ * a_);
- this.avg = totalAvg;
+ this->var = (w * var) + (w_ * var_) + (w * a * a) + (w_ * a_ * a_);
+ this->avg = totalAvg;
return *this;
}