Skip to content

Commit 7397ac6

Browse files
committed
chore: update nx for improved constant precision
1 parent 331cc66 commit 7397ac6

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

lib/nx_signal/internal.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ defmodule NxSignal.Internal do
2525

2626
cond do
2727
Nx.is_infinity(rz) and rz > 0 ->
28-
z + 2.0 * Nx.Constants.pi(:f64) * k * Nx.Constants.i()
28+
z + 2.0 * Nx.Constants.pi() * k * Nx.Constants.i()
2929

3030
Nx.is_infinity(rz) and rz < 0 ->
31-
-z + 2.0 * Nx.Constants.pi(:f64) * k * Nx.Constants.i()
31+
-z + 2.0 * Nx.Constants.pi() * k * Nx.Constants.i()
3232

3333
z == 0 and k == 0 ->
3434
z
@@ -111,7 +111,7 @@ defmodule NxSignal.Internal do
111111

112112
defnp lambertw_branchpt(z) do
113113
m_e =
114-
Nx.Constants.e(:f64)
114+
Nx.Constants.e()
115115

116116
p = Nx.sqrt(2.0 * (m_e * z + 1.0))
117117

@@ -125,7 +125,7 @@ defmodule NxSignal.Internal do
125125

126126
defnp lambertw_asy(z, k) do
127127
w =
128-
Nx.log(z) + 2.0 * Nx.Constants.pi(:f64) * k * Nx.Constants.i()
128+
Nx.log(z) + 2.0 * Nx.Constants.pi() * k * Nx.Constants.i()
129129

130130
w - Nx.log(w)
131131
end

lib/nx_signal/waveforms.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,35 +126,35 @@ defmodule NxSignal.Waveforms do
126126
iex> pulse.envelope
127127
#Nx.Tensor<
128128
f32[4]
129-
[1.0, 0.20443114638328552, 0.001746579073369503, 6.236254534996988e-7]
129+
[1.0, 0.2044311761856079, 0.0017465798882767558, 6.236266472114949e-7]
130130
>
131131
iex> pulse.in_phase
132132
#Nx.Tensor<
133133
f32[4]
134-
[1.0, -0.10221561044454575, -8.732887799851596e-4, 6.236254534996988e-7]
134+
[1.0, -0.10221562534570694, -8.73289187438786e-4, 6.236266472114949e-7]
135135
>
136136
iex> pulse.quadrature
137137
#Nx.Tensor<
138138
f32[4]
139-
[0.0, 0.17704254388809204, -0.0015125821810215712, 4.361525517918713e-13]
139+
[0.0, 0.17704255878925323, -0.001512582995928824, 4.3615339204855497e-13]
140140
>
141141
142142
iex> t = Nx.linspace(0, 1, n: 4)
143143
iex> pulse = NxSignal.Waveforms.gaussian_pulse(t, center_frequency: 4, bandwidth: 0.25)
144144
iex> pulse.envelope
145145
#Nx.Tensor<
146146
f32[4]
147-
[1.0, 0.6724140048027039, 0.20443114638328552, 0.028101593255996704]
147+
[1.0, 0.6724140644073486, 0.2044311761856079, 0.028101608157157898]
148148
>
149149
iex> pulse.in_phase
150150
#Nx.Tensor<
151151
f32[4]
152-
[1.0, -0.3362071216106415, -0.1022154912352562, 0.028101593255996704]
152+
[1.0, -0.33620715141296387, -0.10221550613641739, 0.028101608157157898]
153153
>
154154
iex> pulse.quadrature
155155
#Nx.Tensor<
156156
f32[4]
157-
[0.0, 0.5823275446891785, -0.177042618393898, 1.9653754179671523e-8]
157+
[0.0, 0.5823275446891785, -0.1770426332950592, 1.965376483781256e-8]
158158
>
159159
"""
160160
@doc type: :waveforms

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
88
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
99
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
10-
"nx": {:git, "https://github.com/elixir-nx/nx.git", "58267796d2ba9fc93345e3a4fc5ebfe8416b680c", [sparse: "nx"]},
10+
"nx": {:git, "https://github.com/elixir-nx/nx.git", "c6fc98df9ff36b27727c800524b36e92f56dd7ba", [sparse: "nx"]},
1111
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
1212
"xla": {:hex, :xla, "0.4.3", "cf6201aaa44d990298996156a83a16b9a87c5fbb257758dbf4c3e83c5e1c4b96", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "caae164b56dcaec6fbcabcd7dea14303afde07623b0cfa4a3cd2576b923105f5"},
1313
}

test/nx_signal/waveforms_test.exs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ defmodule NxSignal.WaveformsTest do
3838
-0.497405469417572,
3939
0.005189061164855957,
4040
0.5077835321426392,
41-
0.9974055886268616,
42-
0.871756911277771,
43-
0.7461082935333252,
44-
0.6204596757888794,
45-
0.4948110580444336,
46-
0.3691624104976654,
47-
0.2435137927532196,
48-
0.11786515265703201,
49-
-0.007783474866300821,
50-
-0.13343201577663422,
51-
-0.2590807378292084,
52-
-0.3847294747829437,
53-
-0.5103780031204224,
54-
-0.6360265612602234,
55-
-0.761675238609314,
56-
-0.8873239755630493
41+
0.997405469417572,
42+
0.8717568516731262,
43+
0.7461082339286804,
44+
0.6204595565795898,
45+
0.49481093883514404,
46+
0.36916232109069824,
47+
0.24351368844509125,
48+
0.11786506325006485,
49+
-0.007783569395542145,
50+
-0.13343210518360138,
51+
-0.25908082723617554,
52+
-0.3847295641899109,
53+
-0.5103781223297119,
54+
-0.6360266208648682,
55+
-0.7616753578186035,
56+
-0.8873240947723389
5757
])
5858

5959
assert NxSignal.Waveforms.sawtooth(t, width: 0) ==

0 commit comments

Comments
 (0)