"PMVector sum" is extremely slow, and two more issues

11 views
Skip to first unread message

Atharva Khare

unread,
May 26, 2019, 8:29:24 AM5/26/19
to PolyMath

Hey everyone,


I found three issues in the library, they are written below sorted by their severity. Please go through them and suggest better fixes, if any.


1. "PMVector sum" - Here is the comparison with array:


a := ((1 to: 5000) collect: [ :i | i ]) asPMVector.
a sum. "Best of 10 runs: 568ms"

b := ((1 to: 25000000) collect: [ :i | i ]).
b sum. "Worst of 10 runs: 551ms"


This means that PMVector sum is at least 5,000 times slower than Collection sum.

Possible fix: Don't override sum method. Is there any specific reason to override?


2. PMVector > < operators modify in-place:

x := #(1 2.5 3 4) asPMVector.
x > 2.
x. "==> a PMVector(false true true true)"

I have created a PR for it, here: https://github.com/PolyMathOrg/PolyMath/pull/123
Should additional operators like >= and <= be added in similar fashion as well?

3. PMStandardScaler fails when scale = 0 - happens when all elements in a column are equal. Possible fix: add a "handleZeroScale" method which changes scale to 1 when it is 0.
Question: Should this method be added in PMDataTransformer? If we add more scalers in future, all would need this message.

Atharva Khare

unread,
May 26, 2019, 10:40:12 AM5/26/19
to PolyMath
Forgot to link the issues:

Serge Stinckwich

unread,
May 26, 2019, 12:41:35 PM5/26/19
to polymath...@googlegroups.com

On Sun, May 26, 2019 at 1:29 PM Atharva Khare <kharea...@gmail.com> wrote:

Hey everyone,


Dear Atharva,

 

I found three issues in the library, they are written below sorted by their severity. Please go through them and suggest better fixes, if any.


1. "PMVector sum" - Here is the comparison with array:


a := ((1 to: 5000) collect: [ :i | i ]) asPMVector.
a sum. "Best of 10 runs: 568ms"

b := ((1 to: 25000000) collect: [ :i | i ]).
b sum. "Worst of 10 runs: 551ms"


This means that PMVector sum is at least 5,000 times slower than Collection sum.

Possible fix: Don't override sum method. Is there any specific reason to override?




I try to remove PMVector>>sum and it runs much faster.
All the tests are green. I agree to remove this method.

Thank you for your commitment to PolyMath.

--
Serge Stinckwic
h

Int. Research Unit
 on Modelling/Simulation of Complex Systems (UMMISCO)
Sorbonne University
 (SU)
French National Research Institute for Sustainable Development (IRD)
U
niversity of Yaoundé I, Cameroon
"Programs must be written for people to read, and only incidentally for machines to execute."
https://twitter.com/SergeStinckwich
Reply all
Reply to author
Forward
0 new messages