1+2i = 1+2jk redundancy in QuaternionTest

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

1+2i = 1+2jk redundancy in QuaternionTest

HwaJong Oh
Hi,

Reading down QuaternionTest, you can find many of tests simply (1 + 2 i) = (1 + 2 j k) instead of what it really should do.

For example,

testSinh
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) sinh - (1 + 2 j k) sinh) abs < eps


gives no confidence of sinh computes to correct value. It will pass as long as 1+2i is 1+2jk, which has been tested over and over in other tests.

testSin, testLn, testCosh, testCos, testTan, testTanh all the same.

Is there any historical reason these tests are so obssessed to i = i j then what it should do?
If not, i would like to change them.

Best Regards
HwaJong

--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: 1+2i = 1+2jk redundancy in QuaternionTest

Nicolas Cellier
Hi Oh,
(1 + 2 i) class = Complex.
(1 + 2 j k) class = Quaternion.
So the sole purpose of these tests is to check the consistency of implementations found in Complex and in Quaternions.

It might be a bit clearer to rename the tests (like testSinhConsistencyWithComplex).
Or maybe use good variable names in the set-up...
    oneAndTwoIComplex := 1+2 i.

Feel free to improve these and write additional ones for testing other expectations of the function in less trivial cases.
Anyway, thanks for your comments, writing good tests is as essential as writing good code.

Nicolas



2014-12-25 9:12 GMT+01:00 Hwa Jong Oh <[hidden email]>:
Hi,

Reading down QuaternionTest, you can find many of tests simply (1 + 2 i) = (1 + 2 j k) instead of what it really should do.

For example,

testSinh
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) sinh - (1 + 2 j k) sinh) abs < eps


gives no confidence of sinh computes to correct value. It will pass as long as 1+2i is 1+2jk, which has been tested over and over in other tests.

testSin, testLn, testCosh, testCos, testTan, testTanh all the same.

Is there any historical reason these tests are so obssessed to i = i j then what it should do?
If not, i would like to change them.

Best Regards
HwaJong

--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: 1+2i = 1+2jk redundancy in QuaternionTest

HwaJong Oh
Hi, Nicolas.

So, that's why. Now I get it. 

Those tests were trusting computations of Complex and comparing to Quaternion's. 
Except for the almost impossible case of both Complex&Quaternion is answering the same wrong answer like:

Complex >> sinh
    ^0

Quaternion >> sinh
    ^0

, it will rightly assert the method.


It will be clearer to write a test with real values like:

self assert: (1 + 2 j k) sinh equals: (-0.48905625904129363 i: 1.4031192506220405 j: 0.0 k: 0.0)

but, reader of this test won't grasp the feeling of correctness if he does not know how those number came out.

I must think more.

HwaJong Oh

--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.