@@ -16,11 +16,12 @@ bpdn_data(compound::Int = 1, args...) =
1616 bpdn_data (200 * compound, 512 * compound, 10 * compound, args... )
1717
1818"""
19- model, sol = bpdn_model(args...)
20- model, sol = bpdn_model(compound = 1, args...)
19+ model, nls_model, sol = bpdn_model(args...)
20+ model, nls_model, sol = bpdn_model(compound = 1, args...)
2121
22- Return an instance of an `NLPModel` representing the basis-pursuit denoise
23- problem, i.e., the under-determined linear least-squares objective
22+ Return an instance of an `NLPModel` and an instance of an `NLSModel` representing
23+ the same basis-pursuit denoise problem, i.e., the under-determined linear
24+ least-squares objective
2425
2526 ½ ‖Ax - b‖₂²,
2627
@@ -32,7 +33,7 @@ vector following a normal distribution with mean zero and standard deviation σ.
3233* `m :: Int`: the number of rows of A
3334* `n :: Int`: the number of columns of A (with `n` ≥ `m`)
3435* `k :: Int`: the number of nonzero elements in x̄
35- * `noise :: Float64`: noise amount ϵ (default: 0.01).
36+ * `noise :: Float64`: noise standard deviation σ (default: 0.01).
3637
3738The second form calls the first form with arguments
3839
@@ -42,8 +43,8 @@ The second form calls the first form with arguments
4243
4344## Return Value
4445
45- An instance of a `FirstOrderModel` that represents the basis-pursuit denoise problem
46- and the exact solution x̄.
46+ An instance of a `FirstOrderModel` and of a `FirstOrderNLSModel` that represent the same
47+ basis-pursuit denoise problem, and the exact solution x̄.
4748"""
4849function bpdn_model (args... )
4950 A, b, b0, x0 = bpdn_data (args... )
@@ -55,6 +56,9 @@ function bpdn_model(args...)
5556 r
5657 end
5758
59+ jprod_resid! (Jv, x, v) = mul! (Jv, A, v)
60+ jtprod_resid! (Jtv, x, v) = mul! (Jtv, A' , v)
61+
5862 function obj (x)
5963 resid! (r, x)
6064 dot (r, r) / 2
@@ -66,32 +70,6 @@ function bpdn_model(args...)
6670 g
6771 end
6872
69- FirstOrderModel (obj, grad!, zero (x0), name = " BPDN" ), x0
73+ FirstOrderModel (obj, grad!, zero (x0), name = " BPDN" ), FirstOrderNLSModel (resid!, jprod_resid!, jtprod_resid!, size (A, 1 ), zero (x0), name = " BPDN-LS " ), x0
7074end
7175
72- """
73- model, sol = bpdn_nls_model(args...)
74- model, sol = bpdn_nls_model(compound = 1, args...)
75-
76- Return an instance of a `FirstOrderNLSModel` that represents the basis-pursuit
77- denoise problem explicitly as a least-squares problem and the exact solution x̄.
78-
79- See the documentation of `bpdn_model()` for more information and a
80- description of the arguments.
81- """
82- function bpdn_nls_model (args... )
83- A, b, b0, x0 = bpdn_data (args... )
84- r = similar (b)
85-
86- function resid! (r, x)
87- mul! (r, A, x)
88- r .- = b
89- r
90- end
91-
92- jprod_resid! (Jv, x, v) = mul! (Jv, A, v)
93- jtprod_resid! (Jtv, x, v) = mul! (Jtv, A' , v)
94-
95- FirstOrderNLSModel (resid!, jprod_resid!, jtprod_resid!, size (A, 1 ), zero (x0), name = " BPDN-LS" ),
96- x0
97- end
0 commit comments