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 */ 017package org.apache.commons.math3.exception; 018 019import org.apache.commons.math3.exception.util.Localizable; 020import 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 */ 028public class NoBracketingException extends MathIllegalArgumentException { 029 /** Serializable version Id. */ 030 private static final long serialVersionUID = -3629324471511904459L; 031 /** Lower end of the interval. */ 032 private final double lo; 033 /** Higher end of the interval. */ 034 private final double hi; 035 /** Value at lower end of the interval. */ 036 private final double fLo; 037 /** Value at higher end of the interval. */ 038 private final double fHi; 039 040 /** 041 * Construct the exception. 042 * 043 * @param lo Lower end of the interval. 044 * @param hi Higher end of the interval. 045 * @param fLo Value at lower end of the interval. 046 * @param fHi Value at higher end of the interval. 047 */ 048 public NoBracketingException(double lo, double hi, 049 double fLo, double fHi) { 050 this(LocalizedFormats.SAME_SIGN_AT_ENDPOINTS, lo, hi, fLo, fHi); 051 } 052 053 /** 054 * Construct the exception with a specific context. 055 * 056 * @param specific Contextual information on what caused the exception. 057 * @param lo Lower end of the interval. 058 * @param hi Higher end of the interval. 059 * @param fLo Value at lower end of the interval. 060 * @param fHi Value at higher end of the interval. 061 * @param args Additional arguments. 062 */ 063 public NoBracketingException(Localizable specific, 064 double lo, double hi, 065 double fLo, double fHi, 066 Object ... args) { 067 super(specific, Double.valueOf(lo), Double.valueOf(hi), Double.valueOf(fLo), Double.valueOf(fHi), args); 068 this.lo = lo; 069 this.hi = hi; 070 this.fLo = fLo; 071 this.fHi = fHi; 072 } 073 074 /** 075 * Get the lower end of the interval. 076 * 077 * @return the lower end. 078 */ 079 public double getLo() { 080 return lo; 081 } 082 /** 083 * Get the higher end of the interval. 084 * 085 * @return the higher end. 086 */ 087 public double getHi() { 088 return hi; 089 } 090 /** 091 * Get the value at the lower end of the interval. 092 * 093 * @return the value at the lower end. 094 */ 095 public double getFLo() { 096 return fLo; 097 } 098 /** 099 * Get the value at the higher end of the interval. 100 * 101 * @return the value at the higher end. 102 */ 103 public double getFHi() { 104 return fHi; 105 } 106}