Skip to main content
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]} *)
A. Kato's user avatar
  • 2,570
8 votes
Accepted

Faster simulation of two spins

Everything, up to your last expression can be solved analytically. ...
Julien Kluge's user avatar
  • 5,470
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
Michael E2's user avatar
  • 241k
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]
lericr's user avatar
  • 31.7k
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....
Roman's user avatar
  • 49.3k
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....
Henrik Schumacher's user avatar
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 ...
azerbajdzan's user avatar
  • 20.9k
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 ...
Dunlop's user avatar
  • 4,123
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 ...
Edmund's user avatar
  • 43.1k
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$.) ...
A. Kato's user avatar
  • 2,570
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]} *)
Karl's user avatar
  • 958
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. ...
user64494's user avatar
  • 27.7k
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 ...
Henrik Schumacher's user avatar
1 vote

Problem with illustrating pathways

Function paths[s] finds all possible paths for set of points s. Function hg[path] highlights ...
azerbajdzan's user avatar
  • 20.9k

Only top scored, non community-wiki answers of a minimum length are eligible