/** create */ protected OptimizationBasedFitter() { super(); Throwable cannot; cannot = null; try { ReflectionUtils.ensureClassesAreLoaded( // "org.apache.commons.math3.analysis.MultivariateFunction", //$NON-NLS-1$ "org.apache.commons.math3.exception.MathIllegalStateException", //$NON-NLS-1$ "org.apache.commons.math3.exception.NumberIsTooSmallException", //$NON-NLS-1$ "org.apache.commons.math3.exception.OutOfRangeException", //$NON-NLS-1$ "org.apache.commons.math3.exception.util.LocalizedFormats", //$NON-NLS-1$ "org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer", //$NON-NLS-1$ "org.apache.commons.math3.fitting.leastsquares.LeastSquaresProblem", //$NON-NLS-1$ "org.apache.commons.math3.fitting.leastsquares.LevenbergMarquardtOptimizer", //$NON-NLS-1$ "org.apache.commons.math3.linear.Array2DRowRealMatrix", //$NON-NLS-1$ "org.apache.commons.math3.linear.ArrayRealVector", //$NON-NLS-1$ "org.apache.commons.math3.linear.QRDecomposition", //$NON-NLS-1$ "org.apache.commons.math3.linear.RealMatrix", //$NON-NLS-1$ "org.apache.commons.math3.linear.RealVector", //$NON-NLS-1$ "org.apache.commons.math3.optim.ConvergenceChecker", //$NON-NLS-1$ "org.apache.commons.math3.optim.InitialGuess", //$NON-NLS-1$ "org.apache.commons.math3.optim.MaxEval", //$NON-NLS-1$ "org.apache.commons.math3.optim.MaxIter", //$NON-NLS-1$ "org.apache.commons.math3.optim.PointValuePair", //$NON-NLS-1$ "org.apache.commons.math3.optim.SimpleBounds", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.GoalType", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizer", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.noderiv.NelderMeadSimplex", //$NON-NLS-1$ "org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizer", //$NON-NLS-1$ "org.apache.commons.math3.random.JDKRandomGenerator", //$NON-NLS-1$ "org.apache.commons.math3.util.FastMath", //$NON-NLS-1$ "org.apache.commons.math3.util.Incrementor" //$NON-NLS-1$ ); } catch (final Throwable error) { cannot = error; } this.m_error = cannot; }
/** {@inheritDoc} */ @Override public final int parseInt(final String string) { final _PreparedString prep; int retVal; String str; _TextConst cnst; Object number; int base; checker: { try { // first we try to cast the string directly to a int // this will be the fast execution path for 'correctly' formatted // numbers retVal = java.lang.Integer.parseInt(string); break checker; } catch (final NumberFormatException origNumberError) { // ok, the string does not follow java's default number format // so now, we check whether it is hexadecimal/octal/binary // formatted, a // constant, or even a static member identifier prep = new _PreparedString(string); outer: while ((str = prep.next()) != null) { // we now iterate over the prepared strings: step-by-step, we // will // try // to process the string by, e.g., trimming it; removing +, -, (, // ), // etc; removing internal white spaces and underscores (to match // Java // 7's new binary syntax) and so on - until we can either parse // it or // have to give up if (str != string) { // try again to parse the string directly try { retVal = prep.getReturn(java.lang.Integer.parseInt(str)); break checker; } catch (final Throwable canBeIgnored) { // we ignore this exception, as we will throw the original // one // on failure } } // let's see if it was a constant in some other base if ((str.length() > 2) && (str.charAt(0) == '0')) { if ((base = _PreparedString._getBase(str.charAt(1))) != 0) { try { retVal = prep.getReturn(java.lang.Integer.parseInt(str.substring(2), base)); break checker; } catch (final Throwable canBeIgnored) { // we ignore this exception, as we will throw the original // one // on failure } } } // does the string correspond to a constant we know? cnst = _TextConst.findConst(str); if (cnst != null) { if (cnst.hasInt()) { retVal = prep.getReturn(cnst.m_i); break checker; } break outer; } // ok, it is no constant, maybe it is a public static final // member? try { number = ReflectionUtils.getInstanceByName(Object.class, str); if ((number != null) && (number != string) && (number != str)) { retVal = prep.getReturn(this.__parseObjectRaw(number)); break checker; } } catch (final Throwable canBeIgnored) { // ignore this exception: it will be thrown if no member fits // in which case we will throw the original error anyway at the // end } } // ok, all our ideas to resolve the number have failed - throw // original // error again throw origNumberError; } } this.validateInt(retVal); return retVal; }