Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
682 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Apache.Commons.Math/Exceptions/MultiDimensionMismatchException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Apache.Commons.Math.Exceptions.Util; | ||
|
||
namespace Apache.Commons.Math.Exceptions | ||
{ | ||
/// <summary> | ||
/// Exception thrown when two sets of dimensions differ. | ||
/// </summary> | ||
[Serializable] | ||
public class MultiDimensionMismatchException: MathArgumentException | ||
{ | ||
/// <summary> | ||
/// Wrong dimensions. | ||
/// </summary> | ||
public int[] WrongDimensions { get; private set; } | ||
/// <summary> | ||
/// Correct dimensions. | ||
/// </summary> | ||
public int[] ExpectedDimensions { get; private set; } | ||
|
||
/// <summary> | ||
/// Constructs an exception from the mismatched dimensions. | ||
/// </summary> | ||
/// <param name="wrong">Wrong dimensions.</param> | ||
/// <param name="expected">Expected dimensions.</param> | ||
public MultiDimensionMismatchException(int[] wrong, int[] expected) : | ||
this(LocalizedFormat.DIMENSIONS_MISMATCH, wrong, expected) { } | ||
|
||
/// <summary> | ||
/// Construct an exception from the mismatched dimensions. | ||
/// </summary> | ||
/// <param name="specific">Message pattern providing the specific context of the error.</param> | ||
/// <param name="wrong">Wrong dimensions.</param> | ||
/// <param name="expected">Expected dimensions.</param> | ||
public MultiDimensionMismatchException(ILocalizable specific, int[] wrong, int[] expected): | ||
base(specific, wrong, expected) | ||
{ | ||
this.WrongDimensions = wrong.Clone() as int[]; | ||
this.ExpectedDimensions = expected.Clone() as int[]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Apache.Commons.Math.Exceptions.Util; | ||
|
||
namespace Apache.Commons.Math.Exceptions | ||
{ | ||
/// <summary> | ||
/// Exception to be thrown when function values have the same sign at both ends of an interval. | ||
/// </summary> | ||
[Serializable] | ||
public class NoBracketingException: MathArgumentException | ||
{ | ||
/// <summary> | ||
/// Lower end of the interval. | ||
/// </summary> | ||
public double Lo { get; private set; } | ||
/// <summary> | ||
/// Higher end of the interval. | ||
/// </summary> | ||
public double Hi { get; private set; } | ||
/// <summary> | ||
/// Value at the lower end of the interval. | ||
/// </summary> | ||
public double Flo { get; private set; } | ||
/// <summary> | ||
/// Value at the upper end of the interval. | ||
/// </summary> | ||
public double Fhi { get; private set; } | ||
|
||
/// <summary> | ||
/// Construct the exception. | ||
/// </summary> | ||
/// <param name="lo">Lower end of the interval.</param> | ||
/// <param name="hi">Higher end of the interval.</param> | ||
/// <param name="fLo">Value at the lower end of the interval.</param> | ||
/// <param name="fHi">Value at the higher end of the interval.</param> | ||
public NoBracketingException(double lo, double hi, double fLo, double fHi) : | ||
this(LocalizedFormat.SAME_SIGN_AT_ENDPOINTS, lo, hi, fLo, fHi) { } | ||
|
||
/// <summary> | ||
/// Construct the exception. | ||
/// </summary> | ||
/// <param name="specific">Contextual information on what caused the exception.</param> | ||
/// <param name="lo">Lower end of the interval.</param> | ||
/// <param name="hi">Higher end of the interval.</param> | ||
/// <param name="fLo">Value at the lower end of the interval.</param> | ||
/// <param name="fHi">Value at the higher end of the interval.</param> | ||
/// <param name="args">Additional arguments.</param> | ||
public NoBracketingException(ILocalizable specific, double lo, double hi, double fLo, double fHi, params object[] args) : | ||
base(specific, lo, hi, fLo, fHi, args) | ||
{ | ||
this.Lo = lo; | ||
this.Hi = hi; | ||
this.Flo = fLo; | ||
this.Fhi = fHi; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Apache.Commons.Math.Exceptions.Util; | ||
|
||
namespace Apache.Commons.Math.Exceptions | ||
{ | ||
/// <summary> | ||
/// Exception to be thrown when the required data is missing. | ||
/// </summary> | ||
[Serializable] | ||
public class NoDataException: MathArgumentException | ||
{ | ||
/// <summary> | ||
/// Default constructor. | ||
/// </summary> | ||
public NoDataException() : this(LocalizedFormat.NO_DATA) { } | ||
|
||
/// <summary> | ||
/// Construct the exception with a specific context. | ||
/// </summary> | ||
/// <param name="specific">Contextual information on what caused the exception.</param> | ||
public NoDataException(ILocalizable specific) : base(specific) { } | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
Apache.Commons.Math/Exceptions/NonMonotonicSequenceException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Apache.Commons.Math.Util; | ||
using Apache.Commons.Math.Exceptions.Util; | ||
|
||
namespace Apache.Commons.Math.Exceptions | ||
{ | ||
/// <summary> | ||
/// Exception to be thrown when a sequence of values is not monotonically increasing or decreasing. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
[Serializable] | ||
public class NonMonotonicSequenceException<T>: MathIllegalNumberException<T> | ||
{ | ||
/// <summary> | ||
/// Direction (positive for increasing, negative for decreasing). | ||
/// </summary> | ||
public OrderDirection Direction { get; private set; } | ||
/// <summary> | ||
/// Whether the sequence must be strictly increasing or decreasing. | ||
/// </summary> | ||
public bool Strict { get; private set; } | ||
/// <summary> | ||
/// Index of the wrong value. | ||
/// </summary> | ||
public int Index { get; private set; } | ||
/// <summary> | ||
/// Previous value. | ||
/// </summary> | ||
public T Previous { get; private set; } | ||
|
||
/// <summary> | ||
/// Construct the exception. | ||
/// <para>This constructor used default values assuming that the sequence should | ||
/// have been strictly increasing.</para> | ||
/// </summary> | ||
/// <param name="wrong">The value that did not match the requirements.</param> | ||
/// <param name="previous">Previous value in the sequence.</param> | ||
/// <param name="index">Index of the value that did not match the sequence.</param> | ||
public NonMonotonicSequenceException(T wrong, T previous, int index) : | ||
this(wrong, previous, index, OrderDirection.Increasing, true) { } | ||
|
||
public NonMonotonicSequenceException(T wrong, T previous, int index, OrderDirection direction, bool strict): | ||
base(direction == OrderDirection.Increasing ? | ||
(strict ? LocalizedFormat.NOT_STRICTLY_INCREASING_SEQUENCE : LocalizedFormat.NOT_INCREASING_SEQUENCE) : | ||
(strict ? LocalizedFormat.NOT_STRICTLY_DECREASING_SEQUENCE : LocalizedFormat.NOT_DECREASING_SEQUENCE), | ||
wrong, previous, index, index - 1) | ||
{ | ||
this.Direction = direction; | ||
this.Strict = strict; | ||
this.Index = index; | ||
this.Previous = previous; | ||
} | ||
} | ||
} |
Oops, something went wrong.