Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#NEGATIVE_COMPLEX_MODULE

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#NEGATIVE_COMPLEX_MODULE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 2
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 3
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 4
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 5
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException  if r is negative
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 6
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 7
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}
 
Example 8
Source File: ComplexUtils.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a complex number from the given polar representation.
 * <p>
 * The value returned is <code>r&middot;e<sup>i&middot;theta</sup></code>,
 * computed as <code>r&middot;cos(theta) + r&middot;sin(theta)i</code></p>
 * <p>
 * If either <code>r</code> or <code>theta</code> is NaN, or
 * <code>theta</code> is infinite, {@link Complex#NaN} is returned.</p>
 * <p>
 * If <code>r</code> is infinite and <code>theta</code> is finite,
 * infinite or NaN values may be returned in parts of the result, following
 * the rules for double arithmetic.<pre>
 * Examples:
 * <code>
 * polar2Complex(INFINITY, &pi;/4) = INFINITY + INFINITY i
 * polar2Complex(INFINITY, 0) = INFINITY + NaN i
 * polar2Complex(INFINITY, -&pi;/4) = INFINITY - INFINITY i
 * polar2Complex(INFINITY, 5&pi;/4) = -INFINITY - INFINITY i </code></pre></p>
 *
 * @param r the modulus of the complex number to create
 * @param theta  the argument of the complex number to create
 * @return <code>r&middot;e<sup>i&middot;theta</sup></code>
 * @throws MathIllegalArgumentException if {@code r} is negative.
 * @since 1.1
 */
public static Complex polar2Complex(double r, double theta) throws MathIllegalArgumentException {
    if (r < 0) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.NEGATIVE_COMPLEX_MODULE, r);
    }
    return new Complex(r * FastMath.cos(theta), r * FastMath.sin(theta));
}