[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [analitza/imaginary] analitza: Fix modulus for complex number
From: Percy_Camilo_Triveño_Aucahuasi <percy.camilo.ta () gmail ! com>
Date: 2014-06-15 7:15:44
Message-ID: E1Ww4fI-00084b-O9 () scm ! kde ! org
[Download RAW message or body]
Git commit 42e60bd40101fbe18546d983abfcc1528c3dd310 by Percy Camilo Triveño Aucahuasi.
Committed on 15/06/2014 at 07:15.
Pushed by aucahuasi into branch 'imaginary'.
Fix modulus for complex number
M +1 -1 analitza/operations.cpp
M +2 -0 analitza/tests/analitzatest.cpp
http://commits.kde.org/analitza/42e60bd40101fbe18546d983abfcc1528c3dd310
diff --git a/analitza/operations.cpp b/analitza/operations.cpp
index 158e786..3ba3b2c 100644
--- a/analitza/operations.cpp
+++ b/analitza/operations.cpp
@@ -329,7 +329,7 @@ Cn* Operations::reduceUnaryComplex(Operator::OperatorType op, Cn* val, QString**
val->setValue(log10(a));
break;
case Operator::abs:
- val->setValue(a>=0. ? a : -a);
+ val->setValue(std::abs(a));
break;
case Operator::conjugate:
val->setValue(std::conj(a));
diff --git a/analitza/tests/analitzatest.cpp b/analitza/tests/analitzatest.cpp
index 7e32178..ffd6f60 100644
--- a/analitza/tests/analitzatest.cpp
+++ b/analitza/tests/analitzatest.cpp
@@ -160,6 +160,8 @@ void AnalitzaTest::testTrivialEvaluate_data()
QTest::newRow("complex arg") << "arg(i)" << "1.57079632679";
QTest::newRow("complex real part") << "real(45-9*i)" << "45";
QTest::newRow("complex imag part") << "imaginary(45-9*i)" << "-9";
+ QTest::newRow("simply complex mod") << "abs(i)" << "1";
+ QTest::newRow("complex mod") << "abs(8-9*i)" << "12.0415945788";
QTest::newRow("simple addition") << "2+2" << "4";
QTest::newRow("simple addition with var") << "2+x" << "x+2";
QTest::newRow("minus irreductibility") << "-x" << "-x";
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic