2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
17
package org.apache.commons.math;
19
import org.apache.commons.math.linear.ArrayRealVector;
22
* Exception thrown when an error occurs evaluating a function.
24
* Maintains an <code>argument</code> property holding the input value that
25
* caused the function evaluation to fail.
27
* @version $Revision: 783702 $ $Date: 2009-06-11 04:54:02 -0400 (Thu, 11 Jun 2009) $
29
public class FunctionEvaluationException extends MathException {
31
/** Serializable version identifier. */
32
private static final long serialVersionUID = -4305020489115478365L;
34
/** Argument causing function evaluation failure */
35
private double[] argument;
38
* Construct an exception indicating the argument value
39
* that caused the function evaluation to fail.
41
* @param argument the failing function argument
43
public FunctionEvaluationException(double argument) {
44
super("evaluation failed for argument = {0}", argument);
45
this.argument = new double[] { argument };
49
* Construct an exception indicating the argument value
50
* that caused the function evaluation to fail.
52
* @param argument the failing function argument
55
public FunctionEvaluationException(double[] argument) {
56
super("evaluation failed for argument = {0}", new ArrayRealVector(argument));
57
this.argument = argument.clone();
61
* Constructs an exception with specified formatted detail message.
62
* Message formatting is delegated to {@link java.text.MessageFormat}.
63
* @param argument the failing function argument
64
* @param pattern format specifier
65
* @param arguments format arguments
68
public FunctionEvaluationException(double argument,
69
String pattern, Object ... arguments) {
70
super(pattern, arguments);
71
this.argument = new double[] { argument };
75
* Constructs an exception with specified formatted detail message.
76
* Message formatting is delegated to {@link java.text.MessageFormat}.
77
* @param argument the failing function argument
78
* @param pattern format specifier
79
* @param arguments format arguments
82
public FunctionEvaluationException(double[] argument,
83
String pattern, Object ... arguments) {
84
super(pattern, arguments);
85
this.argument = argument.clone();
89
* Constructs an exception with specified root cause.
90
* Message formatting is delegated to {@link java.text.MessageFormat}.
91
* @param cause the exception or error that caused this exception to be thrown
92
* @param argument the failing function argument
95
public FunctionEvaluationException(Throwable cause, double argument) {
97
this.argument = new double[] { argument };
101
* Constructs an exception with specified root cause.
102
* Message formatting is delegated to {@link java.text.MessageFormat}.
103
* @param cause the exception or error that caused this exception to be thrown
104
* @param argument the failing function argument
107
public FunctionEvaluationException(Throwable cause, double[] argument) {
109
this.argument = argument.clone();
113
* Constructs an exception with specified formatted detail message and root cause.
114
* Message formatting is delegated to {@link java.text.MessageFormat}.
115
* @param cause the exception or error that caused this exception to be thrown
116
* @param argument the failing function argument
117
* @param pattern format specifier
118
* @param arguments format arguments
121
public FunctionEvaluationException(Throwable cause,
122
double argument, String pattern,
123
Object ... arguments) {
124
super(cause, pattern, arguments);
125
this.argument = new double[] { argument };
129
* Constructs an exception with specified formatted detail message and root cause.
130
* Message formatting is delegated to {@link java.text.MessageFormat}.
131
* @param cause the exception or error that caused this exception to be thrown
132
* @param argument the failing function argument
133
* @param pattern format specifier
134
* @param arguments format arguments
137
public FunctionEvaluationException(Throwable cause,
138
double[] argument, String pattern,
139
Object ... arguments) {
140
super(cause, pattern, arguments);
141
this.argument = argument.clone();
145
* Returns the function argument that caused this exception.
147
* @return argument that caused function evaluation to fail
149
public double[] getArgument() {
150
return argument.clone();