Kaydet (Commit) 811c671c authored tarafından hongyu zhong's avatar hongyu zhong Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: implemented BETAINV

AMLOEXT-201 FIX

Change-Id: I68a7277b7353ed5a6f4d2ea8d1a4f7fb894bf487
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
üst 95b61096
......@@ -1762,6 +1762,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpSumX2PY2));
break;
case ocBetaInv:
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpBetainv));
break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
......
......@@ -6198,6 +6198,159 @@ void OpBetaDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n";
ss << "}\n";
}
void OpBetainv::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
decls.insert(fMachEpsDecl);
funs.insert("");
decls.insert(fMaxGammaArgumentDecl);
funs.insert("");
decls.insert(lcl_IterateInverseBetaInvDecl);
funs.insert(lcl_IterateInverseBetaInv);
decls.insert(GetBetaDistDecl);
funs.insert(GetBetaDist);
decls.insert(lcl_HasChangeOfSignDecl);
funs.insert(lcl_HasChangeOfSign);
decls.insert(lcl_HasChangeOfSignDecl);
funs.insert(lcl_HasChangeOfSign);
decls.insert(lcl_HasChangeOfSignDecl);
funs.insert(lcl_HasChangeOfSign);
decls.insert(lcl_GetBetaHelperContFracDecl);
funs.insert(lcl_GetBetaHelperContFrac);
decls.insert(GetBetaDistPDFDecl);
funs.insert(GetBetaDistPDF);
decls.insert(GetLogBetaDecl);
funs.insert(GetLogBeta);
decls.insert(GetBetaDecl);
funs.insert(GetBeta);
decls.insert(lcl_getLanczosSumDecl);
funs.insert(lcl_getLanczosSum);
}
void OpBetainv::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 << "{\n";
ss << " double tmp0,tmp1,tmp2,tmp3,tmp4;\n";
ss << " int gid0=get_global_id(0);\n";
size_t i = vSubArguments.size();
size_t nItems = 0;
ss <<"\n ";
//while (i-- > 1)
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
assert(pCur);
if (pCur->GetType() == formula::svDoubleVectorRef)
{
const formula::DoubleVectorRefToken* pDVR =
dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
size_t nCurWindowSize = pDVR->GetRefRowSize();
ss << "for (int i = ";
if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
#ifdef ISNAN
ss << "gid0; i < " << pDVR->GetArrayLength();
ss << " && i < " << nCurWindowSize << "; i++){\n";
#else
ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
#endif
} else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
#ifdef ISNAN
ss << "0; i < " << pDVR->GetArrayLength();
ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
#else
ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
#endif
} else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
#ifdef ISNAN
ss << "0; i + gid0 < " << pDVR->GetArrayLength();
ss << " && i < "<< nCurWindowSize << "; i++){\n";
#else
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
else {
#ifdef ISNAN
ss << "0; i < "<< nCurWindowSize << "; i++){\n";
#else
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
#ifdef ISNAN
const formula::SingleVectorRefToken* pSVR =
dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
{
#ifdef ISNAN
ss << "{\n";
#endif
nItems += 1;
}
else
{
#ifdef ISNAN
#endif
nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
{
ss << " if (isNan(";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << "))\n";
ss << " tmp"<<i<<"= 0;\n";
ss << " else\n";
ss << " tmp"<<i<<"=\n";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ";\n}\n";
}
else
{
ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n";
}
#else
ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
ss <<";\n";
#endif
}
ss << " if (tmp0 < 0.0 || tmp0 >= 1.0 ||";
ss << "tmp3 == tmp4 || tmp1 <= 0.0 || tmp2 <= 0.0)\n";
ss << " {\n";
ss << " return DBL_MIN;\n";
ss << " }\n";
ss << " if (tmp0 == 0.0)\n";
ss << " return 0.0;\n";
ss << " else\n";
ss << " {";
ss << " bool bConvError;";
ss << " double fVal = lcl_IterateInverseBetaInv";
ss << "(tmp0, tmp1, tmp2, 0.0, 1.0, &bConvError);\n";
ss << " if(bConvError)\n";
ss << " return DBL_MIN;\n";
ss << " else\n";
ss << " return (tmp3 + fVal*(tmp4 - tmp3));\n";
ss << " }";
ss << "}\n";
}
void OpDevSq::GenSlidingWindowFunction(std::stringstream& ss,
const std::string sSymName, SubArguments& vSubArguments)
{
......
......@@ -406,7 +406,13 @@ public:
);
virtual std::string BinFuncName(void) const { return "BetaDist"; }
};
class OpBetainv:public Normal{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments);
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
virtual std::string BinFuncName(void) const { return "OpBetainv"; }
};
}}
#endif
......
......@@ -432,6 +432,7 @@ std::string lcl_IterateInverseBetaInv =
"{\n"
" *rConvError = false;\n"
" double fYEps = 1.0E-307;\n"
" double fXEps = fMachEps;\n"
" if(!(fAx < fBx))\n"
" {\n"
" //print error\n"
......
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