/* -*- 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/. */ #include "op_logical.hxx" #include "formulagroup.hxx" #include "document.hxx" #include "formulacell.hxx" #include "tokenarray.hxx" #include "compiler.hxx" #include "interpre.hxx" #include "formula/vectortoken.hxx" #include using namespace formula; namespace sc { namespace opencl { void OpAnd::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 << " double t = 1,tmp=0;\n"; for(unsigned int j = 0; j< vSubArguments.size(); j++) { ss << " double tmp"<GetFormulaToken(); if(tmpCur0->GetType() == formula::svSingleVectorRef) { #ifdef ISNAN const formula::SingleVectorRefToken*pCurDVR= dynamic_cast(tmpCur0); ss<< " int buffer_len"<GetArrayLength(); ss<< ";\n"; ss <<" if(gid0 >= buffer_len"<GenSlidingWindowDeclRef(); ss <<"))\n"; ss <<" tmp = 1;\n else\n"; #endif ss <<" tmp = "; ss <GenSlidingWindowDeclRef()<<";\n"; ss <<" tmp"<GetType() == formula::svDouble) { ss <<" tmp = "; ss <GenSlidingWindowDeclRef()<<";\n"; ss <<" tmp"<GetType() == formula::svDoubleVectorRef) { const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast(tmpCur0); size_t nCurWindowSize = pCurDVR->GetArrayLength() < pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength(): pCurDVR->GetRefRowSize() ; ss << " for(int i = "; if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) { ss << "gid0; i < " << nCurWindowSize << "; i++) {\n"; } else if(pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()){ ss << "0; i < gid0 + " << nCurWindowSize << "; i++) {\n"; } else{ ss << "0; i < " << nCurWindowSize << "; i++) {\n"; } #ifdef ISNAN if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) { ss <<" if(isNan("<GenSlidingWindowDeclRef(); ss <<")||i+gid0>="<GetArrayLength(); ss <<")\n"; ss <<" tmp = 1;\n else\n"; } else { ss <<" if(isNan("<GenSlidingWindowDeclRef(); ss <<")||i>="<GetArrayLength(); ss <<")\n"; ss <<" tmp = 1;\n else\n"; } #endif ss <<" tmp = "; ss <GenSlidingWindowDeclRef()<<";\n"; ss <<" tmp"<