performance - Issue in nested for loops : How to speed up nested for loops -


I am trying to combine several values ​​which will be used as parameters in an equation. The problem ism, it is very computationally expensive and hanging machine hanged. When there are only 3-4 parameters, it works fine for the loop and I get results within the proper time. Otherwise, it just freezes!
The following is the code, can someone make available in a efficient way to generate a combination of these numbers so that the whole process is fast and I do not wait for days to get results.

Update on ANSWER1 based on answers: (just a simple attempt)

  & gt; & Gt; A1 = 0.1; & Gt; & Gt; B1 = 0.2; & Gt; & Gt; A = a1 + [0: 0.01: 0.04] A = 0.1000 0.1100 0.1200 0.1300 0.1400 & gt; & Gt; B = B1 + [0: 0.01: 0.04] B = 0.2000 0.2100 0.2200 0.2300 0.2400 & gt; & Gt; Aa, BB = ndgird (a, b) Undefined function or variable 'A'  

Some other questions: (1) What is wrong with the way I did it?

(2) 0.04 What does the word mean?

(3) How do I specify the number of elements in each vector of the parameter? In this example, only 5 values ​​are generated. You might want to try to generate a n-dimensional grid for parameter values ​​

e.g. For 2D

  xx, yy = ndgrid ([1,2,3], [0.1, 0.2,0.3])  

Add more vectors Nd.

2D parameters array

If you need a parameter stored in 2d array, you can do this

 < Code> [xx (:), yy (:), ...]  

specific values ​​

In your case,

  a = a1 + [0: 0.01: 0.04] b = b2 + [0: 0.01: 0.04] c = c3- [0: 0.01: 0.04] ... < / Code> 

or alternatively

  a = a1 + linspace (0, 0.04, 5) b = b2 + linspace (0, 0.04, 5) c = C3 - linspace (0, 0.04, 5) ...  

And so on, so that each vector corresponds to those values. That you need to scan. Then use

  [aa, bb, cc, ...] = ndgrid (a, b, c, ...)  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -