當前位置: 首頁>>代碼示例>>Java>>正文


Java UJMPSettings類代碼示例

本文整理匯總了Java中org.ujmp.core.util.UJMPSettings的典型用法代碼示例。如果您正苦於以下問題:Java UJMPSettings類的具體用法?Java UJMPSettings怎麽用?Java UJMPSettings使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UJMPSettings類屬於org.ujmp.core.util包,在下文中一共展示了UJMPSettings類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pinv

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public Matrix pinv(int k) {
	Matrix[] usv = svd(k);
	Matrix u = usv[0];
	Matrix s = usv[1];
	Matrix v = usv[2];

	for (int i = (int) Math.min(s.getRowCount(), s.getColumnCount()); --i >= 0;) {
		double d = s.getAsDouble(i, i);
		if (Math.abs(d) > UJMPSettings.getInstance().getTolerance()) {
			s.setAsDouble(1.0 / d, i, i);
		} else {
			s.setAsDouble(0.0, i, i);
		}
	}

	return v.mtimes(s.transpose()).mtimes(u.transpose());
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:18,代碼來源:AbstractMatrix.java

示例2: tanh

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public Matrix tanh() {
	final int rows = MathUtil.longToInt(getRowCount());
	final int cols = MathUtil.longToInt(getColumnCount());
	final Matrix result = Matrix.Factory.zeros(rows, cols);
	if (UJMPSettings.getInstance().getNumberOfThreads() > 1 && rows >= 100 && cols >= 100) {
		new PForEquidistant(0, rows - 1) {
			public void step(int i) {
				for (int c = 0; c < cols; c++) {
					result.setAsDouble(Math.tanh(getAsDouble(i, c)), i, c);
				}
			}
		};
	} else {
		for (int r = 0; r < rows; r++) {
			for (int c = 0; c < cols; c++) {
				result.setAsDouble(Math.tanh(getAsDouble(r, c)), r, c);
			}
		}
	}
	return result;
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:22,代碼來源:AbstractMatrix.java

示例3: getDouble

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public double getDouble(long... coordinates) {
	if (pinv == null) {

		Matrix[] usv = getSource().svd();
		Matrix u = usv[0];
		Matrix s = usv[1];
		Matrix v = usv[2];

		for (int i = (int) Math.min(s.getRowCount(), s.getColumnCount()); --i >= 0;) {
			double d = s.getAsDouble(i, i);
			if (Math.abs(d) > UJMPSettings.getInstance().getTolerance()) {
				s.setAsDouble(1.0 / d, i, i);
			} else {
				s.setAsDouble(0.0, i, i);
			}
		}

		pinv = v.mtimes(s.transpose()).mtimes(u.transpose());

	}
	return pinv.getAsDouble(coordinates);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:23,代碼來源:Pinv.java

示例4: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix[] calc(Matrix source) {
	QR<Matrix> qr = null;
	if (UJMPSettings.getInstance().isUseOjalgo()) {
		qr = DecompositionOps.QR_OJALGO;
	}
	if (qr == null && UJMPSettings.getInstance().isUseEJML()) {
		qr = DecompositionOps.QR_EJML;
	}
	if (qr == null && UJMPSettings.getInstance().isUseMTJ()) {
		qr = DecompositionOps.QR_MTJ;
	}
	if (qr == null) {
		qr = UJMP;
	}
	return qr.calc(source);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:17,代碼來源:QR.java

示例5: solve

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix solve(Matrix source, Matrix b) {
	QR<Matrix> qr = null;
	if (UJMPSettings.getInstance().isUseOjalgo()) {
		qr = DecompositionOps.QR_OJALGO;
	}
	if (qr == null && UJMPSettings.getInstance().isUseEJML()) {
		qr = DecompositionOps.QR_EJML;
	}
	if (qr == null && UJMPSettings.getInstance().isUseMTJ()) {
		qr = DecompositionOps.QR_MTJ;
	}
	if (qr == null) {
		qr = UJMP;
	}
	return qr.solve(source, b);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:17,代碼來源:QR.java

示例6: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix calc(Matrix source) {
	if (source.getDimensionCount() != 2 || source.getRowCount() != source.getColumnCount()) {
		throw new RuntimeException(
				"inverse only possible for square matrices. use pinv or ginv instead");
	}
	if (UJMPSettings.getInstance().getNumberOfThreads() == 1) {
		if (source.getRowCount() >= THRESHOLD && source.getColumnCount() >= THRESHOLD) {
			return MATRIXLARGESINGLETHREADED.calc(source);
		} else {
			return MATRIXSMALLSINGLETHREADED.calc(source);
		}
	} else {
		if (source.getRowCount() >= THRESHOLD && source.getColumnCount() >= THRESHOLD) {
			return MATRIXLARGEMULTITHREADED.calc(source);
		} else {
			return MATRIXSMALLMULTITHREADED.calc(source);
		}
	}
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:20,代碼來源:InvSymm.java

示例7: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix[] calc(Matrix source) {
	SVD<Matrix> svd = null;
	if (UJMPSettings.getInstance().isUseMTJ()) {
		svd = DecompositionOps.SVD_MTJ;
	}
	if (svd == null && UJMPSettings.getInstance().isUseOjalgo()) {
		svd = DecompositionOps.SVD_OJALGO;
	}
	if (svd == null && UJMPSettings.getInstance().isUseEJML()) {
		svd = DecompositionOps.SVD_EJML;
	}
	if (svd == null) {
		svd = UJMP;
	}
	return svd.calc(source);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:17,代碼來源:SVD.java

示例8: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix calc(Matrix a, Matrix b) {
	SolveSPD<Matrix> solve = null;
	if (UJMPSettings.getInstance().isUseJBlas()) {
		solve = DecompositionOps.SOLVESPD_JBLAS;
	}
	if (solve == null && UJMPSettings.getInstance().isUseOjalgo()) {
		solve = DecompositionOps.SOLVESPD_OJALGO;
	}
	if (solve == null && UJMPSettings.getInstance().isUseEJML()) {
		solve = DecompositionOps.SOLVESPD_EJML;
	}
	if (solve == null && UJMPSettings.getInstance().isUseMTJ()) {
		solve = DecompositionOps.SOLVESPD_MTJ;
	}
	if (solve == null) {
		solve = UJMPSQUARE;
	}
	return solve.calc(a, b);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:20,代碼來源:SolveSPD.java

示例9: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix calc(Matrix a, Matrix b) {
	// no special implementation for symmetric matrices
	Solve<Matrix> solve = null;
	if (UJMPSettings.getInstance().isUseJBlas()) {
		solve = DecompositionOps.SOLVE_JBLAS;
	}
	if (solve == null && UJMPSettings.getInstance().isUseOjalgo()) {
		solve = DecompositionOps.SOLVE_OJALGO;
	}
	if (solve == null && UJMPSettings.getInstance().isUseEJML()) {
		solve = DecompositionOps.SOLVE_EJML;
	}
	if (solve == null && UJMPSettings.getInstance().isUseMTJ()) {
		solve = DecompositionOps.SOLVE_MTJ;
	}
	if (solve == null) {
		solve = UJMPSQUARE;
	}
	return solve.calc(a, b);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:21,代碼來源:SolveSymm.java

示例10: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public Matrix[] calc(Matrix source) {
	Eig<Matrix> eig = null;
	if (UJMPSettings.getInstance().isUseJBlas()) {
		eig = DecompositionOps.EIG_JBLAS;
	}
	if (eig == null && UJMPSettings.getInstance().isUseOjalgo()) {
		eig = DecompositionOps.EIG_OJALGO;
	}
	if (eig == null && UJMPSettings.getInstance().isUseEJML()) {
		eig = DecompositionOps.EIG_EJML;
	}
	if (eig == null) {
		eig = UJMP;
	}
	return eig.calc(source);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:17,代碼來源:Eig.java

示例11: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final Matrix calc(Matrix a, Matrix b) {
	Solve<Matrix> solve = null;
	if (UJMPSettings.getInstance().isUseJBlas()) {
		solve = DecompositionOps.SOLVE_JBLAS;
	}
	if (solve == null && UJMPSettings.getInstance().isUseOjalgo()) {
		solve = DecompositionOps.SOLVE_OJALGO;
	}
	if (solve == null && UJMPSettings.getInstance().isUseEJML()) {
		solve = DecompositionOps.SOLVE_EJML;
	}
	if (solve == null && UJMPSettings.getInstance().isUseMTJ()) {
		solve = DecompositionOps.SOLVE_MTJ;
	}
	if (solve == null) {
		solve = UJMPSQUARE;
	}
	return solve.calc(a, b);
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:20,代碼來源:Solve.java

示例12: BlockDenseDoubleMatrix2D

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
/**
 * Create a new matrix with the specified size, and specified block stripe
 * size.
 * 
 * @param rows
 *            - number of rows of the matrix.
 * @param cols
 *            - number of columns of the matrix.
 * @param blockStripeSize
 *            - length of one side of a square block.
 * @throws IllegalArgumentException
 *             if rows, cols or blockStripeSize are 0 or less, or blockOrder
 *             is null.
 */
public BlockDenseDoubleMatrix2D(final int rows, final int cols, final int blockStripeSize,
		final BlockOrder blockOrder) {
	super(rows, cols);
	verifyTrue(rows > 0, "rows<=0");
	verifyTrue(cols > 0, "cols<=0");
	verifyTrue(blockStripeSize > 0, "blockStripeSize<=0");
	verifyTrue(blockOrder != null, "blockOrder == null");

	if (UJMPSettings.getInstance().getNumberOfThreads() != 1) {
		System.err.println("WARNING: setting number of threads to 1 for BlockMatrix");
		UJMPSettings.getInstance().setNumberOfThreads(1);
	}

	this.size = new long[] { rows, cols };

	// layout structure for the blocks in the matrix
	this.layout = new BlockMatrixLayout(rows, cols, blockStripeSize, blockOrder);

	this.data = new double[this.layout.numberOfBlocks][];
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:35,代碼來源:BlockDenseDoubleMatrix2D.java

示例13: download

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public static void download(URL url, OutputStream output) throws IOException {
	URLConnection connection = url.openConnection();
	connection.setRequestProperty("User-Agent", UJMPSettings.getInstance().getUserAgent());
	connection.setUseCaches(false);
	connection.setDoInput(true);
	connection.setDoOutput(true);
	connection.setConnectTimeout(3000);

	InputStream input = connection.getInputStream();
	byte[] buffer = new byte[8192];
	int n = -1;
	while ((n = input.read(buffer)) != -1) {
		if (n > 0) {
			output.write(buffer, 0, n);
		}
	}
	output.flush();
	input.close();
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:20,代碼來源:HttpUtil.java

示例14: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final void calc(final Matrix source, final double factor, final Matrix target) {
	if (source instanceof DenseMatrix && target instanceof DenseMatrix) {
		TimesScalar.DENSEMATRIX.calc((DenseMatrix) source, factor, (DenseMatrix) target);
	} else if (source instanceof SparseMatrix && target instanceof SparseMatrix) {
		TimesScalar.SPARSEMATRIX.calc((SparseMatrix) source, factor, (SparseMatrix) target);
	} else {
		calc(source, new BigDecimal(factor, UJMPSettings.getInstance().getMathContext()),
				target);
	}
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:11,代碼來源:TimesScalar.java

示例15: calc

import org.ujmp.core.util.UJMPSettings; //導入依賴的package包/類
public final void calc(final Matrix source, final double value, final Matrix target) {
	if (source instanceof DenseMatrix && target instanceof DenseMatrix) {
		PlusScalar.DENSEMATRIX.calc((DenseMatrix) source, value, (DenseMatrix) target);
	} else if (source instanceof SparseMatrix && target instanceof SparseMatrix) {
		PlusScalar.SPARSEMATRIX.calc((SparseMatrix) source, value, (SparseMatrix) target);
	} else {
		calc(source, new BigDecimal(value, UJMPSettings.getInstance().getMathContext()), target);
	}
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:10,代碼來源:PlusScalar.java


注:本文中的org.ujmp.core.util.UJMPSettings類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。