The Mathematica Journal
Departments
Feature Articles
Columns
New Products
New Publications
Classifieds
Calendar
News Bulletins
Mailbox
Letters
Write Us
About the Journal
Staff and Contributors
Submissions
Subscriptions
Advertising
Back Issues
Home
Download this Issue

 

Can Packed Arrays Ever be Slower?

Yes. Here is an example.

[Graphics:../Images/index_gr_26.gif]
[Graphics:../Images/index_gr_27.gif]
[Graphics:../Images/index_gr_28.gif]

If you unpack the data and then use Map, the total time is slightly less.

[Graphics:../Images/index_gr_29.gif]
[Graphics:../Images/index_gr_30.gif]
[Graphics:../Images/index_gr_31.gif]
[Graphics:../Images/index_gr_32.gif]

However, if we inline the function, the auto-compilation can work.

[Graphics:../Images/index_gr_33.gif]
[Graphics:../Images/index_gr_34.gif]

It is not always the case that things are so easily patched up. Some commands are incompatible with packed arrays. However, before complaining too loudly about these (we hope quite rare) cases, please take into account the whole time going into your computation. In the above example, we were not taking into account the time it took to generate the random list. Without auto-compilation and packed arrays, it takes quite a bit longer.

[Graphics:../Images/index_gr_35.gif]
[Graphics:../Images/index_gr_36.gif]

Converted by Mathematica      May 1, 2000

[Article Index] [Prev Page][Next Page]