![]() |
|
apop_linear_constraint finds a point that meets a set of linear constraints. This takes a lot of machinery, so it gets its own file.
Copyright (c) 2007, 2009 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2.
| double apop_linear_constraint | ( | gsl_vector * | beta, | |
| apop_data * | constraint, | |||
| double | margin | |||
| ) |
This is designed to be called from within your own constraint function. Just write the constraint vector+matrix and this will do the rest.
| beta | The proposed vector about to be tested. (No default, must not be NULL) | |
| constraint | The constraints. See apop_f_test on writing (Default: each elements is greater than zero) contrasts. To give a quick example, say your constraint is $3 < 2x + 4y - 7z$; then the first row of your data->vector element would be 3, and the first row of the data->matrix element would be [2 4 -7]. | |
| margin | If zero, then this is a >= constraint, otherwise I will return a point this amount within the borders. You could try GSL_DBL_EPSILON, which is the smallest value a double can hold, or something like 1e-3. (Default = 0.) |
beta is shifted by margin (Euclidian distance) to meet the constraints.This function uses the Designated initializers syntax for inputs.