threshold method
Implementation
double threshold(double x, double t) {
double thresh = t.toDouble();
double xNew = 0;
double x1 = 0;
if (x.abs() < thresh.abs()) {
xNew = 0;
} else {
x1 = x.abs() - thresh;
x1 = (x1 + x1.abs()) / 2;
if (x < 0) {
xNew = -1 * x1;
} else {
xNew = x1;
}
}
return xNew;
}