diff --git a/packages/yap-lbfgs/Makefile.in b/packages/yap-lbfgs/Makefile.in index 5cd843339..ec7f601ad 100644 --- a/packages/yap-lbfgs/Makefile.in +++ b/packages/yap-lbfgs/Makefile.in @@ -1,4 +1,4 @@ -# + # # default base directory for YAP installation # (EROOT for architecture-dependent files) # @@ -20,7 +20,7 @@ YAPLIBDIR=@libdir@/Yap # # CC=@CC@ -CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/liblbfgs-1.7/include +CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/liblbfgs-1.10/include LDFLAGS=@LDFLAGS@ # # @@ -49,8 +49,8 @@ all: $(SOBJS) yap_lbfgs.o: $(srcdir)/yap_lbfgs.c $(CC) -c $(CFLAGS) $(srcdir)/yap_lbfgs.c -o yap_lbfgs.o -lbfgs.o: $(srcdir)/liblbfgs-1.7/lib/lbfgs.c - $(CC) -c $(CFLAGS) -I $(srcdir)/liblbfgs-1.7/lib $(srcdir)/liblbfgs-1.7/lib/lbfgs.c -o lbfgs.o +lbfgs.o: $(srcdir)/liblbfgs-1.10/lib/lbfgs.c + $(CC) -c $(CFLAGS) -I $(srcdir)/liblbfgs-1.10/lib $(srcdir)/liblbfgs-1.10/lib/lbfgs.c -o lbfgs.o @DO_SECOND_LD@yap_lbfgs.@SO@: yap_lbfgs.o lbfgs.o @DO_SECOND_LD@ @SHLIB_LD@ $(LDFLAGS) -o yap_lbfgs.@SO@ yap_lbfgs.o lbfgs.o @EXTRA_LIBS_FOR_DLLS@ diff --git a/packages/yap-lbfgs/liblbfgs-1.7/AUTHORS b/packages/yap-lbfgs/liblbfgs-1.10/AUTHORS similarity index 100% rename from packages/yap-lbfgs/liblbfgs-1.7/AUTHORS rename to packages/yap-lbfgs/liblbfgs-1.10/AUTHORS diff --git a/packages/yap-lbfgs/liblbfgs-1.7/COPYING b/packages/yap-lbfgs/liblbfgs-1.10/COPYING similarity index 96% rename from packages/yap-lbfgs/liblbfgs-1.7/COPYING rename to packages/yap-lbfgs/liblbfgs-1.10/COPYING index 6377dc8c3..406cbe215 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/COPYING +++ b/packages/yap-lbfgs/liblbfgs-1.10/COPYING @@ -1,7 +1,7 @@ The MIT License Copyright (c) 1990 Jorge Nocedal -Copyright (c) 2007-2009 Naoaki Okazaki +Copyright (c) 2007-2010 Naoaki Okazaki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/packages/yap-lbfgs/liblbfgs-1.7/ChangeLog b/packages/yap-lbfgs/liblbfgs-1.10/ChangeLog similarity index 84% rename from packages/yap-lbfgs/liblbfgs-1.7/ChangeLog rename to packages/yap-lbfgs/liblbfgs-1.10/ChangeLog index 5ef08c836..116af150d 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/ChangeLog +++ b/packages/yap-lbfgs/liblbfgs-1.10/ChangeLog @@ -1,3 +1,23 @@ +2010-xx-xx Naoaki Okazaki + + * libLBFGS 1.10: + - Fixed compiling errors on Mac OS X; this patch was kindly submitted by Nic Schraudolph. + - Reduced compiling warnings on Mac OS X; this patch was kindly submitted by Tamas Nepusz. + + +2010-01-29 Naoaki Okazaki + + * libLBFGS 1.9: + - Fixed a mistake in checking the validity of the parameters "ftol" and "wolfe"; this mistake was discovered by Kevin S. Van Horn. + + +2009-07-13 Naoaki Okazaki + + * libLBFGS 1.8: + - Accepted the patch submitted by Takashi Imamichi; the backtracking method now has three criteria for choosing the step length. + - Updated the documentation to explain the above three criteria. + + 2009-02-28 Naoaki Okazaki * libLBFGS 1.7: diff --git a/packages/yap-lbfgs/liblbfgs-1.7/INSTALL b/packages/yap-lbfgs/liblbfgs-1.10/INSTALL similarity index 100% rename from packages/yap-lbfgs/liblbfgs-1.7/INSTALL rename to packages/yap-lbfgs/liblbfgs-1.10/INSTALL diff --git a/packages/yap-lbfgs/liblbfgs-1.7/README b/packages/yap-lbfgs/liblbfgs-1.10/README similarity index 95% rename from packages/yap-lbfgs/liblbfgs-1.7/README rename to packages/yap-lbfgs/liblbfgs-1.10/README index 9a8b1b9b4..b4ce95158 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/README +++ b/packages/yap-lbfgs/liblbfgs-1.10/README @@ -1,8 +1,8 @@ libLBFGS: C library of limited-memory BFGS (L-BFGS) - Copyright (c) 1990, Jorge Nocedal - Copyright (c) 2007-2009, Naoaki Okazaki + Copyright (c) 1990, Jorge Nocedal + Copyright (c) 2007-2010, Naoaki Okazaki ========================================================================= 1. Introduction @@ -68,4 +68,4 @@ SSE/SSE2 instructions are unavailable on CPUs. libLBFGS is distributed under the term of the MIT license. Please refer to COPYING file in the distribution. -$Id: README 56 2009-02-28 09:41:21Z naoaki $ +$Id$ diff --git a/packages/yap-lbfgs/liblbfgs-1.7/include/lbfgs.h b/packages/yap-lbfgs/liblbfgs-1.10/include/lbfgs.h similarity index 88% rename from packages/yap-lbfgs/liblbfgs-1.7/include/lbfgs.h rename to packages/yap-lbfgs/liblbfgs-1.10/include/lbfgs.h index 37b3858cd..cd944a334 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/include/lbfgs.h +++ b/packages/yap-lbfgs/liblbfgs-1.10/include/lbfgs.h @@ -2,7 +2,7 @@ * C library of Limited memory BFGS (L-BFGS). * * Copyright (c) 1990, Jorge Nocedal - * Copyright (c) 2007,2008,2009 Naoaki Okazaki + * Copyright (c) 2007-2010 Naoaki Okazaki * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -/* $Id: lbfgs.h 56 2009-02-28 09:41:21Z naoaki $ */ +/* $Id$ */ #ifndef __LBFGS_H__ #define __LBFGS_H__ @@ -107,6 +107,8 @@ enum { LBFGSERR_INVALID_MAXSTEP, /** Invalid parameter lbfgs_parameter_t::ftol specified. */ LBFGSERR_INVALID_FTOL, + /** Invalid parameter lbfgs_parameter_t::wolfe specified. */ + LBFGSERR_INVALID_WOLFE, /** Invalid parameter lbfgs_parameter_t::gtol specified. */ LBFGSERR_INVALID_GTOL, /** Invalid parameter lbfgs_parameter_t::xtol specified. */ @@ -152,12 +154,40 @@ enum { LBFGS_LINESEARCH_DEFAULT = 0, /** MoreThuente method proposd by More and Thuente. */ LBFGS_LINESEARCH_MORETHUENTE = 0, - /** Backtracking method with strong Wolfe condition. */ - LBFGS_LINESEARCH_BACKTRACKING_STRONG = 1, - /** Backtracking method with regular Wolfe condition. */ + /** + * Backtracking method with the Armijo condition. + * The backtracking method finds the step length such that it satisfies + * the sufficient decrease (Armijo) condition, + * - f(x + a * d) <= f(x) + lbfgs_parameter_t::ftol * a * g(x)^T d, + * + * where x is the current point, d is the current search direction, and + * a is the step length. + */ + LBFGS_LINESEARCH_BACKTRACKING_ARMIJO = 1, + /** The backtracking method with the defualt (regular Wolfe) condition. */ LBFGS_LINESEARCH_BACKTRACKING = 2, - /** Backtracking method with regular Wolfe condition. */ - LBFGS_LINESEARCH_BACKTRACKING_LOOSE = 2, + /** + * Backtracking method with regular Wolfe condition. + * The backtracking method finds the step length such that it satisfies + * both the Armijo condition (LBFGS_LINESEARCH_BACKTRACKING_ARMIJO) + * and the curvature condition, + * - g(x + a * d)^T d >= lbfgs_parameter_t::wolfe * g(x)^T d, + * + * where x is the current point, d is the current search direction, and + * a is the step length. + */ + LBFGS_LINESEARCH_BACKTRACKING_WOLFE = 2, + /** + * Backtracking method with strong Wolfe condition. + * The backtracking method finds the step length such that it satisfies + * both the Armijo condition (LBFGS_LINESEARCH_BACKTRACKING_ARMIJO) + * and the following condition, + * - |g(x + a * d)^T d| <= lbfgs_parameter_t::wolfe * |g(x)^T d|, + * + * where x is the current point, d is the current search direction, and + * a is the step length. + */ + LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE = 3, }; /** @@ -256,6 +286,17 @@ typedef struct { */ lbfgsfloatval_t ftol; + /** + * A coefficient for the Wolfe condition. + * This parameter is valid only when the backtracking line-search + * algorithm is used with the Wolfe condition, + * ::LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE or + * ::LBFGS_LINESEARCH_BACKTRACKING_WOLFE . + * The default value is \c 0.9. This parameter should be greater + * the \ref ftol parameter and smaller than \c 1.0. + */ + lbfgsfloatval_t wolfe; + /** * A parameter to control the accuracy of the line search routine. * The default value is \c 0.9. If the function and gradient @@ -532,7 +573,7 @@ Among the various ports of L-BFGS, this library provides several features: The library is thread-safe, which is the secondary gain from the callback interface. - Cross platform. The source code can be compiled on Microsoft Visual - Studio 2005, GNU C Compiler (gcc), etc. + Studio 2010, GNU C Compiler (gcc), etc. - Configurable precision: A user can choose single-precision (float) or double-precision (double) accuracy by changing ::LBFGS_FLOAT macro. - SSE/SSE2 optimization: @@ -543,18 +584,41 @@ Among the various ports of L-BFGS, this library provides several features: This library is used by: - CRFsuite: A fast implementation of Conditional Random Fields (CRFs) +- Classias: A collection of machine-learning algorithms for classification - mlegp: an R package for maximum likelihood estimates for Gaussian processes - imaging2: the imaging2 class library - Algorithm::LBFGS - Perl extension for L-BFGS +- YAP-LBFGS (an interface to call libLBFGS from YAP Prolog) @section download Download -- Source code +- Source code +- GitHub repository libLBFGS is distributed under the term of the MIT license. @section changelog History +- Version 1.10 (2010-12-22): + - Fixed compiling errors on Mac OS X; this patch was kindly submitted by + Nic Schraudolph. + - Reduced compiling warnings on Mac OS X; this patch was kindly submitted + by Tamas Nepusz. + - Replaced memalign() with posix_memalign(). + - Updated solution and project files for Microsoft Visual Studio 2010. +- Version 1.9 (2010-01-29): + - Fixed a mistake in checking the validity of the parameters "ftol" and + "wolfe"; this was discovered by Kevin S. Van Horn. +- Version 1.8 (2009-07-13): + - Accepted the patch submitted by Takashi Imamichi; + the backtracking method now has three criteria for choosing the step + length: + - ::LBFGS_LINESEARCH_BACKTRACKING_ARMIJO: sufficient decrease (Armijo) + condition only + - ::LBFGS_LINESEARCH_BACKTRACKING_WOLFE: regular Wolfe condition + (sufficient decrease condition + curvature condition) + - ::LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE: strong Wolfe condition + - Updated the documentation to explain the above three criteria. - Version 1.7 (2009-02-28): - Improved OWL-QN routines for stability. - Removed the support of OWL-QN method in MoreThuente algorithm because @@ -658,8 +722,11 @@ method presented in: In Proceedings of the 24th International Conference on Machine Learning (ICML 2007), pp. 33-40, 2007. -Special thanks go to Yoshimasa Tsuruoka and Daisuke Okanohara for technical -information about OWL-QN. +Special thanks go to: + - Yoshimasa Tsuruoka and Daisuke Okanohara for technical information about + OWL-QN + - Takashi Imamichi for the useful enhancements of the backtracking method + - Kevin S. Van Horn, Nic Schraudolph, and Tamas Nepusz for bug fixes Finally I would like to thank the original author, Jorge Nocedal, who has been distributing the effieicnt and explanatory implementation in an open source diff --git a/packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_ansi.h b/packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_ansi.h similarity index 96% rename from packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_ansi.h rename to packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_ansi.h index a7ca63384..fa390da37 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_ansi.h +++ b/packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_ansi.h @@ -1,7 +1,7 @@ /* * ANSI C implementation of vector operations. * - * Copyright (c) 2007,2008,2009 Naoaki Okazaki + * Copyright (c) 2007-2010 Naoaki Okazaki * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -/* $Id: arithmetic_ansi.h 50 2009-02-16 15:14:23Z naoaki $ */ +/* $Id$ */ #include #include diff --git a/packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_sse_double.h b/packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_sse_double.h similarity index 95% rename from packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_sse_double.h rename to packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_sse_double.h index 5f41bf1d7..83405eeb1 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_sse_double.h +++ b/packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_sse_double.h @@ -1,7 +1,7 @@ /* * SSE2 implementation of vector oprations (64bit double). * - * Copyright (c) 2007,2008,2009 Naoaki Okazaki + * Copyright (c) 2007-2010 Naoaki Okazaki * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,10 +23,12 @@ * THE SOFTWARE. */ -/* $Id: arithmetic_sse_double.h 50 2009-02-16 15:14:23Z naoaki $ */ +/* $Id$ */ #include +#ifndef __APPLE__ #include +#endif #include #if 1400 <= _MSC_VER @@ -39,10 +41,15 @@ inline static void* vecalloc(size_t size) { -#ifdef _MSC_VER +#if defined(_MSC_VER) void *memblock = _aligned_malloc(size, 16); +#elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */ + void *memblock = malloc(size); #else - void *memblock = memalign(16, size); + void *memblock = NULL, *p = NULL; + if (posix_memalign(&p, 16, size) == 0) { + memblock = p; + } #endif if (memblock != NULL) { memset(memblock, 0, size); @@ -192,7 +199,7 @@ inline static void vecfree(void *memblock) -#if 3 <= __SSE__ +#if 3 <= __SSE__ || defined(__SSE3__) /* Horizontal add with haddps SSE3 instruction. The work register (rw) is unused. diff --git a/packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_sse_float.h b/packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_sse_float.h similarity index 95% rename from packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_sse_float.h rename to packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_sse_float.h index b01e2bd8b..835b8aa8a 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/lib/arithmetic_sse_float.h +++ b/packages/yap-lbfgs/liblbfgs-1.10/lib/arithmetic_sse_float.h @@ -1,7 +1,7 @@ /* * SSE/SSE3 implementation of vector oprations (32bit float). * - * Copyright (c) 2007,2008,2009 Naoaki Okazaki + * Copyright (c) 2007-2010 Naoaki Okazaki * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,10 +23,12 @@ * THE SOFTWARE. */ -/* $Id: arithmetic_sse_float.h 50 2009-02-16 15:14:23Z naoaki $ */ +/* $Id$ */ #include +#ifndef __APPLE__ #include +#endif #include #if 1400 <= _MSC_VER @@ -45,7 +47,16 @@ inline static void* vecalloc(size_t size) { +#if defined(_MSC_VER) void *memblock = _aligned_malloc(size, 16); +#elif defined(__APPLE__) /* OS X always aligns on 16-byte boundaries */ + void *memblock = malloc(size); +#else + void *memblock = NULL, *p = NULL; + if (posix_memalign(&p, 16, size) == 0) { + memblock = p; + } +#endif if (memblock != NULL) { memset(memblock, 0, size); } @@ -185,7 +196,7 @@ inline static void vecfree(void *memblock) -#if 3 <= __SSE__ +#if 3 <= __SSE__ || defined(__SSE3__) /* Horizontal add with haddps SSE3 instruction. The work register (rw) is unused. diff --git a/packages/yap-lbfgs/liblbfgs-1.7/lib/lbfgs.c b/packages/yap-lbfgs/liblbfgs-1.10/lib/lbfgs.c similarity index 96% rename from packages/yap-lbfgs/liblbfgs-1.7/lib/lbfgs.c rename to packages/yap-lbfgs/liblbfgs-1.10/lib/lbfgs.c index 370ac229e..30ffcf2ab 100644 --- a/packages/yap-lbfgs/liblbfgs-1.7/lib/lbfgs.c +++ b/packages/yap-lbfgs/liblbfgs-1.10/lib/lbfgs.c @@ -2,7 +2,7 @@ * Limited memory BFGS (L-BFGS). * * Copyright (c) 1990, Jorge Nocedal - * Copyright (c) 2007,2008,2009 Naoaki Okazaki + * Copyright (c) 2007-2010 Naoaki Okazaki * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -/* $Id: lbfgs.c 55 2009-02-23 14:51:21Z naoaki $ */ +/* $Id$ */ /* This library is a C port of the FORTRAN implementation of Limited-memory @@ -65,6 +65,7 @@ licence. #include #endif/*HAVE_CONFIG_H*/ +#include #include #include #include @@ -73,7 +74,6 @@ licence. #ifdef _MSC_VER #define inline __inline -typedef unsigned int uint32_t; #endif/*_MSC_VER*/ #if defined(USE_SSE) && defined(__SSE2__) && LBFGS_FLOAT == 64 @@ -113,7 +113,7 @@ typedef struct tag_iteration_data iteration_data_t; static const lbfgs_parameter_t _defparam = { 6, 1e-5, 0, 1e-5, 0, LBFGS_LINESEARCH_DEFAULT, 40, - 1e-20, 1e20, 1e-4, 0.9, 1.0e-16, + 1e-20, 1e20, 1e-4, 0.9, 0.9, 1.0e-16, 0.0, 0, -1, }; @@ -290,7 +290,7 @@ int lbfgs( if (n % 8 != 0) { return LBFGSERR_INVALID_N_SSE; } - if (((unsigned short)x & 0x000F) != 0) { + if ((uintptr_t)(const void*)x % 16 != 0) { return LBFGSERR_INVALID_X_SSE; } #endif/*defined(USE_SSE)*/ @@ -312,6 +312,12 @@ int lbfgs( if (param.ftol < 0.) { return LBFGSERR_INVALID_FTOL; } + if (param.linesearch == LBFGS_LINESEARCH_BACKTRACKING_WOLFE || + param.linesearch == LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE) { + if (param.wolfe <= param.ftol || 1. <= param.wolfe) { + return LBFGSERR_INVALID_WOLFE; + } + } if (param.gtol < 0.) { return LBFGSERR_INVALID_GTOL; } @@ -347,8 +353,9 @@ int lbfgs( case LBFGS_LINESEARCH_MORETHUENTE: linesearch = line_search_morethuente; break; - case LBFGS_LINESEARCH_BACKTRACKING: - case LBFGS_LINESEARCH_BACKTRACKING_STRONG: + case LBFGS_LINESEARCH_BACKTRACKING_ARMIJO: + case LBFGS_LINESEARCH_BACKTRACKING_WOLFE: + case LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE: linesearch = line_search_backtracking; break; default: @@ -483,7 +490,7 @@ int lbfgs( /* Report the progress. */ if (cd.proc_progress) { - if (ret = cd.proc_progress(cd.instance, x, g, fx, xnorm, gnorm, step, cd.n, k, ls)) { + if ((ret = cd.proc_progress(cd.instance, x, g, fx, xnorm, gnorm, step, cd.n, k, ls))) { goto lbfgs_exit; } } @@ -649,10 +656,10 @@ static int line_search_backtracking( const lbfgs_parameter_t *param ) { - int ret = 0, count = 0; - lbfgsfloatval_t width, dg, norm = 0.; + int count = 0; + lbfgsfloatval_t width, dg; lbfgsfloatval_t finit, dginit = 0., dgtest; - const lbfgsfloatval_t wolfe = 0.9, dec = 0.5, inc = 2.1; + const lbfgsfloatval_t dec = 0.5, inc = 2.1; /* Check the input parameters for errors. */ if (*stp <= 0.) { @@ -680,26 +687,33 @@ static int line_search_backtracking( ++count; - if (*f <= finit + *stp * dgtest) { - /* The sufficient decrease condition. */ - - if (param->linesearch == LBFGS_LINESEARCH_BACKTRACKING_STRONG) { - /* Check the strong Wolfe condition. */ - vecdot(&dg, g, s, n); - if (dg > -wolfe * dginit) { - width = dec; - } else if (dg < wolfe * dginit) { - width = inc; - } else { - /* Strong Wolfe condition. */ - return count; - } - } else { - /* Exit with the loose Wolfe condition. */ - return count; - } - } else { + if (*f > finit + *stp * dgtest) { width = dec; + } else { + /* The sufficient decrease condition (Armijo condition). */ + if (param->linesearch == LBFGS_LINESEARCH_BACKTRACKING_ARMIJO) { + /* Exit with the Armijo condition. */ + return count; + } + + /* Check the Wolfe condition. */ + vecdot(&dg, g, s, n); + if (dg < param->wolfe * dginit) { + width = inc; + } else { + if(param->linesearch == LBFGS_LINESEARCH_BACKTRACKING_WOLFE) { + /* Exit with the regular Wolfe condition. */ + return count; + } + + /* Check the strong Wolfe condition. */ + if(dg > -param->wolfe * dginit) { + width = dec; + } else { + /* Exit with the strong Wolfe condition. */ + return count; + } + } } if (*stp < param->min_step) { @@ -735,7 +749,7 @@ static int line_search_backtracking_owlqn( const lbfgs_parameter_t *param ) { - int i, ret = 0, count = 0; + int i, count = 0; lbfgsfloatval_t width = 0.5, norm = 0.; lbfgsfloatval_t finit = *f, dgtest;