Class MathTools

java.lang.Object
de.tu_bs.isbs.util.math.MathTools

public class MathTools
extends java.lang.Object
Mathematische Hilfsfunktionen.
Author:
reiser
  • Method Summary

    Modifier and Type Method Description
    static double agm​(double x, double y)
    Gaußsches arithmetisch-geometrisches Mittel (AGM).
    static double checkFinite​(double v)
    Prüft, ob Wert v eine finite Zahl ist, wirft anderenfalls ArithmeticException.
    static double[] checkFinite​(double[] values)
    Prüft, ob alle Werte in values finite Zahlen sind, wirft anderenfalls ArithmeticException.
    static double[][] checkFinite​(double[][] values)
    Prüft, ob alle Werte in values finite Zahlen sind, wirft anderenfalls ArithmeticException.
    static double evaluate_polynomial​(double x, double[] coeff)
    Wertet ein Polynom an der Stelle x aus.
    static void main​(java.lang.String[] args)  
    static double max​(double... a)
    Das Maximum aus einer beliebigen Anzahl von Argumenten.
    static int maxInt​(int... a)
    Das Maximum aus einer beliebigen Anzahl von Argumenten.
    static double min​(double... a)
    Das Minimum aus einer beliebigen Anzahl von Argumenten.
    static int minInt​(int... a)
    Das Minimum aus einer beliebigen Anzahl von Argumenten.
    static double[] quadroots​(double a, double b, double c)
    Berechnet Lösungen (x1,x2) der quadratischen Gleichung ax**2 + bx + c = 0.
    static Vector rotate3DVector_ZAxis​(Vector V, double alpha)
    Rotiert einen 3D-Vektor um die z-Achse um den Winkel alpha.
    static Vector rotate3DVector_ZAxis​(Vector V, double sinAlpha, double cosAlpha)
    Rotiert einen 3D-Vektor um die z-Achse um den Winkel alpha.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • quadroots

      public static double[] quadroots​(double a, double b, double c)
      Berechnet Lösungen (x1,x2) der quadratischen Gleichung ax**2 + bx + c = 0. Algorithmus aus: Heinrich Sormann. Numerische Methoden in der Physik. Vorlesungsskript (WS 2007/2008). Inst. f. Theor. Phys., TU Graz. S. 9
      Parameters:
      a - Koeffizient a.
      b - Koeffizient b.
      c - Koeffizient c.
      Returns:
      Array mit zwei Lösungen x1 ≤ x2 der quadratischen Gleichung ax**2+bx+c = 0. Wenn keine Lösungen existieren, oder wenn jedes x eine Lösung ist, wird {NAN, NAN} geliefert. Dies ist der Fall für a = b = 0. (Keine Lösung für c ≠ 0, jedes x Lösung für c = 0.)
    • evaluate_polynomial

      public static double evaluate_polynomial​(double x, double[] coeff)
      Wertet ein Polynom an der Stelle x aus.
      Parameters:
      x -
      coeff - coefficients of polynomial poly(x)
      Returns:
      poly(x)
    • rotate3DVector_ZAxis

      public static Vector rotate3DVector_ZAxis​(Vector V, double sinAlpha, double cosAlpha)
      Rotiert einen 3D-Vektor um die z-Achse um den Winkel alpha. Nimmt aus Effizienzgründen die Werte sin(alpha) und cos(alpha) als Parameter entgegen, statt diese aus dem Wert alpha selbst zu berechnen. Die Gültigkeit dieser Parameter wird nicht geprüft.
      Parameters:
      V - der zu rotierende 3D-Vektor.
      sinAlpha - sin(alpha)
      cosAlpha - cos(alpha)
      Returns:
      Liefert einen um den Winkel alpha um die z-Achse rotierten Vektor.
    • rotate3DVector_ZAxis

      public static Vector rotate3DVector_ZAxis​(Vector V, double alpha)
      Rotiert einen 3D-Vektor um die z-Achse um den Winkel alpha.
      Parameters:
      V - der zu rotierende 3D-Vektor.
      alpha - Winkel alpha [rad]
      Returns:
      Liefert einen um den Winkel alpha um die z-Achse rotierten Vektor.
    • checkFinite

      public static double[][] checkFinite​(double[][] values)
      Prüft, ob alle Werte in values finite Zahlen sind, wirft anderenfalls ArithmeticException.
      Parameters:
      values - Die zu prüfenden Werte.
      Returns:
      values
      Throws:
      java.lang.ArithmeticException - Wirft ArithmeticException/RuntimeException, wenn values ein Element enthält, das entweder NaN oder +/-Inf ist.
    • checkFinite

      public static double[] checkFinite​(double[] values)
      Prüft, ob alle Werte in values finite Zahlen sind, wirft anderenfalls ArithmeticException.
      Parameters:
      values - Die zu prüfenden Werte.
      Returns:
      values
      Throws:
      java.lang.ArithmeticException - Wirft ArithmeticException/RuntimeException, wenn values ein Element enthält, das entweder NaN oder +/-Inf ist.
    • checkFinite

      public static double checkFinite​(double v)
      Prüft, ob Wert v eine finite Zahl ist, wirft anderenfalls ArithmeticException.
      Parameters:
      v - Der zu prüfende Wert.
      Returns:
      v
      Throws:
      java.lang.ArithmeticException - wird geworfen, wenn v entweder NaN oder +/-Inf ist.
    • max

      public static double max​(double... a)
      Das Maximum aus einer beliebigen Anzahl von Argumenten.
      Parameters:
      a - Liste von Werten.
      Returns:
      Maximum aller Argumente oder NaN, falls ein Argument NaN ist.
      Throws:
      java.lang.IndexOutOfBoundsException - wird ausgelöst, wenn kein Argument angegeben wird.
    • min

      public static double min​(double... a)
      Das Minimum aus einer beliebigen Anzahl von Argumenten.
      Parameters:
      a - Liste von Werten.
      Returns:
      Minimum aller Argumente oder NaN, falls ein Argument NaN ist.
    • maxInt

      public static int maxInt​(int... a)
      Das Maximum aus einer beliebigen Anzahl von Argumenten.
      Parameters:
      a - Liste von Werten.
      Returns:
      Maximum aller Argumente.
    • minInt

      public static int minInt​(int... a)
      Das Minimum aus einer beliebigen Anzahl von Argumenten.
      Parameters:
      a - Liste von Werten.
      Returns:
      Minimum aller Argumente.
    • agm

      public static double agm​(double x, double y)
      Gaußsches arithmetisch-geometrisches Mittel (AGM).
      Parameters:
      x -
      y -
      Returns:
      NaN oder +/-Inf, wenn 1/2*(x+y) NaN oder +/-Inf ergibt, sonst agm(x,y).
    • main

      public static void main​(java.lang.String[] args)