Skip to content

Commit 6f8d224

Browse files
softmin function is included
1 parent 02c4cb1 commit 6f8d224

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

xlumina/toolbox.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- space
1414
- wrap_phase
1515
- is_conserving_energy
16+
- softmin
1617
- delta_kronecker
1718
- build_LCD_cell
1819
- draw_sSLM
@@ -78,6 +79,14 @@ def is_conserving_energy(light_source, propagated_light):
7879

7980
return I_propagated / I_source
8081

82+
@jit
83+
def softmin(args, beta=90):
84+
"""
85+
Differentiable version for min() function.
86+
"""
87+
return - nn.logsumexp(-beta * args) / beta
88+
89+
8190
def delta_kronecker(a, b):
8291
"""
8392
Computes the Kronecker delta.

0 commit comments

Comments
 (0)