de.jreality.math

## Class Rn

• ```public final class Rn
extends Object```
Static methods for n-dimensional Euclidean vector space Rn. All vectors are of type double[].

This includes a set of methods related to linear transformations of Rn. Because of the need to have matrices stored in contiguous memory (rather than Java-style as an array of pointers), matrices are also of type double[]. Since all the matrices that occur here are square ones, the actual dimensions can be calculated easily from the over-all length. For example, an array of length 16 corresponds to a 4x4 matrix. Currently the limit on the size of these square matrices is 10x10. Methods where there is a lower limit annotate this restriction.

Conventions:

• matrices act on column vectors standing to the right of the matrix.
• Some software packages of this type attempt to provide many versions of the same method, for example, add(), which have different number of arguments depending on whether one of the arguments is re-used. This is not the policy here. Each such method typically exists in only one form. For example, in the case of add(), it has the form ` public static double[] add(double[] dst, double[]src1, double[] src2) ` . The operation is then given by ` dst = src1 + src2 `. Care has been taken to allow re-use of the same variable, for example, in the invocation ` Rn.add(a, a, a) ` which adds a vector a to itself and stores the result back into itself.
• Just as in the written form of the addition statement above, the destination array comes first in the argument list. This is true for every method which calculates a vector or matrix.
• These methods generally return this vector or matrix. This allows nested used of these methods; for example to add three vectors a,b,c together into a fourth d: ` Rn.add(d, c, Rn.add(null, a, b)) ` in the process.
• Methods return the computed vector or matrix, in general. It is in general possible to pass in a `null` value for the destination vector or matrix. The method itself in this case then allocates a new one, fills it accordingly, and returns it. Unless otherwise noted, this is the behavior of the static methods in this class.

Methods try as much as possible to react reasonably to differing argument types. In general, the methods check the lengths of the arguments, determine a minimum valid length on which the desired operation can be carried out, and does so. This allows some flexibility in terms of lengths of input vectors which the following paragraph attempts to justify on practical grounds.

For example. the method `matrixTimesVector(double[], double[], double[])` is happiest when the dimension of the square matrix matches the length of the input vectors. However, it is often the case that users have dehomogenized coordinates for vectors, that is, one dimension less than the dimension of the matrix. For example, points in Euclidean 3-space are naturally stored as 3-vectors although the natural setting for isometries is 4x4 matrices. In this case the method assumes an implicit final coordinate of 1.0 and carries out the multiplication accordingly. At the same time, the method also operates correctly on 4-vectors.

Some commonly used methods come in two varieties: one acts on single vectors (` double[] `) and another acts on array of vectors ( `double[][]`). Compare `matrixTimesVector(double[], double[], double[])` and `matrixTimesVector(double[][], double[], double[][])`.

Author:
Charles Gunn
`Pn`
• ### Field Summary

Fields
Modifier and Type Field and Description
`static double` `TOLERANCE`
The default tolerance used for checking numerical equality = 10E-8.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double[]` ```abs(double[] dst, double[] src)```
`static double[]` ```add(double[] dst, double[] src1, double[] src2)```
Add the vector src1 to the vector src2 and put the result in dst.
`static double[]` ```adjoint(double[] dst, double[] src)```
Calculate the adjoint of the square matrix src and put the result into dst.
`static double[]` ```average(double[] dst, double[][] vlist)```
Calculate the average of the elements in the vector list vlist.
`static double[]` ```barycentricTriangleInterp(double[] dst, double[][] corners, double[] weights)```
Calculate the euclidean coordinates of the point whose barycentric coordinates with respect to the triangle corners are coords.
`static double[]` ```bezierCombination(double[] dst, double t, double[] v0, double[] t0, double[] t1, double[] v1)```
`static double[]` ```bilinearInterpolation(double[] ds, double u, double v, double[] vb, double[] vt, double[] cb, double[] ct)```
`static double[][]` ```calculateBounds(double[][] bounds, double[][] vlist)```
Given a list of vectors, calculate the minimum and maximum values in each coordinate.
`static double` ```cofactor(double[] m, int row, int column)```
Calculate the (i,j)th cofactor of the matrix m The dimension of the matrix m can be no greater than 5.
`static double[][]` ```completeBasis(double[][] dst, double[][] partial)```
The array partial contains m n-vectors which are assumed to be linearly independent.
`static double[]` ```conjugateByMatrix(double[] dst, double[] m, double[] c)```
Form the conjugate of the matrix m by the matrix c: dst = c .
`static double[]` ```convertArray2DToArray1D(double[] target, double[][] src)```
inlines the given 2-dim array.
`static double[]` `convertArray3DToArray1D(double[][][] V)`
`static double[]` ```convertArray3DToArray1D(double[][][] V, int usample, int vsample)```
`static double[][]` `convertArray3DToArray2D(double[][][] V)`
`static float[]` `convertDoubleToFloatArray(double[] ds)`
`static double[]` ```copy(double[] dst, double[] src)```
Make a copy of src in dst.
`static double[]` ```crossProduct(double[] dst, double[] u, double[] v)```
Calculate the cross product of the two vectors u and v.
`static double` `determinant(double[] m)`
Calculate the determinate of the square matrix m.
`static double` `determinant(double[][] m)`
`static double[]` ```diagonalMatrix(double[] dst, double[] entries)```
`static boolean` ```equals(double[] u, double[] v)```
Calculate whether the two arrays contain exactly the same values.
`static boolean` ```equals(double[] u, double[] v, double tol)```
Calculate whether the two arrays contain the same values.
`static double` ```euclideanAngle(double[] u, double[] v)```
Calculate the euclidean angle between the vectors u and v.
`static double` ```euclideanDistance(double[] u, double[] v)```
Calculates and returns the euclidean distance between the two points u and v.
`static double` ```euclideanDistanceSquared(double[] u, double[] v)```
calculates and returns the square of the euclidean distance between the two points u and v.
`static double` `euclideanNorm(double[] vec)`
Calculates and returns the euclidean norm of the input vector.
`static double` `euclideanNormSquared(double[] vec)`
Calculates and returns the square of the euclidean norm of the input vector.
`static double[]` ```extractSubmatrix(double[] subm, double[] src, int l, int r, int t, int b)```
Extract a rectangular submatrix of the input matrix.
`static double[]` `identityMatrix(int dim)`
Create and return an identity matrix of dimension dim.
`static double` ```innerProduct(double[] u, double[] v)```
Calculate and return the euclidean inner product of the two vectors.
`static double` ```innerProduct(double[] u, double[] v, int n)```
Calculate and return at most n terms of the inner product of the two vectors.
`static double[]` ```inverse(double[] minvIn, double[] m)```
Use Gaussian pivoting to calculate the inverse matrix of the input matrix.
`static boolean` ```isIdentityMatrix(double[] mat, double tol)```
Calculates whether the input matrix in within tol of the identity matrix.
`static boolean` `isNan(double[] ds)`
`static boolean` ```isSpecialMatrix(double[] mat, double tol)```
Calculates whether the input matrix is within tol of being a "special" matrix.
`static boolean` `isZero(double[] iline)`
`static boolean` ```isZero(double[] iline, double tol)```
`static double[]` ```linearCombination(double[] dst, double a, double[] aVec, double b, double[] bVec)```
Calculate the linear combination dst = a*aVec + b*bVec.
`static double` `manhattanNorm(double[] vec)`
Calculate the "manhattan norm" of the input vector.
`static double` ```manhattanNormDistance(double[] u, double[] v)```
Calculate the "manhattan norm" distance between the two input vectors.
`static double[][]` ```matrixTimesVector(double[][] dst, double[] m, double[][] src)```
`static double[]` ```matrixTimesVector(double[] dst, double[] m, double[] src)```
Multiply the input vector src by the matrix m and put the result into dst.
`static String` `matrixToJavaString(double[] v)`
Like `matrixToString(double[])`, but formatted for direct insertion as java source code
`static String` `matrixToString(double[] m)`
Print the square matrix m into a string using default format from `String.format(java.lang.String, java.lang.Object[])` and return the string.
`static String` ```matrixToString(double[] m, String formatString)```
Print the square matrix m into a string using formatString and return the string.
`static double[]` ```max(double[] dst, double[] src1, double[] src2)```
Calculate the maximum of two vectors, coordinate-wise.
`static double` `maxNorm(double[] vec)`
Calculate the "max norm" of a vector.
`static double` ```maxNormDistance(double[] u, double[] v)```
Calculate the distance between two points based on the `"max norm"`.
`static double[]` ```min(double[] dst, double[] src1, double[] src2)```
Calculate the minimum of two vectors, coordinate-wise.
`static int` `mysqrt(int sq)`
Returns the square root of the `sq` parameter.
`static double[]` ```negate(double[] dst, double[] src)```
dst[i] = -src[i]
`static double[][]` ```normalize(double[][] dst, double[][] src)```
`static double[]` ```normalize(double[] dst, double[] src)```
Normalize src using the `euclidean norm`.
`static double[]` ```permutationMatrix(double[] dst, int[] perm)```
Calculate a permutation matrix which sends e(i) to e(perm[i])
`static double[]` ```planeParallelToPassingThrough(double[] plane, double[] ds, double[] ds2)```
`static double[]` ```polarDecompose(double[] q, double[] s, double[] m)```
`static double[]` ```projectOnto(double[] dst, double[] src, double[] fixed)```
Project orthogonally src onto fixed.
`static double[]` ```projectOntoComplement(double[] dst, double[] src, double[] fixed)```
Project src onto the orthogonal complement of fixed.
`static double[]` ```setDiagonalMatrix(double[] dst, double[] diag)```
Construct and return a diagonal matrix with the entries given by the vector diag.
`static double[]` ```setEuclideanNorm(double[] dst, double length, double[] src)```
Scale the vector to have the given length.
`static double[]` `setIdentityMatrix(double[] mat)`
Set the matrix to be the identity matrix.
`static float[]` `setIdentityMatrix(float[] mat)`
`static double[]` ```setToLength(double[] p1, double[] p12, double rad)```
`static double[]` ```setToValue(double[] dst, double val)```
Set the destination to vector to have constant value val.
`static double[]` ```setToValue(double[] dst, double x, double y)```
Initialize the 2-vector dst.
`static double[]` ```setToValue(double[] dst, double x, double y, double z)```
Initialize the 3-vector dst.
`static double[]` ```setToValue(double[] dst, double x, double y, double z, double w)```
Initialize the 4-vector dst.
`static double[]` ```submatrix(double[] subm, double[] m, int row, int column)```
Extract the submatrix gotten by deleting the given row and column.
`static double[][]` ```subtract(double[][] dst, double[][] src1, double[][] src2)```
`static double[]` ```subtract(double[] dst, double[] src1, double[] src2)```
dst[i] = src1[i] - src2[i]
`static void` ```swap(double[] u, double[] v)```
Swap the contents of the two vectors.
`static double[][]` ```times(double[][] dst, double factor, double[][] src)```
`static double[]` ```times(double[] dst, double[] src1, double[] src2)```
Multiply the square matrices according to the equation dst = src1 * src2 .
`static double[]` ```times(double[] dst, double factor, double[] src)```
Multiply the vector by the scalar value factor and put result into dst.
`static float[]` ```times(float[] dst, float[] src1, float[] src2)```
`static String` `toString(double[] v)`
Print the array v into a string using default format from `String.format(java.lang.String, java.lang.Object[])` and return the string.
`static String` `toString(double[][] v)`
A vectorized version of `toString(double[])`.
`static String` `toString(double[][][] v)`
`static String` ```toString(double[][] v, int n)```
`static String` ```toString(double[] v, String formatString)```
Print the array v into a string using formatString and return the string.
`static String` `toString(float[] v)`
`static double` `trace(double[] m)`
Calculate the trace of the given square matrix.
`static double[]` ```transpose(double[] dst, double[] src)```
Transpose the given square matrix src into dst.
`static float[]` ```transposeD2F(float[] dst, double[] src)```
Transpose the given 4x4 matrix src into dst .
`static double[]` ```transposeF2D(double[] dst, float[] src)```
Transpose the given 4x4 matrix src into dst .
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### TOLERANCE

`public static final double TOLERANCE`
The default tolerance used for checking numerical equality = 10E-8.
Constant Field Values
• ### Method Detail

• #### abs

```public static double[] abs(double[] dst,
double[] src)```
Parameters:
`ds` -
`ds2` -

```public static double[] add(double[] dst,
double[] src1,
double[] src2)```
Add the vector src1 to the vector src2 and put the result in dst.
Parameters:
`dst` -
`src1` -
`src2` -
Returns:
dst

```public static double[] adjoint(double[] dst,
double[] src)```
Calculate the adjoint of the square matrix src and put the result into dst. The adjoint of a matrix is a same-size matrix, whose (i,j)th entry is the determinant of the sub-matrix of the original matrix obtained by deleting the (i)th row and (j)th column. The dimension of the input matrix can be no greater than 4.
Parameters:
`dst` - may be null
`src` - may be = dst
Returns:
dst
• #### average

```public static double[] average(double[] dst,
double[][] vlist)```
Calculate the average of the elements in the vector list vlist.
Parameters:
`dst` -
`vlist` -
Returns:
• #### barycentricTriangleInterp

```public static double[] barycentricTriangleInterp(double[] dst,
double[][] corners,
double[] weights)```
Calculate the euclidean coordinates of the point whose barycentric coordinates with respect to the triangle corners are coords. This is just the weighted average of the corners of the triangle. Return the result in dst.
Parameters:
`dst` - double[n] (may be null)
`corners` - double[n]
`weights` - double
Returns:
• #### calculateBounds

```public static double[][] calculateBounds(double[][] bounds,
double[][] vlist)```
Given a list of vectors, calculate the minimum and maximum values in each coordinate. Return the result in bounds. For example bounds is the minimum y-value of the vectors in the list, etc.
Parameters:
`bounds` - double[n]
`vlist` - double[][n]
Returns:
• #### cofactor

```public static double cofactor(double[] m,
int row,
int column)```
Calculate the (i,j)th cofactor of the matrix m The dimension of the matrix m can be no greater than 5.
Parameters:
`m` - double[n][n]
`row` -
`column` -
Returns:
m
• #### conjugateByMatrix

```public static double[] conjugateByMatrix(double[] dst,
double[] m,
double[] c)```
Form the conjugate of the matrix m by the matrix c: dst = c . m . Inverse(c)
Parameters:
`dst` - double[n][n]
`m` - double[n][n]
`c` - double[n][n]
Returns:
dst
• #### convertArray2DToArray1D

```public static double[] convertArray2DToArray1D(double[] target,
double[][] src)```
inlines the given 2-dim array. Assumes equal length for sub-arrays
Returns:
the target array (a new one if target == null)
• #### convertArray3DToArray1D

`public static double[] convertArray3DToArray1D(double[][][] V)`
• #### convertArray3DToArray1D

```public static double[] convertArray3DToArray1D(double[][][] V,
int usample,
int vsample)```
Parameters:
`V` -
Returns:
• #### convertArray3DToArray2D

`public static double[][] convertArray3DToArray2D(double[][][] V)`
Parameters:
`V` -
Returns:
• #### convertDoubleToFloatArray

`public static float[] convertDoubleToFloatArray(double[] ds)`
• #### copy

```public static double[] copy(double[] dst,
double[] src)```
Make a copy of src in dst. The length of dst may be larger than that of src. Excess terms will be left.
Parameters:
`dst` -
`src` -
Returns:
• #### crossProduct

```public static double[] crossProduct(double[] dst,
double[] u,
double[] v)```
Calculate the cross product of the two vectors u and v. Note that the only valid dimension is 3.
Parameters:
`dst` - double
`u` - double
`v` - double
Returns:
dst
• #### determinant

`public static double determinant(double[] m)`
Calculate the determinate of the square matrix m. TODO: figure out how to generate the necessary permutations without having to recursively call submatrix()
Parameters:
`m` -
Returns:
• #### determinant

`public static double determinant(double[][] m)`
• #### equals

```public static boolean equals(double[] u,
double[] v)```
Calculate whether the two arrays contain exactly the same values. Returns true only if the `"manhattan norm"` of the difference of the two vectors does not exceed the default `tolerance`.
Parameters:
`u` - double[n]
`v` - double[n]
Returns:
`equals()`
• #### equals

```public static boolean equals(double[] u,
double[] v,
double tol)```
Calculate whether the two arrays contain the same values. Returns true only if the `"manhattan norm"` of the difference of the two vectors does not exceed the provided tol.
Parameters:
`u` - double[n]
`v` - double[n]
`tol` -
Returns:
• #### euclideanAngle

```public static double euclideanAngle(double[] u,
double[] v)```
Calculate the euclidean angle between the vectors u and v.
Parameters:
`u` -
`v` -
Returns:
• #### euclideanDistance

```public static double euclideanDistance(double[] u,
double[] v)```
Calculates and returns the euclidean distance between the two points u and v.
Parameters:
`u` -
`v` -
Returns:
• #### euclideanDistanceSquared

```public static double euclideanDistanceSquared(double[] u,
double[] v)```
calculates and returns the square of the euclidean distance between the two points u and v.
Parameters:
`u` - double[n]
`v` - double[n]
Returns:
• #### euclideanNorm

`public static double euclideanNorm(double[] vec)`
Calculates and returns the euclidean norm of the input vector.
Parameters:
`vec` - double[n]
Returns:
`innerProduct()`
• #### euclideanNormSquared

`public static double euclideanNormSquared(double[] vec)`
Calculates and returns the square of the euclidean norm of the input vector.
Parameters:
`vec` - double[n]
Returns:
• #### extractSubmatrix

```public static double[] extractSubmatrix(double[] subm,
double[] src,
int l,
int r,
int t,
int b)```
Extract a rectangular submatrix of the input matrix.
Parameters:
`subm` - double[b-t][r-l]
`src` - double[n][n]
`l` - begin with the lth column
`r` - and include the rth column
`t` - begin with the t-th row
`b` - and include the b-th row
Returns:
subm
• #### identityMatrix

`public static double[] identityMatrix(int dim)`
Create and return an identity matrix of dimension dim.
Parameters:
`dim` -
Returns:
• #### diagonalMatrix

```public static double[] diagonalMatrix(double[] dst,
double[] entries)```
• #### innerProduct

```public static double innerProduct(double[] u,
double[] v)```
Calculate and return the euclidean inner product of the two vectors. If they are of different lengths only evaluates the inner product on the lesser of the two lengths.
Parameters:
`u` -
`v` -
Returns:
• #### innerProduct

```public static double innerProduct(double[] u,
double[] v,
int n)```
Calculate and return at most n terms of the inner product of the two vectors. Useful when using homogenous coordinates but one wants to ignore the final coordinate.
Parameters:
`u` -
`v` -
Returns:
• #### inverse

```public static double[] inverse(double[] minvIn,
double[] m)```
Use Gaussian pivoting to calculate the inverse matrix of the input matrix. This method is safe when minvIn == m.
Parameters:
`minv` - double[n][n]
`m` - double[n][n]
Returns:
minv
• #### isIdentityMatrix

```public static boolean isIdentityMatrix(double[] mat,
double tol)```
Calculates whether the input matrix in within tol of the identity matrix.
Parameters:
`mat` -
`tol` -
Returns:
• #### isSpecialMatrix

```public static boolean isSpecialMatrix(double[] mat,
double tol)```
Calculates whether the input matrix is within tol of being a "special" matrix. To be exact, returns true if the absolute value of the determinant is within tol of 1.0.
Parameters:
`mat` -
`tol` -
Returns:
• #### linearCombination

```public static double[] linearCombination(double[] dst,
double a,
double[] aVec,
double b,
double[] bVec)```
Calculate the linear combination dst = a*aVec + b*bVec.
Parameters:
`dst` - double[n]
`a` -
`aVec` - double[n]
`b` -
`bVec` - double[n]
Returns:
• #### manhattanNorm

`public static double manhattanNorm(double[] vec)`
Calculate the "manhattan norm" of the input vector. This is the sum of the absolute values of the entries.
Parameters:
`vec` -
Returns:
• #### manhattanNormDistance

```public static double manhattanNormDistance(double[] u,
double[] v)```
Calculate the "manhattan norm" distance between the two input vectors.
Parameters:
`u` -
`v` -
Returns:
• #### matrixTimesVector

```public static double[] matrixTimesVector(double[] dst,
double[] m,
double[] src)```
Multiply the input vector src by the matrix m and put the result into dst. This method works correctly when the vectors are given using homogeneous or dehomogenous coordinates (but this must be consistent for both src and dst).
Parameters:
`dst` - double[n] (may be null)
`m` - double[n][n]
`src` - double[n]
Returns:
dst
• #### matrixTimesVector

```public static double[][] matrixTimesVector(double[][] dst,
double[] m,
double[][] src)```
Parameters:
`dst` - double[m][n] (may be null)
`m` - double[n][n]
`src` - double[m][n]
Returns:
dst
• #### matrixToJavaString

`public static String matrixToJavaString(double[] v)`
Like `matrixToString(double[])`, but formatted for direct insertion as java source code
Parameters:
`v` -
Returns:
• #### matrixToString

```public static String matrixToString(double[] m,
String formatString)```
Print the square matrix m into a string using formatString and return the string.
Parameters:
`m` -
`formatString` -
Returns:
`String.format(java.lang.String, java.lang.Object[])`
• #### max

```public static double[] max(double[] dst,
double[] src1,
double[] src2)```
Calculate the maximum of two vectors, coordinate-wise.
Parameters:
`dst` -
`src1` -
`src2` -
Returns:
• #### maxNorm

`public static double maxNorm(double[] vec)`
Calculate the "max norm" of a vector. That is the maximum of the absolute values of the entries.
Parameters:
`vec` -
Returns:
• #### maxNormDistance

```public static double maxNormDistance(double[] u,
double[] v)```
Calculate the distance between two points based on the `"max norm"`.
Parameters:
`u` -
`v` -
Returns:
• #### min

```public static double[] min(double[] dst,
double[] src1,
double[] src2)```
Calculate the minimum of two vectors, coordinate-wise.
Parameters:
`dst` -
`src1` -
`src2` -
Returns:
• #### negate

```public static double[] negate(double[] dst,
double[] src)```
dst[i] = -src[i]
Parameters:
`dst` -
`src` -
Returns:
• #### normalize

```public static double[] normalize(double[] dst,
double[] src)```
Normalize src using the `euclidean norm`.
Parameters:
`dst` -
`src` -
Returns:
• #### normalize

```public static double[][] normalize(double[][] dst,
double[][] src)```
Parameters:
`ds` -
• #### planeParallelToPassingThrough

```public static double[] planeParallelToPassingThrough(double[] plane,
double[] ds,
double[] ds2)```
Parameters:
`plane` -
`ds` -
`ds2` -
• #### polarDecompose

```public static double[] polarDecompose(double[] q,
double[] s,
double[] m)```
Parameters:
`q` -
`s` -
`m` -
Returns:
"Graphics Gems IV", p. 207 for details
• #### projectOnto

```public static double[] projectOnto(double[] dst,
double[] src,
double[] fixed)```
Project orthogonally src onto fixed.
Parameters:
`dst` -
`src` -
`fixed` -
Returns:
• #### projectOntoComplement

```public static double[] projectOntoComplement(double[] dst,
double[] src,
double[] fixed)```
Project src onto the orthogonal complement of fixed.
Parameters:
`dst` -
`src` -
`fixed` -
Returns:
• #### setDiagonalMatrix

```public static double[] setDiagonalMatrix(double[] dst,
double[] diag)```
Construct and return a diagonal matrix with the entries given by the vector diag. The number of entries of diag cannot be more than the dimension of the square matrix dst.
Parameters:
`dst` -
`diag` -
Returns:
• #### setEuclideanNorm

```public static double[] setEuclideanNorm(double[] dst,
double length,
double[] src)```
Scale the vector to have the given length.
Parameters:
`dst` -
`length` -
`src` -
Returns:
• #### setIdentityMatrix

`public static double[] setIdentityMatrix(double[] mat)`
Set the matrix to be the identity matrix.
Parameters:
`mat` -
Returns:
• #### setIdentityMatrix

`public static float[] setIdentityMatrix(float[] mat)`
• #### setToValue

```public static double[] setToValue(double[] dst,
double val)```
Set the destination to vector to have constant value val.
Parameters:
`dst` -
`val` -
Returns:
• #### setToValue

```public static double[] setToValue(double[] dst,
double x,
double y)```
Initialize the 2-vector dst.
Parameters:
`dst` -
`x` -
`y` -
Returns:
• #### setToValue

```public static double[] setToValue(double[] dst,
double x,
double y,
double z)```
Initialize the 3-vector dst.
Parameters:
`dst` -
`x` -
`y` -
`z` -
Returns:
• #### setToValue

```public static double[] setToValue(double[] dst,
double x,
double y,
double z,
double w)```
Initialize the 4-vector dst.
Parameters:
`dst` -
`x` -
`y` -
`z` -
`w` -
Returns:
• #### mysqrt

`public static int mysqrt(int sq)`
Returns the square root of the `sq` parameter. Will return very fast for square roots of 0 to 10.
Parameters:
`sq` -
Returns:
• #### submatrix

```public static double[] submatrix(double[] subm,
double[] m,
int row,
int column)```
Extract the submatrix gotten by deleting the given row and column.
Parameters:
`subm` - double[n-1 * n-1]
`m` - double[n*n]
`row` -
`column` -
Returns:
• #### subtract

```public static double[] subtract(double[] dst,
double[] src1,
double[] src2)```
dst[i] = src1[i] - src2[i]
Parameters:
`dst` -
`src1` -
`src2` -
Returns:
• #### subtract

```public static double[][] subtract(double[][] dst,
double[][] src1,
double[][] src2)```
• #### swap

```public static void swap(double[] u,
double[] v)```
Swap the contents of the two vectors.
Parameters:
`u` -
`v` -
• #### times

```public static double[] times(double[] dst,
double factor,
double[] src)```
Multiply the vector by the scalar value factor and put result into dst.
Parameters:
`dst` -
`factor` -
`src` -
Returns:
• #### times

```public static double[] times(double[] dst,
double[] src1,
double[] src2)```
Multiply the square matrices according to the equation dst = src1 * src2 . This operation is overwrite-safe; that is, it gives correct results when src1=dst or src2=dst.
Parameters:
`dst` - double[n*n] may be null
`src1` - double[n*n]
`src2` - double[n*n]
Returns:
• #### times

```public static double[][] times(double[][] dst,
double factor,
double[][] src)```
Parameters:
`dst` -
`factor` -
`src` -
Returns:
• #### toString

`public static String toString(double[][] v)`
A vectorized version of `toString(double[])`.
Parameters:
`v` -
Returns:
• #### toString

```public static String toString(double[][] v,
int n)```
• #### toString

`public static String toString(double[][][] v)`
• #### toString

`public static String toString(float[] v)`
• #### trace

`public static double trace(double[] m)`
Calculate the trace of the given square matrix.
Parameters:
`m` -
Returns:
• #### transpose

```public static double[] transpose(double[] dst,
double[] src)```
Transpose the given square matrix src into dst. This operation is overwrite-safe; that is, it gives correct results when src=dst.
Parameters:
`dst` -
`src` -
Returns:
• #### transposeD2F

```public static float[] transposeD2F(float[] dst,
double[] src)```
Transpose the given 4x4 matrix src into dst .
converts from `double` to `float`. This is useful for hooking up to GL libraries, for example.
Parameters:
`dst` -
`src` -
Returns:
• #### transposeF2D

```public static double[] transposeF2D(double[] dst,
float[] src)```
Transpose the given 4x4 matrix src into dst .
converts from `float` to `double`.
Parameters:
`dst` -
`src` -
Returns:
• #### bilinearInterpolation

```public static double[] bilinearInterpolation(double[] ds,
double u,
double v,
double[] vb,
double[] vt,
double[] cb,
double[] ct)```
• #### bezierCombination

```public static double[] bezierCombination(double[] dst,
double t,
double[] v0,
double[] t0,
double[] t1,
double[] v1)```
• #### isNan

`public static boolean isNan(double[] ds)`
• #### setToLength

```public static double[] setToLength(double[] p1,
double[] p12,
• #### completeBasis

```public static double[][] completeBasis(double[][] dst,
double[][] partial)```
The array partial contains m n-vectors which are assumed to be linearly independent. The destination array dst is calculated so that it extends partial with n-m n-vectors, each of which is orthogonal to all elements of partial as well as to each other. That is, if partial is an orthogonal sub-basis, then dst will also be.
Parameters:
`dst` - double[n][n]
`partial` - double[m][n]
Returns:
• #### permutationMatrix

```public static double[] permutationMatrix(double[] dst,
int[] perm)```
Calculate a permutation matrix which sends e(i) to e(perm[i])
Parameters:
`dst` -
`perm` -
Returns:
• #### isZero

`public static boolean isZero(double[] iline)`
• #### isZero

```public static boolean isZero(double[] iline,
double tol)```
• #### times

```public static float[] times(float[] dst,
float[] src1,
float[] src2)```