simplify tgv command
@@ -80,15 +80,7 @@ int main_tgv(int argc, char* argv[])
auto grad2a = linop_transpose_create(DIMS + 1, DIMS - 1, DIMS + 0, linop_codomain(grad2x)->dims);
auto grad2b = linop_identity_create(DIMS + 1, linop_codomain(grad2x)->dims);
- auto grad2c = linop_plus(grad2a, grad2b);
-
- linop_free(grad2a);
- linop_free(grad2b);
-
- auto grad2 = linop_chain(grad2x, grad2c);
-
- linop_free(grad2x);
- linop_free(grad2c);
+ auto grad2 = linop_chain_FF(grad2x, linop_plus_FF(grad2a, grad2b));
long grd_dims[DIMS];
@@ -103,28 +95,18 @@ int main_tgv(int argc, char* argv[])
long pos1[DIMS] = { [DIMS - 1] = 0 };
auto grad1b = linop_extract_create(DIMS, pos1, in_dims, out_dims);
auto grad1c = linop_reshape_create(DIMS - 1, linop_domain(grad1)->dims, DIMS, in_dims);
+ auto grad1d = linop_chain_FF(linop_chain_FF(grad1b, grad1c), grad1);
- auto grad1d1 = linop_chain(grad1b, grad1c);
- auto grad1d = linop_chain(grad1d1, grad1);
-
- linop_free(grad1);
- linop_free(grad1b);
- linop_free(grad1c);
- linop_free(grad1d1);
long pos1b[DIMS] = { [DIMS - 1] = 1 };
auto grad1e = linop_extract_create(DIMS, pos1b, grd_dims, out_dims);
- const struct linop_s* grad1f = linop_plus(grad1e, grad1d);
+ const struct linop_s* grad1f = linop_plus_FF(grad1e, grad1d);
- linop_free(grad1e);
- linop_free(grad1d);
long pos2[DIMS] = { [DIMS - 1] = 1 };
auto grad2e = linop_extract_create(DIMS, pos2, grd_dims, out_dims);
- const struct linop_s* grad2f = linop_chain(grad2e, grad2);
+ const struct linop_s* grad2f = linop_chain_FF(grad2e, grad2);
- linop_free(grad2);
- linop_free(grad2e);
auto p1 = prox_thresh_create(DIMS + 0, linop_codomain(grad1f)->dims, lambda, 0u);
auto p2 = prox_thresh_create(DIMS + 1, linop_codomain(grad2f)->dims, lambda, 0u);
