fr.cnes.sirius.patrius.stela
Class JavaMathAdapter

java.lang.Object
  extended by fr.cnes.sirius.patrius.stela.JavaMathAdapter

public final class JavaMathAdapter
extends Object

Math adapter class.

Since:
1.3
Version:
$Id: JavaMathAdapter.java 17584 2017-05-10 13:26:39Z bignon $
Author:
cardosop
Concurrency :
unconditionally thread-safe

Method Summary
static double binomialCoefficientGeneric(int a, int b)
          Compute the Binomial Coefficient, "a choose b", the number of b-element subsets that can be selected from an a-element set.
static double[][] matrixAdd(double[][] m1, double[][] m2)
          Add 2 matrices.
static double[][] matrixMultiply(double[][] m1, double[][] m2)
          Multiply 2 matrix.
static void matrixToVector(double[][] matrix, double[] vector, int offset)
          Copy a matrix into a vector, column per column.
static double[][] matrixTranspose(double[][] m)
          Transpose a matrix.
static double[] matrixVectorMultiply(double[][] m, double[] v)
          Multiply matrix with a vector.
static double mod(double x, double mod)
          Computes "x" modulo "mod".
static double[] negate(double[] v)
          Invert a vector.
static double[][] scalarMultiply(double coef, double[][] matrix)
          Return coef * matrix.
static double[][] threeDMatrixVectorMultiply(double[][][] mat, double[] vect)
          Multiply an automatically-generated-3-dimensional matrix with a vector.
Automatically generated 3D matrices have their rows and wideness inverted.
static void vectorToMatrix(double[] vector, double[][] matrix)
          Copy a vector into a matrix, column per column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

mod

public static double mod(double x,
                         double mod)
Computes "x" modulo "mod".

Parameters:
x - value to modulate
mod - modulo (for instance π)
Returns:
"x" modulo "mod"

binomialCoefficientGeneric

public static double binomialCoefficientGeneric(int a,
                                                int b)
Compute the Binomial Coefficient, "a choose b", the number of b-element subsets that can be selected from an a-element set. This formula can be used with negative a values.

Parameters:
a - the size of the set
b - the size of the subsets
Returns:
a choose b

threeDMatrixVectorMultiply

public static double[][] threeDMatrixVectorMultiply(double[][][] mat,
                                                    double[] vect)
                                             throws OrekitException
Multiply an automatically-generated-3-dimensional matrix with a vector.
Automatically generated 3D matrices have their rows and wideness inverted. This method corrects it.

Parameters:
mat - the 3-dimensional matrix
vect - the vector
Returns:
product, a 2-dimensional matrix
Throws:
OrekitException - thrown if matrix dimension mismatch

negate

public static double[] negate(double[] v)
Invert a vector.

Parameters:
v - vector
Returns:
-v

matrixAdd

public static double[][] matrixAdd(double[][] m1,
                                   double[][] m2)
                            throws OrekitException
Add 2 matrices.

Parameters:
m1 - first matrix
m2 - second matrix
Returns:
sum of the two matrices
Throws:
OrekitException - thrown if matrix dimension mismatch

vectorToMatrix

public static void vectorToMatrix(double[] vector,
                                  double[][] matrix)
Copy a vector into a matrix, column per column.

Parameters:
vector - vector to be copied
matrix - matrix where to put the data

matrixToVector

public static void matrixToVector(double[][] matrix,
                                  double[] vector,
                                  int offset)
Copy a matrix into a vector, column per column.

Parameters:
matrix - matrix from which the data is read
vector - vector in which the data is put
offset - offset after which the data will be put in the vector thrown if dimensions mismatch

matrixMultiply

public static double[][] matrixMultiply(double[][] m1,
                                        double[][] m2)
Multiply 2 matrix.

Parameters:
m1 - first Matrix
m2 - second matrix
Returns:
the products

matrixTranspose

public static double[][] matrixTranspose(double[][] m)
Transpose a matrix.

Parameters:
m - the matrix.
Returns:
Matrix transposed.

matrixVectorMultiply

public static double[] matrixVectorMultiply(double[][] m,
                                            double[] v)
Multiply matrix with a vector.

Parameters:
m - the matrix
v - the vector
Returns:
Products with matrix and vector

scalarMultiply

public static double[][] scalarMultiply(double coef,
                                        double[][] matrix)
Return coef * matrix.

Parameters:
coef - a coefficent
matrix - a matrix
Returns:
a matrix resulting from the operation coef * matrix.


Copyright © 2017 CNES. All Rights Reserved.