Linked Questions

0 votes
0 answers
70 views

Packed/Unpacked array - what object/like 0 or 1?/how to check/ [duplicate]

In Mathematica, there is a concept called packed array. ...
imida k's user avatar
  • 4,315
603 votes
19 answers
157k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
79 votes
8 answers
7k views

Partitioning with varying partition size

How can I partition a list into partitions whose sizes vary? The length of the $k$'th partition is a function $f(k)$. For example: if $l = \{1, 2, 3, 4, 5, 6\}$ and $f(k) = k$. Then the partitioning ...
sjdh's user avatar
  • 7,777
20 votes
17 answers
11k views

Generating a list of numbers that are not multiples of 4

I want to write simple code that will list all numbers from $1$ to $n$ that are not multiples of $4$. And in this case I consider that ...
Narine's user avatar
  • 433
52 votes
6 answers
11k views

How to implement the general array broadcasting method from NumPy?

A friend of mine introduced array broadcasting in the Python NumPy package which is very convenient (and also highly efficient). The idea is perfectly shown in this ...
matheorem's user avatar
  • 17.2k
29 votes
8 answers
2k views

Speed up Do loops in MMA 13.0

How to speed up Do loop in MMA 13. We consider the following Benchmark test (4 kernels, i7, win10): In MMA 13: ...
ABCDEMMM's user avatar
  • 1,856
36 votes
6 answers
7k views

Finding all elements within a certain range in a sorted list

Suppose we have a sorted list of values. Let's use list = Sort@RandomReal[1, 1000000]; for this example. I need a fast function ...
Szabolcs's user avatar
  • 236k
56 votes
3 answers
2k views

Are there guidelines for avoiding the unpacking of a packed array?

Packed arrays are very useful because they save memory and generally allow speedier and more efficient calculation times. If a list of data currently stored as a packed array is unpacked, it can slow ...
Verbeia's user avatar
  • 34.3k
15 votes
6 answers
1k views

Efficient conditional Mean[] on a large data set

Consider a list, AK6, that has 382 sublists of length varying from 2500 to 3000. Each "subsublist" is as such : ...
500's user avatar
  • 5,599
15 votes
8 answers
912 views

Iterate over # without needing to define a variable

I want a function that takes in a number $n_0$ and a list $\{n_1, n_2, n_3, n_4, n_5\}$ and returns $\{\{n_0,n_1\},\{n_0,n_2\}, \{n_0,n_3\},... \}$. The reason I want this is to use it in Map, so I ...
Lucas Mumbo's user avatar
58 votes
1 answer
5k views

Why won't Parallelize speed up my code?

What reasons are there that can cause parallelized Mathematica code not to run with full performance?
Szabolcs's user avatar
  • 236k
35 votes
3 answers
3k views

Why is Plus so much slower than Total?

Why is Plus so much slower than Total for summing lists? ...
Alecto Irene Perez's user avatar
25 votes
5 answers
7k views

How to zero (or replace) the diagonal of a square matrix?

Zeroing the diagonal of a square matrix is an operation I need frequently, but somehow I still haven't managed to find an elegant solution that satisfies all these requirements: works with both ...
Szabolcs's user avatar
  • 236k
14 votes
3 answers
4k views

Dramatic speed difference of code on MATLAB and Mathematica

Background: I was trying to convert a MATLAB code (fluid simulation, SPH method) into a Mathematica one, but the speed difference is huge. MATLAB code: ...
zjx1805's user avatar
  • 326
10 votes
5 answers
2k views

How can I define a very large matrix efficiently?

Here's a 7x7 matrix: ...
Allure's user avatar
  • 625

15 30 50 per page
1
2 3 4 5
9