Group Abstract Group Abstract

Message Boards Message Boards

1
|
333 Views
|
4 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Dractic slowdown in the performance of Table

Posted 26 days ago

Let's initialize

a = Table[Random[], {1460}, {361}, {720}];

Then use some elements to form another table

Table[a[[1, i, 1]], {i, 1, 100}]; // AbsoluteTiming

This operation takes very little time

out[] = {0.0004528, Null}

But just a bit large Table (from 1 to 361)

Table[a[[1, i, 1]], {i, 1, 361}]; // AbsoluteTiming

takes crazy long

out[]= {67.1042, Null}

What is a problem?

P.S. Mathematica ver. 13.3. RAM is sufficient.

POSTED BY: Rodion Stepanov
4 Replies

The time is spent attempting to compile (I believe eventually with success) the last Table command because it has exceeded the default auto-compile length of 250. This involves, among other things, a full iteration over the table (I do not know all the details here).

Table can be dissuaded from doing this as below.

SetSystemOptions["CompileOptions"->"TableCompileLength"->Infinity];
a = Table[Random[], {1460}, {361}, {720}];

In[3]:= Table[a[[1, i, 1]], {i, 1, 100}]; // AbsoluteTiming

(* Out[3]= {0.000062, Null} *)

In[4]:= Table[a[[1, i, 1]], {i, 1, 361}]; // AbsoluteTiming

(* Out[4]= {0.000177, Null} *)

I will file a suggestion report that this handling be reconsidered with an eye toward optimizing it for better speed.

POSTED BY: Daniel Lichtblau

Great, it works! Thanks

POSTED BY: Rodion Stepanov

I don't know why the longer time, but this seems to be a workaround:

a[[1, 1 ;; 100, 1]]; // Timing
a[[1, All, 1]]; // Timing
POSTED BY: Gianluca Gorni

sure, there are many alternative ways to take elements but I need this Table because in fact the processing is much more complex (I don't show all operations over a[[1, i, 1]]).

POSTED BY: Rodion Stepanov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard