Allow NULL for nlop derivative (fallback to "not implemented")
@@ -139,6 +139,26 @@ static void lop_del(const linop_data_t* _data)
xfree(data);
}
+static void der_not_implemented(const nlop_data_t* _data, unsigned int o, unsigned int i, complex float* dst, const complex float* src)
+{
+ UNUSED(o);
+ UNUSED(i);
+ UNUSED(dst);
+ UNUSED(src);
+
+ error("Derivative o=%d, i=%d of %s is not implemented!\n", o, i, _data->TYPEID->name);
+}
+
+static void adj_not_implemented(const nlop_data_t* _data, unsigned int o, unsigned int i, complex float* dst, const complex float* src)
+{
+ UNUSED(o);
+ UNUSED(i);
+ UNUSED(dst);
+ UNUSED(src);
+
+ error("Adjoint derivative o=%d, i=%d of %s is not implemented!\n", o, i, _data->TYPEID->name);
+}
+
struct nlop_s* nlop_generic_create2( int OO, int ON, const long odims[OO][ON], const long ostr[OO][ON], int II, int IN, const long idims[II][IN], const long istr[II][IN],
nlop_data_t* data, nlop_gen_fun_t forward, nlop_der_fun_t deriv[II][OO], nlop_der_fun_t adjoint[II][OO], nlop_der_fun_t normal[II][OO], nlop_p_fun_t norm_inv[II][OO],
@@ -186,8 +206,8 @@ struct nlop_s* nlop_generic_create2( int OO, int ON, const long odims[OO][ON], c
d2->data = data;
d2->del = del;
- d2->deriv = deriv[i][o];
- d2->adjoint = adjoint[i][o];
+ d2->deriv = (NULL != deriv) ? ((NULL != deriv[i][o]) ? deriv[i][o] : der_not_implemented) : der_not_implemented;
+ d2->adjoint = (NULL != adjoint) ? ((NULL != adjoint[i][o]) ? adjoint[i][o] : adj_not_implemented) : adj_not_implemented;
d2->normal = (NULL != normal) ? normal[i][o] : NULL;
d2->norm_inv = (NULL != norm_inv) ? norm_inv[i][o] : NULL;
