utilities: using error-handling interface
/*
- * Copyright (c) 2007 - 2015 Joseph Gaeddert
+ * Copyright (c) 2007 - 2020 Joseph Gaeddert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,8 +36,8 @@ float liquid_rosenbrock(void * _userdata,
unsigned int _n)
{
if (_n == 0) {
- fprintf(stderr,"error: liquid_rosenbrock(), input vector length cannot be zero\n");
- exit(1);
+ liquid_error(LIQUID_EICONFIG,"liquid_rosenbrock(), input vector length cannot be zero");
+ return 0.0f;
} else if (_n == 1) {
return (1.0f-_v[0])*(1.0f-_v[0]);
}
@@ -59,8 +59,8 @@ float liquid_invgauss(void * _userdata,
unsigned int _n)
{
if (_n == 0) {
- fprintf(stderr,"error: liquid_invgauss(), input vector length cannot be zero\n");
- exit(1);
+ liquid_error(LIQUID_EICONFIG,"liquid_invgauss(), input vector length cannot be zero");
+ return 0.0f;
}
float t = 0.0f;
@@ -85,8 +85,8 @@ float liquid_multimodal(void * _userdata,
unsigned int _n)
{
if (_n == 0) {
- fprintf(stderr,"error: liquid_multimodal(), input vector length cannot be zero\n");
- exit(1);
+ liquid_error(LIQUID_EICONFIG,"liquid_multimodal(), input vector length cannot be zero");
+ return 0.0f;
}
float t0 = 1.0f;
@@ -112,8 +112,8 @@ float liquid_spiral(void * _userdata,
unsigned int _n)
{
if (_n == 0) {
- fprintf(stderr,"error: liquid_rosenbrock(), input vector length cannot be zero\n");
- exit(1);
+ liquid_error(LIQUID_EICONFIG,"liquid_rosenbrock(), input vector length cannot be zero");
+ return 0.0f;
} else if (_n == 1) {
return _v[0]*_v[0];
}
