本文整理了Java中org.opengis.referencing.operation.Matrix.getElement()
方法的一些代码示例,展示了Matrix.getElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.getElement()
方法的具体详情如下:
包路径:org.opengis.referencing.operation.Matrix
类名称:Matrix
方法名:getElement
[英]Retrieves the value at the specified row and column of this matrix.
[中]检索此矩阵指定行和列的值。
代码示例来源:origin: geotools/geotools
/**
* Creates a new matrix initialized to the same value than the specified one. The specified
* matrix size must be {@value #SIZE}×{@value #SIZE}.
*/
public Matrix2(final Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = matrix.getElement(0, 0);
m01 = matrix.getElement(0, 1);
m10 = matrix.getElement(1, 0);
m11 = matrix.getElement(1, 1);
}
代码示例来源:origin: geotools/geotools
@Override
public void invert(Matrix matrix) throws SingularMatrixException {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
if (matrix.getElement(0, 0) == 0) {
throw new SingularMatrixException("1 dimensional matrix is singular");
}
m00 = 1.0 / matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
/**
* Creates a new matrix initialized to the same value than the specified one. The specified
* matrix size must be {@value #SIZE}×{@value #SIZE}.
*/
public Matrix1(final Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void negate(Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = -matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void mul(Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 *= matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void sub(Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 -= matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void mul(Matrix matrix1, Matrix matrix2) {
if (matrix1.getNumRow() != SIZE || matrix1.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
if (matrix2.getNumRow() != SIZE || matrix2.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = matrix1.getElement(0, 0) * matrix2.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void transpose(Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
/** {@inheritDoc} */
public final void multiply(final Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 *= matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void mul(double scalar, Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = scalar * matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void sub(double scalar, Matrix matrix) {
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = scalar - matrix.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
@Override
public void sub(Matrix matrix1, Matrix matrix2) {
if (matrix1.getNumRow() != SIZE || matrix1.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
if (matrix2.getNumRow() != SIZE || matrix2.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
m00 = matrix1.getElement(0, 0) - matrix2.getElement(0, 0);
}
}
代码示例来源:origin: geotools/geotools
/**
* Constructs a transform from the specified matrix. The matrix should be affine, but it will
* not be verified.
*
* @param matrix The matrix.
*/
protected ProjectiveTransform(final Matrix matrix) {
numRow = matrix.getNumRow();
numCol = matrix.getNumCol();
elt = new double[numRow * numCol];
int index = 0;
for (int j = 0; j < numRow; j++) {
for (int i = 0; i < numCol; i++) {
elt[index++] = matrix.getElement(j, i);
}
}
}
代码示例来源:origin: geotools/geotools
/**
* Creates a new matrix initialized to the same value than the specified one. The specified
* matrix size must be {@value #SIZE}×{@value #SIZE}.
*/
public Matrix4(final Matrix matrix) {
super(SIZE);
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
for (int j = 0; j < SIZE; j++) {
for (int i = 0; i < SIZE; i++) {
setElement(j, i, matrix.getElement(j, i));
}
}
}
代码示例来源:origin: geotools/geotools
/** Gets the derivative of this function at a value. */
public double derivative(final double value) throws TransformException {
final DirectPosition1D p = new DirectPosition1D(value);
final Matrix m = derivative(p);
assert m.getNumRow() == 1 && m.getNumCol() == 1;
return m.getElement(0, 0);
}
代码示例来源:origin: geotools/geotools
/**
* Creates a new matrix initialized to the same value than the specified one. The specified
* matrix size must be {@value #SIZE}×{@value #SIZE}.
*/
public Matrix3(final Matrix matrix) {
mat = new DMatrix3x3();
if (matrix.getNumRow() != SIZE || matrix.getNumCol() != SIZE) {
throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE));
}
for (int j = 0; j < SIZE; j++) {
for (int i = 0; i < SIZE; i++) {
setElement(j, i, matrix.getElement(j, i));
}
}
}
/**
代码示例来源:origin: geotools/geotools
/**
* Cast (or convert) Matrix to internal DMatrixRMaj representation required for CommonOps_DDRM.
*
* @param matrix
* @return
*/
private DMatrixRMaj internal(Matrix matrix) {
if (matrix instanceof GeneralMatrix) {
return ((GeneralMatrix) matrix).mat;
} else {
DMatrixRMaj a = new DMatrixRMaj(matrix.getNumRow(), matrix.getNumCol());
for (int j = 0; j < a.numRows; j++) {
for (int i = 0; i < a.numCols; i++) {
a.set(j, i, matrix.getElement(j, i));
}
}
return a;
}
}
代码示例来源:origin: geotools/geotools
/** Asserts that the specified matrix is diagonal. */
private static void assertDiagonal(final Matrix matrix) {
final int nrow = matrix.getNumRow();
final int ncol = matrix.getNumCol();
for (int j = 0; j < nrow; j++) {
for (int i = 0; i < ncol; i++) {
if (i != j) {
assertEquals("row " + j + ", col " + i, 0.0, matrix.getElement(j, i), EPS);
}
}
}
}
}
代码示例来源:origin: geotools/geotools
/**
* Constructs a new matrix and copies the initial values from the parameter matrix.
*
* @param matrix The matrix to copy.
*/
public GeneralMatrix(final Matrix matrix) {
if (matrix instanceof GeneralMatrix) {
mat = new DMatrixRMaj(((GeneralMatrix) matrix).mat);
} else {
mat = new DMatrixRMaj(matrix.getNumRow(), matrix.getNumCol());
final int height = getNumRow();
final int width = getNumCol();
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
mat.set(j, i, matrix.getElement(j, i));
}
}
}
}
代码示例来源:origin: geotools/geotools
@Override
public void invert(Matrix matrix) throws SingularMatrixException {
DMatrixRMaj a;
if (matrix instanceof GeneralMatrix) {
a = new DMatrixRMaj(((GeneralMatrix) matrix).mat);
} else {
a = new DMatrixRMaj(matrix.getNumRow(), matrix.getNumCol());
for (int j = 0; j < mat.numRows; j++) {
for (int i = 0; i < mat.numCols; i++) {
mat.set(j, i, matrix.getElement(j, i));
}
}
}
boolean success = CommonOps_DDRM.invert(a);
if (!success) {
throw new SingularMatrixException("Could not invert, possible singular matrix?");
}
this.mat = a;
}
内容来源于网络,如有侵权,请联系作者删除!