add ^ (=power) and - (=unary minus) to OpenCLSubsetOpCodes

Both of these are trivial and quite common mathematical operations.
Unary minus is a bit complicated in that unary '-' is the same symbol
as binary '-' and so there needs to be a hack to expand the '-'
from the list to both of the opcodes ocSub and ocNegSub.

Change-Id: I556e20e161c22dc89919afffbf904c1ef1d552ff
Reviewed-on: https://gerrit.libreoffice.org/64362
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
This commit is contained in:
Luboš Luňák
2018-12-03 15:35:15 +01:00
parent ac439c8c83
commit f7e7a59f38
2 changed files with 6 additions and 1 deletions
@@ -1480,7 +1480,7 @@
true, and a formula contains only these operators and
functions, it might be calculated using OpenCL.</desc>
</info>
<value>+;-;*;/;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSDIST;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;VLOOKUP;CORREL;COVAR;PEARSON;SLOPE;SUMIFS</value>
<value>+;-;*;/;^;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSDIST;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;VLOOKUP;CORREL;COVAR;PEARSON;SLOPE;SUMIFS</value>
</prop>
<prop oor:name="OpenCLAutoSelect" oor:type="xs:boolean" oor:nillable="false">
<info>
+5
View File
@@ -111,8 +111,10 @@ void ScCalcConfig::setOpenCLConfigToDefault()
static OpCodeSet pDefaultOpenCLSubsetOpCodes(new std::set<OpCode>({
ocAdd,
ocSub,
ocNegSub,
ocMul,
ocDiv,
ocPow,
ocRandom,
ocSin,
ocCos,
@@ -236,6 +238,9 @@ ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes)
}
fromIndex = semicolon+1;
}
// HACK: Both unary and binary minus have the same string but different opcodes.
if( result->find( ocSub ) != result->end())
result->insert( ocNegSub );
return result;
}