Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0e41f1b

Browse files
committed
optimization and simplification
1 parent 020d527 commit 0e41f1b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

‎dbrprop.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22

33
class DBRprop:
44
def __init__(self):
5-
self.nbr = np.random.randint(15,5000)
5+
self.nbr = np.random.randint(15,5000)
66
self.n = np.random.rand(2)*5 + 0.00000001
7-
self.d = np.random.rand(2)*10000+ 3
7+
self.d = np.random.rand(2)*10000+ 3
88
# creation of array of data representing the mirror
9-
self.data = np.array([[self.n[0], 0]])
10-
self.data = np.vstack((self.data, [self.n[1], self.d[1]]))
11-
for k in range(self.nbr - 4):
12-
self.data = np.vstack((self.data, [self.n[0], self.d[0]]))
13-
self.data = np.vstack((self.data, [self.n[1], self.d[1]]))
14-
self.data = np.vstack((self.data, [self.n[0], self.d[0]]))
15-
self.data = np.vstack((self.data, [self.n[1],0]))
9+
self.data = np.tile(np.array([[self.n[0], self.d[0]], [self.n[1], self.d[1]]]), (self.nbr, 1))
10+
self.data[0, 1] = 0
11+
self.data[-1, 1] = 0
1612

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /