diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-08-25 18:25:47 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-08-25 18:26:31 +0300 |
commit | 32b35d9d8a21091b987d94fc2ad24d69e9d8a6f3 (patch) | |
tree | 3510ea4c73cb2ccb8504c277d0eae1381fe565ac | |
parent | 567471e0b6b3d4fd5d4ed51445d091c0763fb845 (diff) |
Return correct value from the OpenCL VLOOKUP implementation
The commit c3383aafa18ef9d03b04b2a4719e71fdfabc14eb was missing an !
operator in two places where it checks whether a cell is a numeric or
string one, resulting in it always using the string value, which for
NULL (the case I was looking at, only numeric cells in the array)
meant zero was returned.
As such I am not sure if it is entirely correct to do the check
whether a cell is a numeric or string value in the order the generated
OpenCL code does here (and all over the place perhaps). The
documentation in <formula/vectortoken.hxx> says:
* Single unit of vector reference consists of two physical arrays.
*
* If the whole data array consists of only numeric values, mpStringArray
* will be NULL, and NaN values in the numeric array represent empty
* cells.
*
* If the whole data array consists of only string values, mpNumericArray
* will be NULL, and NULL values in the string array represent empty
* cells.
*
* If the data array consists of numeric and string values, then both
* mpNumericArray and mpStringArray will be non-NULL, and a string cell will
* be represented by a non-NULL pointer value in the string array. If the
* string value is NULL, check the corresponding value in the numeric array.
* If the value in the numeric array is NaN, it's an empty cell, otherwise
* it's a numeric cell.
Note how that implies one should first check whether the value in the
string array is NULL or not, and only if it is NULL, look at the vale
in the numeric array. The code in the generated OpenCL VLOOKUP
implementation does it backwards. Scary. But probably equivalent for
the subset of cases we actually handle in OpenCL, which (I think) are
those where no string cells are involved.
More bug fixes for the OpenCL VLOOKUP will follow.
Change-Id: Id567c245a0700267584be6032320863a4a66df83
-rw-r--r-- | sc/source/core/opencl/op_spreadsheet.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx index c005d2a89c72..6ade850dac4f 100644 --- a/sc/source/core/opencl/op_spreadsheet.cxx +++ b/sc/source/core/opencl/op_spreadsheet.cxx @@ -174,7 +174,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss, else { ss << " {\n"; - ss << " tmp = isNan("; + ss << " tmp = !isNan("; vSubArguments[1+j]->GenNumDeclRef(ss); ss << "[rowNum])?"; vSubArguments[1+j]->GenNumDeclRef(ss); @@ -259,7 +259,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss, } else { - ss << " tmp = isNan("; + ss << " tmp = !isNan("; vSubArguments[1+j]->GenNumDeclRef(ss); ss << "[rowNum])?"; vSubArguments[1+j]->GenNumDeclRef(ss); |