当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.transpose方法代码示例

本文整理汇总了Java中org.ujmp.core.Matrix.transpose方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.transpose方法的具体用法?Java Matrix.transpose怎么用?Java Matrix.transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ujmp.core.Matrix的用法示例。


在下文中一共展示了Matrix.transpose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transposeAnnotation

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public static MapMatrix<String, Object> transposeAnnotation(MapMatrix<String, Object> aorig,
		long[] newSize, int swap1, int swap2) {

	if (aorig != null) {
		MapMatrix<String, Object> a = new DefaultMapMatrix<String, Object>(
				new TreeMap<String, Object>());
		a.put(Matrix.LABEL, aorig.get(Matrix.LABEL));
		for (int i = 0; i < newSize.length; i++) {
			Matrix am = (Matrix) aorig.get(Matrix.DIMENSIONMETADATA + i);
			if (am != null) {
				am = am.transpose(Ret.NEW, swap1, swap2);
				if (i == swap1) {
					a.put(Matrix.DIMENSIONMETADATA + swap2, am);
				} else if (i == swap2) {
					a.put(Matrix.DIMENSIONMETADATA + swap1, am);
				} else {
					a.put(Matrix.DIMENSIONMETADATA + i, am);
				}
			}
		}
		return a;
	}
	return null;
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:25,代码来源:Transpose.java

示例2: testCholPascalSmall

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testCholPascalSmall() throws Exception {
	Matrix pascal = Matrix.Factory.pascal(5, 5);
	Matrix a = createMatrixWithAnnotation(pascal);

	if (!isSupported(a, MatrixLibraries.CHOL, MatrixLayout.SQUARE, Size.SMALL, null)) {
		return;
	}

	Matrix chol = a.chol();
	Matrix cholTrans = chol.transpose();
	Matrix prod = chol.mtimes(cholTrans);
	Matrix diff = prod.minus(a);

	assertEquals(getLabel(), 0.0, diff.getRMS(), TOLERANCE);

	if (a instanceof Erasable) {
		((Erasable) a).erase();
	}
	if (prod instanceof Erasable) {
		((Erasable) prod).erase();
	}
	if (diff instanceof Erasable) {
		((Erasable) diff).erase();
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:27,代码来源:AbstractMatrixTest.java

示例3: calculateObjects

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public Map<String, Object> calculateObjects(Map<String, Object> input) {
	Map<String, Object> result = new HashMap<String, Object>();

	Matrix weight = MathUtil.getMatrix(input.get(SOURCE1));
	Matrix contactdeviation = MathUtil.getMatrix(input.get(SOURCE2));

	Matrix transposedWeight = weight.transpose();
	Matrix target = transposedWeight.mtimes(contactdeviation);

	// ignore bias
	switch (biasType) {
	case SINGLE:
		target = target.subMatrix(Ret.NEW, 0, 0, target.getRowCount() - 2, 0);
		break;
	case MULTIPLE:
		target = target.subMatrix(Ret.NEW, 0, 0, target.getRowCount() / 2 - 1, 0);
		break;
	case NONE:
		break;
	}

	result.put(TARGET, target);

	return result;
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:26,代码来源:DimmingFunction.java

示例4: main

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		// create a dense empty matrix with 4 rows and 4 columns
		Matrix dense = DenseMatrix.Factory.zeros(4, 4);

		// set entry at row 2 and column 3 to the value 5.0
		dense.setAsDouble(5.0, 2, 3);

		// set some other values
		dense.setAsDouble(1.0, 0, 0);
		dense.setAsDouble(3.0, 1, 1);
		dense.setAsDouble(4.0, 2, 2);
		dense.setAsDouble(-2.0, 3, 3);
		dense.setAsDouble(-2.0, 1, 3);

		// print the final matrix on the console
		System.out.println(dense);

		// create a sparse empty matrix with 4 rows and 4 columns
		Matrix sparse = SparseMatrix.Factory.zeros(4, 4);
		sparse.setAsDouble(2.0, 0, 0);

		// basic calculations
		Matrix transpose = dense.transpose();
		Matrix sum = dense.plus(sparse);
		Matrix difference = dense.minus(sparse);
		Matrix matrixProduct = dense.mtimes(sparse);
		Matrix scaled = dense.times(2.0);

		Matrix inverse = dense.inv();
		Matrix pseudoInverse = dense.pinv();
		double determinant = dense.det();

		Matrix[] singularValueDecomposition = dense.svd();
		Matrix[] eigenValueDecomposition = dense.eig();
		Matrix[] luDecomposition = dense.lu();
		Matrix[] qrDecomposition = dense.qr();
		Matrix choleskyDecomposition = dense.chol();

	}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:41,代码来源:QuickStart.java

示例5: testSparseTranspose

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testSparseTranspose() throws Exception {
	Matrix m = createMatrix(2, 2);
	if (isTestSparse() && m.isSparse()) {
		m = createMatrix(800000, 900000);
		m.setAsDouble(1, 3, 4);
		m.setAsDouble(1, 334534, 4454);
		assertEquals(1.0, m.getAsDouble(3, 4), TOLERANCE);
		assertEquals(1.0, m.getAsDouble(334534, 4454), TOLERANCE);
		m = m.transpose();
		assertEquals(1.0, m.getAsDouble(4, 3), TOLERANCE);
		assertEquals(1.0, m.getAsDouble(4454, 334534), TOLERANCE);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:15,代码来源:AbstractMatrixTest.java

示例6: testTransposeSmall

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testTransposeSmall() throws Exception {
	// TODO: check labels
	Matrix m = createMatrixWithAnnotation(2, 3);
	m.setAsDouble(1.0, 0, 0);
	m.setAsDouble(2.0, 0, 1);
	m.setAsDouble(3.0, 0, 2);
	m.setAsDouble(4.0, 1, 0);
	m.setAsDouble(5.0, 1, 1);
	m.setAsDouble(6.0, 1, 2);
	Matrix r = m.transpose();
	assertEquals(getLabel(), m.getRowCount(), r.getColumnCount());
	assertEquals(getLabel(), m.getColumnCount(), r.getRowCount());
	assertEquals(getLabel(), 1.0, r.getAsDouble(0, 0), TOLERANCE);
	assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
	assertEquals(getLabel(), 2.0, r.getAsDouble(1, 0), TOLERANCE);
	assertEquals(getLabel(), 5.0, r.getAsDouble(1, 1), TOLERANCE);
	assertEquals(getLabel(), 3.0, r.getAsDouble(2, 0), TOLERANCE);
	assertEquals(getLabel(), 6.0, r.getAsDouble(2, 1), TOLERANCE);

	assertEquals(getLabel(), 1.0, m.getAsDouble(0, 0), TOLERANCE);
	assertEquals(getLabel(), 2.0, m.getAsDouble(0, 1), TOLERANCE);
	assertEquals(getLabel(), 3.0, m.getAsDouble(0, 2), TOLERANCE);
	assertEquals(getLabel(), 4.0, m.getAsDouble(1, 0), TOLERANCE);
	assertEquals(getLabel(), 5.0, m.getAsDouble(1, 1), TOLERANCE);
	assertEquals(getLabel(), 6.0, m.getAsDouble(1, 2), TOLERANCE);

	if (m instanceof Erasable) {
		((Erasable) m).erase();
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:32,代码来源:AbstractMatrixTest.java

示例7: testTransposeLarge

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testTransposeLarge() throws Exception {
	if (!isTestLarge()) {
		return;
	}
	// TODO: check labels
	Matrix m = createMatrixWithAnnotation(111, 101);
	m.setAsDouble(1.0, 0, 0);
	m.setAsDouble(2.0, 0, 1);
	m.setAsDouble(3.0, 0, 2);
	m.setAsDouble(4.0, 1, 0);
	m.setAsDouble(5.0, 1, 1);
	m.setAsDouble(6.0, 1, 2);
	Matrix r = m.transpose();
	assertEquals(getLabel(), m.getRowCount(), r.getColumnCount());
	assertEquals(getLabel(), m.getColumnCount(), r.getRowCount());
	assertEquals(getLabel(), 1.0, r.getAsDouble(0, 0), TOLERANCE);
	assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
	assertEquals(getLabel(), 2.0, r.getAsDouble(1, 0), TOLERANCE);
	assertEquals(getLabel(), 5.0, r.getAsDouble(1, 1), TOLERANCE);
	assertEquals(getLabel(), 3.0, r.getAsDouble(2, 0), TOLERANCE);
	assertEquals(getLabel(), 6.0, r.getAsDouble(2, 1), TOLERANCE);

	if (m instanceof Erasable) {
		((Erasable) m).erase();
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:28,代码来源:AbstractMatrixTest.java

示例8: testTransposeNewSmall

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testTransposeNewSmall() throws Exception {
	Matrix m = createMatrixWithAnnotation(2, 3);
	m.setAsDouble(1.0, 0, 0);
	m.setAsDouble(2.0, 0, 1);
	m.setAsDouble(3.0, 0, 2);
	m.setAsDouble(4.0, 1, 0);
	m.setAsDouble(5.0, 1, 1);
	m.setAsDouble(6.0, 1, 2);
	m.setLabel("label");
	m.setRowLabel(1, "row1");
	m.setColumnLabel(2, "col2");
	Matrix r = m.transpose(Ret.NEW);
	assertEquals(getLabel(), m.getRowCount(), r.getColumnCount());
	assertEquals(getLabel(), m.getColumnCount(), r.getRowCount());
	assertEquals(getLabel(), 1.0, r.getAsDouble(0, 0), TOLERANCE);
	assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
	assertEquals(getLabel(), 2.0, r.getAsDouble(1, 0), TOLERANCE);
	assertEquals(getLabel(), 5.0, r.getAsDouble(1, 1), TOLERANCE);
	assertEquals(getLabel(), 3.0, r.getAsDouble(2, 0), TOLERANCE);
	assertEquals(getLabel(), 6.0, r.getAsDouble(2, 1), TOLERANCE);
	assertEquals(getLabel(), "label", r.getLabel());
	assertEquals(getLabel(), "row1", r.getColumnLabel(1));
	assertEquals(getLabel(), "col2", r.getRowLabel(2));

	if (m instanceof Erasable) {
		((Erasable) m).erase();
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:30,代码来源:AbstractMatrixTest.java

示例9: testTransposeLinkSmall

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public final void testTransposeLinkSmall() throws Exception {
	Matrix m = createMatrixWithAnnotation(2, 3);
	m.setAsDouble(1.0, 0, 0);
	m.setAsDouble(2.0, 0, 1);
	m.setAsDouble(3.0, 0, 2);
	m.setAsDouble(4.0, 1, 0);
	m.setAsDouble(5.0, 1, 1);
	m.setAsDouble(6.0, 1, 2);
	m.setLabel("label");
	m.setRowLabel(1, "row1");
	m.setColumnLabel(2, "col2");
	Matrix r = m.transpose(Ret.LINK);
	assertEquals(getLabel(), m.getRowCount(), r.getColumnCount());
	assertEquals(getLabel(), m.getColumnCount(), r.getRowCount());
	assertEquals(getLabel(), 1.0, r.getAsDouble(0, 0), TOLERANCE);
	assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
	assertEquals(getLabel(), 2.0, r.getAsDouble(1, 0), TOLERANCE);
	assertEquals(getLabel(), 5.0, r.getAsDouble(1, 1), TOLERANCE);
	assertEquals(getLabel(), 3.0, r.getAsDouble(2, 0), TOLERANCE);
	assertEquals(getLabel(), 6.0, r.getAsDouble(2, 1), TOLERANCE);
	assertEquals(getLabel(), "label", r.getLabel());
	assertEquals(getLabel(), "row1", r.getColumnLabel(1));
	assertEquals(getLabel(), "col2", r.getRowLabel(2));

	if (m instanceof Erasable) {
		((Erasable) m).erase();
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:30,代码来源:AbstractMatrixTest.java

示例10: testStringTranspose

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public void testStringTranspose() {
	Matrix m1 = new DefaultDenseStringMatrix2D(2, 1);
	m1.setAsString("string1", 0, 0);
	m1.setAsString("string2", 1, 0);
	Matrix m2 = m1.transpose();
	assertEquals("string1", m2.getAsString(0, 0));
	assertEquals("string2", m2.getAsString(0, 1));
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:10,代码来源:TestDefaultDenseStringMatrix2D.java

示例11: testTransposeSmallSquare

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public void testTransposeSmallSquare() throws Exception {
	Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(10, 10);
	Matrix ref2 = ref1.transpose(Ret.LINK);

	for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
		Matrix m1 = getMatrix(mclass, ref1);
		Matrix m2 = m1.transpose();
		assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:12,代码来源:TestCompareMatrices.java

示例12: testTransposeSmallTall

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public void testTransposeSmallTall() throws Exception {
	Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(15, 10);
	Matrix ref2 = ref1.transpose(Ret.LINK);

	for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
		Matrix m1 = getMatrix(mclass, ref1);
		Matrix m2 = m1.transpose();
		assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:12,代码来源:TestCompareMatrices.java

示例13: testTransposeSmallWide

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public void testTransposeSmallWide() throws Exception {
	Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(10, 15);
	Matrix ref2 = ref1.transpose(Ret.LINK);

	for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
		Matrix m1 = getMatrix(mclass, ref1);
		Matrix m2 = m1.transpose();
		assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:12,代码来源:TestCompareMatrices.java

示例14: testTransposeLargeSquare

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public void testTransposeLargeSquare() throws Exception {
	Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 101);
	Matrix ref2 = ref1.transpose(Ret.LINK);

	for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
		Matrix m1 = getMatrix(mclass, ref1);
		Matrix m2 = m1.transpose();
		assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:12,代码来源:TestCompareMatrices.java

示例15: testTransposeLargeTall

import org.ujmp.core.Matrix; //导入方法依赖的package包/类
@Test
public void testTransposeLargeTall() throws Exception {
	Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100);
	Matrix ref2 = ref1.transpose(Ret.LINK);

	for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
		Matrix m1 = getMatrix(mclass, ref1);
		Matrix m2 = m1.transpose();
		assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:12,代码来源:TestCompareMatrices.java


注:本文中的org.ujmp.core.Matrix.transpose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。