Apply a transform to {@code boundingBox}.

@param boundingBox
The {@link BoundingBox} to apply the transform to.
@param matrix
The transformation matrix to apply.
@return The transformed {@code BoundingBox}.
764590
private BoundingBox transform(BoundingBox boundingBox, Matrix4f matrix) {
        boundingBox.clear();
        if (boundingBox.mVertices != null) {
            for (Vector3f v : boundingBox.mVertices) {
                v.mulPosition(matrix);
                boundingBox.expand(v);
            }
        }
        return boundingBox;
    }
19991
public Bbox transform(Matrix t) {
		Coordinate c1 = transform(t, new Coordinate(x, y));
		Coordinate c2 = transform(t, new Coordinate(x + width, y + height));
		Coordinate origin = new Coordinate(Math.min(c1.getX(), c2.getX()), Math.min(c1.getY(), c2.getY()));
		Coordinate endPoint = new Coordinate(Math.max(c1.getX(), c2.getX()), Math.max(c1.getY(), c2.getY()));
		return new Bbox(origin.getX(), origin.getY(), endPoint.getX() - origin.getX(), endPoint.getY() - origin.getY());
	}
895786
public static DenseMatrix matrix(double[][] A) {
        if (nlmatrixZeros != null) {
            try {
                return (DenseMatrix) nlmatrixArray2D.newInstance((Object) A);
            } catch (Exception e) {
                logger.error("Failed to call NLMatrix(double[][]): {}", e);
            }
        }

        return new JMatrix(A);
    }
896885
public Matrix getMatrix(int i0, int i1, int[] c)
    {
        Matrix X = new Matrix(i1 - i0 + 1, c.length);
        double[][] B = X.getArray();
        try
        {
            for (int i = i0; i <= i1; i++)
            {
                for (int j = 0; j < c.length; j++)
                {
                    B[i - i0][j] = A[i][c[j]];
                }
            }
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            throw new ArrayIndexOutOfBoundsException("Submatrix indices");
        }
        return X;
    }
109844
public Matrix3x2d set(Matrix3x2dc m) {
        if (m instanceof Matrix3x2d) {
            MemUtil.INSTANCE.copy((Matrix3x2d) m, this);
        } else {
            setMatrix3x2dc(m);
        }
        return this;
    }
950269
public BoundingBox projectBoundingBox(BoundingBox boundingBox,
			Projection projection) {
		ProjectionTransform projectionTransform = projection
				.getTransformation(getProjection());
		BoundingBox projectedBoundingBox = boundingBox
				.transform(projectionTransform);
		return projectedBoundingBox;
	}
1187267
public BoundingBox getBoundingBox(Projection projection) {
        ProjectionTransform webMercatorToProjection = ProjectionFactory
                .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR)
                .getTransformation(projection);
        return webMercatorBoundingBox
                .transform(webMercatorToProjection);
    }
796322
public static void matrixFill(Object[][] matrix, Object val) {
        if (matrix != null) {
            for (int i = 0, n = matrix.length; i < n; i++) {
                if (matrix[i] != null) {
                    for (int j = 0, m = matrix[i].length; j < m; j++) {
                        matrix[i][j] = val;
                    }
                }
            }
        }
    }
179082
public static DMatrix2 extractRow( DMatrix2x2 a , int row , DMatrix2 out ) {
        if( out == null) out = new DMatrix2();
        switch( row ) {
            case 0:
                out.a1 = a.a11;
                out.a2 = a.a12;
            break;
            case 1:
                out.a1 = a.a21;
                out.a2 = a.a22;
            break;
            default:
                throw new IllegalArgumentException("Out of bounds row.  row = "+row);
        }
        return out;
    }
543395
public void addMatrix(double[][] m) {
    assert (m.length == dim);
    assert (m[0].length == dim);

    // reset inverse transformation - needs recomputation.
    inv = null;

    // extend the matrix with an extra row and column
    double[][] ht = new double[dim + 1][dim + 1];
    for(int i = 0; i < dim; i++) {
      for(int j = 0; j < dim; j++) {
        ht[i][j] = m[i][j];
      }
    }
    // the other cells default to identity matrix
    ht[dim][dim] = 1.0;
    // Multiply from left.
    trans = times(ht, trans);
  }
83796
function (matrix) {

        var attributes = this.attributes;
        var positions = attributes.position.value;
        var normals = attributes.normal.value;
        var tangents = attributes.tangent.value;

        matrix = matrix.array;
        // Normal Matrix
        var inverseTransposeMatrix = mat4.create();
        mat4.invert(inverseTransposeMatrix, matrix);
        mat4.transpose(inverseTransposeMatrix, inverseTransposeMatrix);

        var vec3TransformMat4 = vec3.transformMat4;
        var vec3ForEach = vec3.forEach;
        vec3ForEach(positions, 3, 0, null, vec3TransformMat4, matrix);
        if (normals) {
            vec3ForEach(normals, 3, 0, null, vec3TransformMat4, inverseTransposeMatrix);
        }
        if (tangents) {
            vec3ForEach(tangents, 4, 0, null, vec3TransformMat4, inverseTransposeMatrix);
        }

        if (this.boundingBox) {
            this.updateBoundingBox();
        }
    }
