Ticket #2170: 0001-ticket-2170-fixed-wrong-behaviour-of-complex-numbers.patch
File 0001-ticket-2170-fixed-wrong-behaviour-of-complex-numbers.patch, 7.1 KB (added by , 5 years ago) |
---|
-
bin/errtxts
From fd502092e75afdb34ef48290549dade399539dfc Mon Sep 17 00:00:00 2001 From: Arsenij Percov <a.percov@jacobs-university.de> Date: Wed, 25 Sep 2019 17:31:26 +0200 Subject: [PATCH] ticket:2170 - fixed wrong behaviour of complex numbers Summary: Added support for complex numbers using unsigned shorts or longs. Fixed error messages for non-compatible imaginary and real parts provided in query. Test Plan: Queries from ticket. Reviewers: dmisev Differential Revision: http://codereview.rasdaman.org/D955 --- bin/errtxts | 2 +- qlparser/oql.yy | 16 +++++++++-- qlparser/qtatomicdata.cc | 59 ++++++++++++++++++++++++++++++++++++++++ qlparser/qtatomicdata.hh | 3 ++ raslib/test/errtxts | 2 +- 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/bin/errtxts b/bin/errtxts index 6528c654c..30333e469 100644
a b 72 72 308^E^Parsing error: Unexpected end of query. 73 73 309^E^Parsing error: Unknown error. 74 74 310^E^Lexical analysing error $errorNo in line $lineNo, column $columnNo: Unexpected characters $token. 75 311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type (i.e. float or double).75 311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type. 76 76 312^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Variable already defined. 77 77 313^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Only constant interval bounds allowed. 78 78 314^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Too few arguments in function call. -
qlparser/oql.yy
diff --git a/qlparser/oql.yy b/qlparser/oql.yy index 2f40f602f..9902fc953 100644
a b inductionExp: SQRT LRPAR generalExp RRPAR 3447 3447 } 3448 3448 | COMPLEX LRPAR generalExp COMMA generalExp RRPAR 3449 3449 { 3450 3450 3451 $$ = new QtConstructComplex($3, $5); 3451 3452 $$->setParseInfo(*($1.info)); 3452 3453 parseQueryTree->removeDynamicObject($3); … … atomicLit: BooleanLit 3846 3847 | COMPLEX LRPAR intLitExp COMMA intLitExp RRPAR 3847 3848 { 3848 3849 // this should construct a complex type 3849 // for both float and doublecell type3850 // for both long and short cell type 3850 3851 if($3.bytes+$5.bytes== 2u * sizeof(int) || $3.bytes + $5.bytes == 2u * sizeof(short) || $3.bytes + $5.bytes == 2u * sizeof(long)) { 3851 $$ = new QtAtomicData($3.svalue, $5.svalue, $3.bytes + $5.bytes); 3852 if ($3.negative && !$5.negative){ 3853 $$ = new QtAtomicData($3.svalue, $5.uvalue, $3.bytes + $5.bytes); 3854 } 3855 else if ($3.negative && $5.negative){ 3856 $$ = new QtAtomicData($3.svalue, $5.svalue, $3.bytes + $5.bytes); 3857 } 3858 else if (!$3.negative && $5.negative){ 3859 $$ = new QtAtomicData($3.uvalue, $5.svalue, $3.bytes + $5.bytes); 3860 } 3861 else if (!$3.negative && !$5.negative){ 3862 $$ = new QtAtomicData($3.uvalue, $5.uvalue, $3.bytes + $5.bytes); 3863 } 3852 3864 } else { 3853 3865 if(parseError) delete parseError; 3854 3866 parseError = new ParseInfo(311, $2.info->getToken().c_str(), -
qlparser/qtatomicdata.cc
diff --git a/qlparser/qtatomicdata.cc b/qlparser/qtatomicdata.cc index 681caa2f2..9f170cc67 100755
a b QtAtomicData::QtAtomicData(r_Long valRe, r_Long valIm, unsigned short size) 248 248 valueType->makeFromCLong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm); 249 249 } 250 250 251 252 QtAtomicData::QtAtomicData(r_ULong valRe, r_ULong valIm, unsigned short size) 253 : QtScalarData() 254 { 255 r_ULong dummyRe = valRe; 256 r_ULong dummyIm = valIm; 257 258 if (size == 2 * sizeof(r_ULong)) 259 { 260 valueType = TypeFactory::mapType("CInt32"); 261 } 262 else 263 { 264 valueType = TypeFactory::mapType("CInt16"); 265 } 266 267 valueBuffer = new char[valueType->getSize()]; 268 valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getReOffset(), &dummyRe); 269 valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm); 270 } 271 272 QtAtomicData::QtAtomicData(r_Long valRe, r_ULong valIm, unsigned short size) 273 : QtScalarData() 274 { 275 r_Long dummyRe = valRe; 276 r_ULong dummyIm = valIm; 277 if (size == 2 * sizeof(r_ULong)) 278 { 279 valueType = TypeFactory::mapType("CInt32"); 280 } 281 else 282 { 283 valueType = TypeFactory::mapType("CInt16"); 284 } 285 286 valueBuffer = new char[valueType->getSize()]; 287 valueType->makeFromCLong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getReOffset(), &dummyRe); 288 valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm); 289 } 290 291 QtAtomicData::QtAtomicData(r_ULong valRe, r_Long valIm, unsigned short size) 292 : QtScalarData() 293 { 294 r_ULong dummyRe = valRe; 295 r_Long dummyIm = valIm; 296 297 if (size == 2 * sizeof(r_ULong)) 298 { 299 valueType = TypeFactory::mapType("CInt32"); 300 } 301 else 302 { 303 valueType = TypeFactory::mapType("CInt16"); 304 } 305 306 valueBuffer = new char[valueType->getSize()]; 307 valueType->makeFromCULong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getReOffset(), &dummyRe); 308 valueType->makeFromCLong(valueBuffer + (static_cast<GenericComplexType *>(const_cast<BaseType *>(valueType)))->getImOffset(), &dummyIm); 309 } 310 No newline at end of file -
qlparser/qtatomicdata.hh
diff --git a/qlparser/qtatomicdata.hh b/qlparser/qtatomicdata.hh index 79b09a3bd..076c2411a 100644
a b public: 88 88 /// constructor getting complex data 89 89 QtAtomicData(double valRe, double valIm, unsigned short size); 90 90 QtAtomicData(r_Long valRe, r_Long valIm, unsigned short size); 91 QtAtomicData(r_ULong valRe, r_ULong valIm, unsigned short size); 92 QtAtomicData(r_Long valRe, r_ULong valIm, unsigned short size); 93 QtAtomicData(r_ULong valRe, r_Long valIm, unsigned short size); 91 94 92 95 /// copy constructor 93 96 QtAtomicData(const QtAtomicData &obj); -
raslib/test/errtxts
diff --git a/raslib/test/errtxts b/raslib/test/errtxts index 0004f3024..7faf68c6d 100755
a b 58 58 308^E^Parsing error: Unexpected end of query. 59 59 309^E^Parsing error: Unknown error. 60 60 310^E^Lexical analysing error $errorNo in line $lineNo, column $columnNo: Unexpected characters $token. 61 311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type (i.e. float or double).61 311^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Complex constructor must have both arguments of the same type. 62 62 312^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Variable already defined. 63 63 313^E^Parsing error $errorNo in line $lineNo, column $columnNo, token $token: Only constant interval bounds allowed. 64 64 #