9
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Use Inner
Inner[Power, var, #, Times] & /@ expo
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
8
votes
Accepted
Faster simulation of two spins
Everything, up to your last expression can be solved analytically.
...
7
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
This feels like I was just following the directions in the OP:
Times @@ (var^#) & /@ expo
4
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Here is another Inner strategy:
Inner[OperatorApplied[Power], expo, var, Times]
4
votes
Nested For runs really slow
The For loop is not the whole problem here: even
AbsoluteTiming[Do[i = 1, M, M, M]]
(* {4.50839, Null} *)
takes very long....
3
votes
How to optimize performance with DeleteDuplicates?
I build upon A. Kato's idea to use a normalization: First turn each element into a unique representative of the equivalence class. Then run vanilla DeleteDuplicates....
3
votes
How to optimize performance with DeleteDuplicates?
This answer is for the case where the order does matter. While OP's question asks for case where the order does not matter at any level.
First of all rules can be ...
3
votes
How to speed up estimation of mean and Gaussian curvatures on triangular meshes?
This is longer than a comment hence the new answer (it also took a few years to get around to testing everything... ). The answer by @user68078 shows how to implement a much faster version of the MDSB ...
3
votes
Accepted
Problem with illustrating pathways
The code is a bit heavy and slow as you are not taking advantage of a few built-in functions or functional programming patterns. I applied a functional programming approach which reduces the code and ...
2
votes
Accepted
Help defining all pathways of a sample from the same start-point
Recursive function call will help you.
(I understand that $x_0, x_1,..., x_7$ are all distinct, and a permutation of all the points in $S$.)
...
2
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
expo . Log@var // Exp
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
1
vote
Speeding up NMaximize for an optimisation problem in thousands of variables
I have played with smaller numbers, decreasing accuracy, and obtained the following.
...
1
vote
Accepted
Faster evaluation of matrix operation
Essentially, your code is a double loop: the outer loop goes over n (with a trip count of 750) and the inner loop goes over the list ...
1
vote
Problem with illustrating pathways
Function paths[s] finds all possible paths for set of points s.
Function hg[path] highlights ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
performance-tuning × 3010list-manipulation × 553
matrix × 238
compile × 204
parallelization × 170
numerical-integration × 168
plotting × 153
mathematical-optimization × 142
differential-equations × 131
equation-solving × 131
programming × 111
numerics × 110
linear-algebra × 108
functions × 102
memory × 94
graphs-and-networks × 88
code-review × 78
sparse-arrays × 74
calculus-and-analysis × 73
function-construction × 73
image-processing × 67
probability-or-statistics × 63
graphics × 58
random × 56
combinatorics × 50