/** * @param value * @param type * @return */ private Object createTypedObject(String value, Class type) { if (java.lang.String.class == type) return value; else if (java.lang.Integer.class == type) return java.lang.Integer.parseInt(value); else if (java.lang.Long.class == type) return java.lang.Long.parseLong(value); else if (java.lang.Boolean.class == type) return java.lang.Boolean.parseBoolean(value); else if (java.lang.Float.class == type) return java.lang.Float.parseFloat(value); else if (java.lang.Double.class == type) return java.lang.Double.parseDouble(value); return null; }
public void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException { if (parameterIndex < 1 || parameterIndex > args.length) { throw new SQLException("bad parameter index"); } if (x == null) { args[parameterIndex - 1] = nullrepl ? "" : null; } else { if (conn.useJulian) { args[parameterIndex - 1] = java.lang.Double.toString(SQLite.Database.julian_from_long(x.getTime())); } else { args[parameterIndex - 1] = x.toString(); } } blobs[parameterIndex - 1] = false; }
public double EVAL( UnivariatePolynomial p, double lowerBound, double upperBound, double fl, double fu) { // System.out.println( "EVAL on (" + lowerBound + "," + upperBound + ") |-> (" + fl + "," + fu + // ")" ); double m = (lowerBound + upperBound) / 2.0; double r = (upperBound - lowerBound) / 2.0; // System.out.println( "(m,r)=("+m+","+r+")" ); if (upperBound - lowerBound < EPSILON) { // System.out.println( "epsilon reached" ); // prevent infinite loop (e.g. for non-squarefree polynomials) if (fl * fu < 0.0) return m; else return m; // java.lang.Double.NaN; } // test for exclusion predicate: no real root in (m-r,m+r) UnivariatePolynomial t = p.shift(m); // System.out.println( "Taylor exp. of f(x-" + m + "): " + t ); double fm = t.getCoeff(0); double ta[] = t.getCoeffs(); ta[0] = -Math.abs(ta[0]); for (int i = 1; i < ta.length; ++i) ta[i] = Math.abs(ta[i]); if (0.0 > new UnivariatePolynomial(ta).evaluateAt(r)) return java.lang.Double.NaN; // System.out.println( "Exclusion predicate false" ); // test for inclusion predicate: exactly one real root in (m-r,m+r) UnivariatePolynomial t_der = p.derive().shift(m); // System.out.println( "Taylor exp. of f'(x-" + m + "): " + t_der ); double ta_der[] = t_der.getCoeffs(); ta_der[0] = -Math.abs(ta_der[0]); for (int i = 1; i < ta_der.length; ++i) ta_der[i] = Math.abs(ta_der[i]); if (fl * fu <= 0.0 && 0.0 > new UnivariatePolynomial(ta_der).evaluateAt(r)) return bisect(p, lowerBound, upperBound, fl, fu); // System.out.println( "Inclusion predicate false" ); System.out.println(); // bisect double result_left = EVAL(p, lowerBound, m, fl, fm); if (!java.lang.Double.isNaN(result_left)) return result_left; else return EVAL(p, m, upperBound, fm, fu); }