Kaydet (Commit) 374f670a authored tarafından yiming ju's avatar yiming ju Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: implemented CHISQINV

AMLOEXT-148 FIX

Change-Id: I2f41abf89b8714e854efde85b88c2c2998d6da1a
Refacotring: convert fmax&fmin to max&min
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst a6ec8871
...@@ -696,9 +696,9 @@ public: ...@@ -696,9 +696,9 @@ public:
virtual std::string GetBottom(void) { return "MAXFLOAT"; } virtual std::string GetBottom(void) { return "MAXFLOAT"; }
virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
{ {
return "fmin("+lhs + "," + rhs +")"; return "min("+lhs + "," + rhs +")";
} }
virtual std::string BinFuncName(void) const { return "fmin"; } virtual std::string BinFuncName(void) const { return "min"; }
}; };
class OpMax: public Reduction { class OpMax: public Reduction {
...@@ -706,9 +706,9 @@ public: ...@@ -706,9 +706,9 @@ public:
virtual std::string GetBottom(void) { return "-MAXFLOAT"; } virtual std::string GetBottom(void) { return "-MAXFLOAT"; }
virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
{ {
return "fmax("+lhs + "," + rhs +")"; return "max("+lhs + "," + rhs +")";
} }
virtual std::string BinFuncName(void) const { return "fmax"; } virtual std::string BinFuncName(void) const { return "max"; }
}; };
class OpSumProduct: public SumOfProduct { class OpSumProduct: public SumOfProduct {
public: public:
...@@ -1232,6 +1232,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -1232,6 +1232,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiSqDist)); ft->Children[i],new OpChiSqDist));
break; break;
case ocChiSqInv:
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiSqInv));
break;
case ocExternal: case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString( if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect")))) "com.sun.star.sheet.addin.Analysis.getEffect"))))
......
...@@ -3000,6 +3000,61 @@ vSubArguments) ...@@ -3000,6 +3000,61 @@ vSubArguments)
} }
void OpChiSqInv::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
decls.insert(fMaxGammaArgumentDecl);decls.insert(GetChiSqDistCDFDecl);
decls.insert(GetLowRegIGammaDecl);decls.insert(lcl_IterateInverseChiSQInvDecl);
decls.insert(GetGammaContFractionDecl);decls.insert(GetGammaSeriesDecl);
decls.insert(fHalfMachEpsDecl);decls.insert(F_PIDecl);
decls.insert(fBigInvDecl);decls.insert(lcl_HasChangeOfSignDecl);
decls.insert(fMachEpsDecl);
funs.insert(GetGammaContFraction);funs.insert(GetChiSqDistCDF);
funs.insert(GetLowRegIGamma);funs.insert(lcl_HasChangeOfSign);
funs.insert(GetGammaSeries);funs.insert(lcl_IterateInverseChiSQInv);
}
void OpChiSqInv::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName, SubArguments &
vSubArguments)
{
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
if (i)
ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ") {\n";
ss << " int gid0 = get_global_id(0);\n";
ss << " int singleIndex = gid0;\n";
ss << " double result = 0;\n";
if(vSubArguments.size()!=2)
{
ss << " result = -DBL_MAX;\n";
ss << " return result;\n";
}else
{
GenTmpVariables(ss,vSubArguments);
CheckAllSubArgumentIsNan(ss,vSubArguments);
ss << " tmp1 = floor(tmp1);\n";
ss << " bool bConvError;\n";
ss << " if(tmp1 < 1.0 || tmp0 < 0 || tmp0>=1.0)\n";
ss << " result = -DBL_MAX;\n";
ss << " else\n";
ss << " {\n";
ss << " result =lcl_IterateInverseChiSQInv( tmp0, tmp1,";
ss << "tmp1*0.5, tmp1, &bConvError );\n";
ss << " }\n";
ss << " if(bConvError)\n";
ss << " result = -DBL_MAX;\n";
ss << " return result;\n";
ss << "}";
}
}
}} }}
......
...@@ -261,6 +261,16 @@ public: ...@@ -261,6 +261,16 @@ public:
virtual std::string BinFuncName(void) const { return "ChiSqDist"; } virtual std::string BinFuncName(void) const { return "ChiSqDist"; }
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
}; };
class OpChiSqInv: public CheckVariables
{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "ChiSqInv"; }
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
};
}} }}
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment