mikera.matrixx
Class Matrix33
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<AVector>
-
- mikera.matrixx.AMatrix
-
- mikera.matrixx.impl.APrimitiveMatrix
-
- mikera.matrixx.Matrix33
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, IMatrix, ISpecialisedTransform
public final class Matrix33 extends APrimitiveMatrix implements ISpecialisedTransform
Specialised 3*3 Matrix for Vector3 maths, using primitive matrix elements- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description doublem00doublem01doublem02doublem10doublem11doublem12doublem20doublem21doublem22
-
Constructor Summary
Constructors Constructor and Description Matrix33()Create a new (zero-initialised) 3x3 MatrixMatrix33(AMatrix m)Matrix33(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)Matrix33(Matrix33 source)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)intcheckSquare()Checks if a matrix is square.Matrix33clone()Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original.intcolumnCount()Gets the number of columns in this matrix (dimension 1)voidcopyRowTo(int row, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arraystatic Matrix33createIdentityMatrix()static Matrix33createScaleMatrix(double d)doubledeterminant()Calculates the determinant of the matrix.doublediagonalProduct()Computes the product of entries on the main diagonal of a matrixlongelementCount()Returns the total number of elements in this array.booleanequals(Matrix33 m)booleanequals(java.lang.Object o)Matrix33exactClone()Creates a deep clone of an array, using the same class implementation as the original arraydoubleget(int row, int column)Returns the double value at the specified position in a 2D matrixvoidgetElements(double[] data, int offset)Copies all elements of this array a double array at the specified offsetVector3getRowClone(int row)Returns a row of the matrix as a cloned vectorMatrix33getTranspose()Returns the transpose of this array.AMatrixinnerProduct(AMatrix a)Computes the inner product of this matrix with another.AVectorinnerProduct(AVector a)Computes the inner product of this array with a vectorMatrix33innerProduct(Matrix33 a)Vector3innerProduct(Vector3 a)Matrix33inverse()Computes the inverse of a matrix.booleanisSymmetric()Returns true if a matrix is symmetricbooleanisZero()Returns true if the matrix is the zero matrix (all components zero)voidmultiply(double factor)Multiplies all elements of the array in place by a given double valueintrowCount()Gets the number of rows in this matrix (dimension 0)voidset(int row, int column, double value)Sets a value at a given position in a mutable 2D arrayAffine34toAffineTransform()double[]toDoubleArray()Copies the elements of this array to a new double[] array.doubletrace()Computes the trace of a matrix, i.e.voidtransform(AVector source, AVector dest)Transforms a source vector into a destination vector, using matrix multiplication (inner product).Vector3transform(Vector3 source)voidtransform(Vector3 source, AVector dest)voidtransform(Vector3 source, Vector3 dest)voidtransformInPlace(AVector dest)voidtransformInPlace(Vector3 dest)voidtransformNormal(AVector source, AVector dest)voidtransformNormal(Vector3 source, Vector3 dest)-
Methods inherited from class mikera.matrixx.impl.APrimitiveMatrix
copy, getColumn, getRow, isFullyMutable, isSquare
-
Methods inherited from class mikera.matrixx.AMatrix
abs, add, add, add, add, add2, addAt, addCopy, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addOuterProduct, addOuterProduct, addOuterProductSparse, addOuterProductSparse, addRowMultiple, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, bandIndex, bandLength, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, checkColumn, checkRow, clamp, composeWith, copyColumnTo, dense, denseClone, dimensionality, divide, divide, divide, divide, divideCopy, elementIterator, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equalsArray, equalsTranspose, exp, fill, get, get, get, get, getBand, getBandWrapped, getColumnClone, getColumns, getColumnView, getElement, getLeadingDiagonal, getLongShape, getRows, getRowView, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTransposeCopy, getTransposeView, hashCode, hasOrthonormalColumns, hasOrthonormalRows, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, isBoolean, isDiagonal, isElementConstrained, isHermitian, isIdentity, isInvertible, isLowerTriangular, isMutable, isOrthogonal, isOrthogonal, isPositiveDefinite, isRectangularDiagonal, isSameShape, isSameShape, isUpperTriangular, isView, iterator, join, log, lowerBandwidth, lowerBandwidthLimit, mul, multiply, multiply, multiply, multiplyCopy, multiplyRow, mutable, negate, nonZeroCount, outerProduct, outputDimensions, pow, rank, reciprocal, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, replaceColumn, replaceRow, reshape, reshape, rotateView, rowDotProduct, scaleAdd, scaleAdd, set, set, set, set, set, set, set, set, setApplyOp, setApplyOp, setColumn, setElements, setElements, setMultiple, setMultiple, setMultiple, setMultiple, setMultiple, setRow, setSparse, setSparse, signum, slice, slice, sliceCount, sparse, sparseClone, sqrt, square, sub, sub, sub, subArray, subCopy, subMatrix, swapColumns, swapRows, toDoubleBuffer, toMatrix, toMatrixTranspose, toMutableMatrix, toNestedDoubleArrays, toSliceArray, toString, toStringFull, toVector, transform, transformInPlace, transposeInnerProduct, transposeInnerProduct, transposeInPlace, unsafeGet, unsafeSet, upperBandwidth, upperBandwidthLimit, validate
-
Methods inherited from class mikera.arrayz.impl.AbstractArray
absCopy, absDiff, absDiffCopy, add, addApplyOp, addAt, addCopy, addInnerProduct, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, compareTo, componentCount, density, divideCopy, elementAbsPowSum, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, epsilonEquals, equals, equalsArray, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, isSparse, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, setSparse, signumCopy, sliceValue, squareCopy, sub, sub, subCopy, withComponents
-
Methods inherited from interface mikera.arrayz.INDArray
absCopy, absDiff, absDiffCopy, addApplyOp, addAt, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, componentCount, divideCopy, elementAbsPowSum, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, epsilonEquals, equalsArray, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, isSparse, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, setSparse, signumCopy, sliceValue, squareCopy, sub, subCopy, withComponents
-
-
-
-
Field Detail
-
m00
public double m00
-
m01
public double m01
-
m02
public double m02
-
m10
public double m10
-
m11
public double m11
-
m12
public double m12
-
m20
public double m20
-
m21
public double m21
-
m22
public double m22
-
-
Constructor Detail
-
Matrix33
public Matrix33()
Create a new (zero-initialised) 3x3 Matrix
-
Matrix33
public Matrix33(Matrix33 source)
-
Matrix33
public Matrix33(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
-
Matrix33
public Matrix33(AMatrix m)
-
-
Method Detail
-
determinant
public double determinant()
Description copied from class:AMatrixCalculates the determinant of the matrix.- Overrides:
determinantin classAMatrix
-
elementCount
public long elementCount()
Description copied from interface:INDArrayReturns the total number of elements in this array. Equivalent to the product of all dimension sizes.- Specified by:
elementCountin interfaceINDArray- Overrides:
elementCountin classAMatrix
-
multiply
public void multiply(double factor)
Description copied from interface:INDArrayMultiplies all elements of the array in place by a given double value
-
rowCount
public int rowCount()
Description copied from interface:IMatrixGets the number of rows in this matrix (dimension 0)
-
columnCount
public int columnCount()
Description copied from interface:IMatrixGets the number of columns in this matrix (dimension 1)- Specified by:
columnCountin interfaceIMatrix- Returns:
-
checkSquare
public int checkSquare()
Description copied from class:AMatrixChecks if a matrix is square. Returns the size if true, throws an exception otherwise;- Specified by:
checkSquarein classAPrimitiveMatrix- Returns:
-
get
public double get(int row, int column)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
set
public void set(int row, int column, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 2D array
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)
-
innerProduct
public AMatrix innerProduct(AMatrix a)
Description copied from interface:IMatrixComputes the inner product of this matrix with another. Equivalent to matrix x matrix multiplication- Specified by:
innerProductin interfaceIMatrix- Overrides:
innerProductin classAMatrix- Returns:
-
innerProduct
public AVector innerProduct(AVector a)
Description copied from interface:INDArrayComputes the inner product of this array with a vector- Specified by:
innerProductin interfaceINDArray- Specified by:
innerProductin interfaceIMatrix- Overrides:
innerProductin classAMatrix- Parameters:
a- A vector- Returns:
- A new array representing the inner product
-
transform
public void transform(AVector source, AVector dest)
Description copied from interface:IMatrixTransforms a source vector into a destination vector, using matrix multiplication (inner product). The destination vector is overwritten.
-
transformInPlace
public void transformInPlace(AVector dest)
- Specified by:
transformInPlacein interfaceIMatrix- Overrides:
transformInPlacein classAMatrix
-
transformInPlace
public void transformInPlace(Vector3 dest)
-
isSymmetric
public boolean isSymmetric()
Description copied from class:AMatrixReturns true if a matrix is symmetric- Specified by:
isSymmetricin interfaceIMatrix- Overrides:
isSymmetricin classAMatrix- Returns:
-
toAffineTransform
public Affine34 toAffineTransform()
- Overrides:
toAffineTransformin classAMatrix
-
getTranspose
public Matrix33 getTranspose()
Description copied from interface:INDArrayReturns the transpose of this array. A transpose of an array is equivalent to reversing the order of dimensions. May or may not return a view depending on the array type.- Specified by:
getTransposein interfaceINDArray- Specified by:
getTransposein interfaceIMatrix- Overrides:
getTransposein classAMatrix- Returns:
- the transpose of this matrix
-
getRowClone
public Vector3 getRowClone(int row)
Returns a row of the matrix as a cloned vector- Specified by:
getRowClonein interfaceIMatrix- Overrides:
getRowClonein classAMatrix
-
copyRowTo
public void copyRowTo(int row, double[] dest, int destOffset)Description copied from class:AMatrixCopies the elements in a selected row of this matrix to a double array
-
inverse
public Matrix33 inverse()
Description copied from class:AMatrixComputes the inverse of a matrix. Returns null if the matrix is singular. Throws an Exception is the matrix is not square
-
trace
public double trace()
Description copied from interface:IMatrixComputes the trace of a matrix, i.e. the sum of all elements on the leading diagonal
-
diagonalProduct
public double diagonalProduct()
Description copied from class:AMatrixComputes the product of entries on the main diagonal of a matrix- Specified by:
diagonalProductin interfaceIMatrix- Overrides:
diagonalProductin classAMatrix- Returns:
-
clone
public Matrix33 clone()
Description copied from interface:INDArrayReturns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original. Clone should attempt to return the most efficient possible array type. Clone should preserve sparsity property where possible, but this is not guaranteed.
-
toDoubleArray
public double[] toDoubleArray()
Description copied from interface:INDArrayCopies the elements of this array to a new double[] array.- Specified by:
toDoubleArrayin interfaceINDArray- Overrides:
toDoubleArrayin classAMatrix
-
exactClone
public Matrix33 exactClone()
Description copied from interface:INDArrayCreates a deep clone of an array, using the same class implementation as the original array- Specified by:
exactClonein interfaceINDArray- Specified by:
exactClonein classAMatrix- Returns:
- A clone of the original array
-
getElements
public void getElements(double[] data, int offset)Description copied from interface:INDArrayCopies all elements of this array a double array at the specified offset- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAMatrix
-
equals
public boolean equals(Matrix33 m)
-
createIdentityMatrix
public static Matrix33 createIdentityMatrix()
-
createScaleMatrix
public static Matrix33 createScaleMatrix(double d)
-
-
DMelt 3.0 © DataMelt by jWork.ORG