716087
public void setMatrix(int[] matrix) {
		this.matrix = matrix;
		sum = 0;
		for (int i = 0; i < matrix.length; i++)
			sum += matrix[i];
	}
57859
protected static HyperBoundingBox computeBounds(NumberVector[] samples) {
    assert(samples.length > 0) : "Cannot compute bounding box of empty set.";
    // Compute bounds:
    final int dimensions = samples[0].getDimensionality();
    final double[] min = new double[dimensions];
    final double[] max = new double[dimensions];
    NumberVector first = samples[0];
    for(int d = 0; d < dimensions; d++) {
      min[d] = max[d] = first.doubleValue(d);
    }
    for(int i = 1; i < samples.length; i++) {
      NumberVector v = samples[i];
      for(int d = 0; d < dimensions; d++) {
        final double c = v.doubleValue(d);
        min[d] = c < min[d] ? c : min[d];
        max[d] = c > max[d] ? c : max[d];
      }
    }
    return new HyperBoundingBox(min, max);
  }
464262
public static DenseDoubleMatrix2D inverse(final double[][] matrix) {
		double epsilon = UJMPSettings.getInstance().getTolerance();
		int rows = matrix.length;
		int cols = matrix[0].length;
		double[][] s = new double[cols][cols];
		for (int c = 0; c < cols; c++) {
			s[c][c] = 1.0;
		}
		final double[][] t = new double[rows][rows];
		for (int r = 0; r < rows; r++) {
			t[r][r] = 1.0;
		}
		int maxDiag = Math.min(rows, cols);

		int diag = 0;
		for (; diag < maxDiag; diag++) {

			// get the largest value for the pivot
			swapPivot(matrix, diag, s, t);

			if (matrix[diag][diag] == 0.0) {
				break;
			}

			// divide through to make pivot identity
			double divisor = matrix[diag][diag];
			if (Math.abs(divisor) < epsilon) {
				matrix[diag][diag] = 0.0;
				break;
			}

			divideRowBy(matrix, diag, diag, divisor);
			divideRowBy(t, diag, 0, divisor);
			matrix[diag][diag] = 1.0;

			// remove values down remaining rows
			for (int row = diag + 1; row < rows; row++) {
				double factor = matrix[row][diag];
				if (factor != 0.0) {
					addRowTimes(matrix, diag, diag, row, factor);
					addRowTimes(t, diag, 0, row, factor);
					matrix[row][diag] = 0.0;
				}
			}

			// remove values across remaining cols - some optimization could
			// be done here because the changes to the original matrix at this
			// point only touch the current diag column
			for (int col = diag + 1; col < cols; col++) {
				double factor = matrix[diag][col];
				if (factor != 0.0) {
					addColTimes(matrix, diag, diag, col, factor);
					addColTimes(s, diag, 0, col, factor);
					matrix[diag][col] = 0.0;
				}
			}
		}

		double[][] result = times(s, t, diag);
		return new ArrayDenseDoubleMatrix2D(result);
	}
842881
public static DMatrix3 extractRow( DMatrix3x3 a , int row , DMatrix3 out ) {
        if( out == null) out = new DMatrix3();
        switch( row ) {
            case 0:
                out.a1 = a.a11;
                out.a2 = a.a12;
                out.a3 = a.a13;
            break;
            case 1:
                out.a1 = a.a21;
                out.a2 = a.a22;
                out.a3 = a.a23;
            break;
            case 2:
                out.a1 = a.a31;
                out.a2 = a.a32;
                out.a3 = a.a33;
            break;
            default:
                throw new IllegalArgumentException("Out of bounds row.  row = "+row);
        }
        return out;
    }
808943
public static final DoubleMatrix2D invert2x2Matrix(DoubleMatrix2D A) throws Exception{
		if(2!=A.rows() || A.rows() != A.columns()){
			throw new IllegalArgumentException("matrix is not 2x2");
		}
		//ad - bc
		double s = A.getQuick(0, 0)*A.getQuick(1, 1)-A.getQuick(0, 1)*A.getQuick(1, 0);
		if(Math.abs(s) < 1.e-16){
			throw new Exception("Matrix is singular");
		}
		DoubleMatrix2D ret = new DenseDoubleMatrix2D(2, 2);
		ret.setQuick(0, 0, A.getQuick(1, 1) / s);
		ret.setQuick(1, 1, A.getQuick(0, 0) / s);
		ret.setQuick(0, 1, -A.getQuick(1, 0) / s);
		ret.setQuick(1, 0, A.getQuick(0, 1) / s);
		return ret;
	}
1077736
public static double[][] transpose(double[][] matrix){

		//Get number of rows and columns of matrix
		int numberOfRows = matrix.length;
		int numberOfCols = matrix[0].length;

		//Instantiate a unitMatrix of dimension dim
		double[][] transpose = new double[numberOfCols][numberOfRows];

		//Create unit matrix
		for(int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {
			for(int colIndex = 0; colIndex < numberOfCols; colIndex++) {
				transpose[colIndex][rowIndex] = matrix[rowIndex][colIndex];
			}
		}
		return transpose;
	}