001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.commons.math3.exception; 018 019 import org.apache.commons.math3.exception.util.Localizable; 020 import org.apache.commons.math3.exception.util.LocalizedFormats; 021 022 /** 023 * Exception to be thrown when function values have the same sign at both 024 * ends of an interval. 025 * 026 * @since 3.0 027 * @version $Id: NoBracketingException.java 1364378 2012-07-22 17:42:38Z tn $ 028 */ 029 public class NoBracketingException extends MathIllegalArgumentException { 030 /** Serializable version Id. */ 031 private static final long serialVersionUID = -3629324471511904459L; 032 /** Lower end of the interval. */ 033 private final double lo; 034 /** Higher end of the interval. */ 035 private final double hi; 036 /** Value at lower end of the interval. */ 037 private final double fLo; 038 /** Value at higher end of the interval. */ 039 private final double fHi; 040 041 /** 042 * Construct the exception. 043 * 044 * @param lo Lower end of the interval. 045 * @param hi Higher end of the interval. 046 * @param fLo Value at lower end of the interval. 047 * @param fHi Value at higher end of the interval. 048 */ 049 public NoBracketingException(double lo, double hi, 050 double fLo, double fHi) { 051 this(LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, lo, hi, fLo, fHi); 052 } 053 054 /** 055 * Construct the exception with a specific context. 056 * 057 * @param specific Contextual information on what caused the exception. 058 * @param lo Lower end of the interval. 059 * @param hi Higher end of the interval. 060 * @param fLo Value at lower end of the interval. 061 * @param fHi Value at higher end of the interval. 062 * @param args Additional arguments. 063 */ 064 public NoBracketingException(Localizable specific, 065 double lo, double hi, 066 double fLo, double fHi, 067 Object ... args) { 068 super(specific, lo, hi, fLo, fHi, args); 069 this.lo = lo; 070 this.hi = hi; 071 this.fLo = fLo; 072 this.fHi = fHi; 073 } 074 075 /** 076 * Get the lower end of the interval. 077 * 078 * @return the lower end. 079 */ 080 public double getLo() { 081 return lo; 082 } 083 /** 084 * Get the higher end of the interval. 085 * 086 * @return the higher end. 087 */ 088 public double getHi() { 089 return hi; 090 } 091 /** 092 * Get the value at the lower end of the interval. 093 * 094 * @return the value at the lower end. 095 */ 096 public double getFLo() { 097 return fLo; 098 } 099 /** 100 * Get the value at the higher end of the interval. 101 * 102 * @return the value at the higher end. 103 */ 104 public double getFHi() { 105 return fHi; 106 } 107 }