Kaydet (Commit) 27097337 authored tarafından dechuang's avatar dechuang Kaydeden (comit) I-Jui (Ray) Sung

GPU Calc: implemented ODD

AMLOEXT-153 FIX

Change-Id: I97b823f3d31879a7b79456fd0a5c3696957795f9
Signed-off-by: 's avatarhaochen <haochen@multicorewareinc.com>
Signed-off-by: 's avatarI-Jui (Ray) Sung <ray@multicorewareinc.com>
üst 99910c63
...@@ -1224,6 +1224,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( ...@@ -1224,6 +1224,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpPower)); ft->Children[i], new OpPower));
break; break;
case ocOdd:
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpOdd));
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"))))
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "compiler.hxx" #include "compiler.hxx"
#include "interpre.hxx" #include "interpre.hxx"
#include "formula/vectortoken.hxx" #include "formula/vectortoken.hxx"
#include "opinlinefun_math.hxx"
#include <sstream> #include <sstream>
using namespace formula; using namespace formula;
...@@ -747,7 +748,46 @@ void OpRound::GenSlidingWindowFunction(std::stringstream &ss, ...@@ -747,7 +748,46 @@ void OpRound::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n"; ss << " return tmp;\n";
ss << "}"; ss << "}";
} }
void OpOdd::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName,
SubArguments &vSubArguments)
{
FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
formula::SingleVectorRefToken *>(tmpCur);
ss << Math_Intg_Str;
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
if (i)
ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ")\n{\n";
ss <<" int gid0=get_global_id(0);\n";
ss << " double tmp=0;\n";
ss << " double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
ss << ";\n";
#ifdef ISNAN
ss<< " if(isNan(arg0)||(gid0>=";
ss<<tmpCurDVR->GetArrayLength();
ss<<"))\n";
ss<<" arg0 = 0;\n";
#endif
ss << " if (arg0 > 0.0 ){\n";
ss << " tmp=Intg(arg0);\n";
ss << " if(tmp-trunc(tmp/2)*2 == 0)\n";
ss << " tmp=tmp+1;\n";
ss << " }else if (arg0 < 0.0 ){\n";
ss << " tmp=Intg(arg0);\n";
ss << " if(tmp-trunc(tmp/2)*2 == 0)\n";
ss << " tmp=tmp-1.0;\n";
ss << " }else if (arg0 == 0.0 )\n";
ss << " tmp=1.0;\n";
ss << " return tmp;\n";
ss << "}";
}
}} }}
......
...@@ -190,6 +190,13 @@ public: ...@@ -190,6 +190,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments); const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Power"; } virtual std::string BinFuncName(void) const { return "Power"; }
}; };
class OpOdd: public Normal
{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Odd"; }
};
}} }}
#endif #endif
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef SC_OPENCL_OPINLINFUN_MATH
#define SC_OPENCL_OPINLINFUN_MATH
std::string Math_Intg_Str=
"\ndouble Intg(double n)\n\
{\n\
if(trunc(n)==n )\n\
return n;\n\
else if(n<0)\n\
return trunc(n)-1;\n\
else\n\
return trunc(n)+1;\n\
}\n";
#endif //SC_OPENCL_OPINLINFUN_MATH
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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