Jump to content

Fastest Array Replication


Recommended Posts

I have need to replicate elements in an array.

The "Interleave 1D Arrays" is not feasible due to:

1) too large a number of replicates (>5)

2) variable number of replicates (345, 625, etc.)

I know that a For loop (with a pre-initialized array of size length M x number of replicates N) could work, however I avoid them (for speed) and so came up with the following:

Multiply the input array with an array populated with the number of replicates using the Outer Product then reshape from a 2D array back to a 1D array.

Any other suggestions?

post-12325-126108528704_thumb.png

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.