Java Code Examples for cern.colt.matrix.DoubleMatrix2D#size()

The following examples show how to use cern.colt.matrix.DoubleMatrix2D#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Algebra.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the Frobenius norm of matrix <tt>A</tt>, which is <tt>Sqrt(Sum(A[i,j]<sup>2</sup>))</tt>.
 */
public double normF(DoubleMatrix2D A) {
	if (A.size()==0) return 0;
	return A.aggregate(hypotFunction(),cern.jet.math.Functions.identity);
}
 
Example 2
Source File: Property.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the matrix's fraction of non-zero cells; <tt>A.cardinality() / A.size()</tt>.
 */
public double density(DoubleMatrix2D A) {
	return A.cardinality() / (double) A.size();
}
 
Example 3
Source File: ScanningAlgorithm.java    From CFGScanDroid with GNU General Public License v2.0 4 votes vote down vote up
public static SparseDoubleMatrix2D checkIncestConditionParents(	DoubleMatrix2D signatureNodeIncestVector,
																DoubleMatrix2D functionNodeIncestVector,
																SparseDoubleMatrix2D signatureAdjacencyMatrix, 
																SparseDoubleMatrix2D functionAdjacencyMatrix,
																int[] signatureDepths,
																int[] functionDepths,
																int depth,
																SparseDoubleMatrix2D candidateList) {

	SparseDoubleMatrix2D signatureSelector = new SparseDoubleMatrix2D(1, signatureDepths.length);
	SparseDoubleMatrix2D functionSelector = new SparseDoubleMatrix2D(1, functionDepths.length);

	for(int i=0; i<signatureNodeIncestVector.size(); ++i) {
		if(signatureNodeIncestVector.get(0, i) == 0.0)
			continue;

		signatureSelector.assign(0.0);
		signatureSelector.set(0, i, 1.0);

		DoubleMatrix2D signatureNodeParentVector = Algebra.DEFAULT.mult(signatureSelector, Algebra.DEFAULT.transpose(signatureAdjacencyMatrix));

		// only bipartite match on incest parents
		for(int iParent = 0; iParent < signatureNodeParentVector.columns(); ++iParent) {
			if(signatureNodeParentVector.get(0, iParent) > 0 && signatureDepths[iParent] != depth) {
				signatureNodeParentVector.set(0, iParent, 0.0);
			}
		}

		int signatureIncestParentCount = signatureNodeParentVector.cardinality();

		for(int j=0; j<functionNodeIncestVector.size(); ++j) {
			if(candidateList.get(i, j) == 0.0)
				continue;

			functionSelector.assign(0.0);
			functionSelector.set(0, j, 1.0);

			DoubleMatrix2D functionNodeParentVector = Algebra.DEFAULT.mult(functionSelector, Algebra.DEFAULT.transpose(functionAdjacencyMatrix));

			// only bipartite match on incest parents
			for(int iParent = 0; iParent < functionNodeParentVector.columns(); ++iParent) {
				if(functionNodeParentVector.get(0, iParent) > 0 && functionDepths[iParent] != depth) {
					functionNodeParentVector.set(0, iParent, 0.0);
				}
			}

			int functionIncestParentCount = functionNodeParentVector.cardinality();

			// bipartite matching, if !sufficient
			if(	candidateList.get(i, j) > 0 && (signatureIncestParentCount > functionIncestParentCount ||
				!bipartiteMatchingVector(candidateList, signatureNodeParentVector, functionNodeParentVector, signatureDepths, functionDepths))) {
				// remove candidacy
				candidateList.set(i, j, 0.0);
			}
		}
	}

	return candidateList;
}
 
Example 4
Source File: Algebra.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Returns the Frobenius norm of matrix <tt>A</tt>, which is <tt>Sqrt(Sum(A[i,j]<sup>2</sup>))</tt>.
 */
public double normF(DoubleMatrix2D A) {
	if (A.size()==0) return 0;
	return A.aggregate(hypotFunction(),cern.jet.math.Functions.identity);
}
 
Example 5
Source File: Property.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Returns the matrix's fraction of non-zero cells; <tt>A.cardinality() / A.size()</tt>.
 */
public double density(DoubleMatrix2D A) {
	return A.cardinality() / (double) A.size();
}
 
Example 6
Source File: Formatter.java    From database with GNU General Public License v2.0 3 votes vote down vote up
/**
Returns a string representation of the given matrix with axis as well as rows and columns labeled.
Pass <tt>null</tt> to one or more parameters to indicate that the corresponding decoration element shall not appear in the string converted matrix.

@param matrix The matrix to format.
@param rowNames The headers of all rows (to be put to the left of the matrix).
@param columnNames The headers of all columns (to be put to above the matrix).
@param rowAxisName The label of the y-axis.
@param columnAxisName The label of the x-axis.
@param title The overall title of the matrix to be formatted.
@return the matrix converted to a string.
*/
protected String toTitleString(DoubleMatrix2D matrix, String[] rowNames, String[] columnNames, String rowAxisName, String columnAxisName, String title) {
	if (matrix.size()==0) return "Empty matrix";
	String[][] s = format(matrix);
	//String oldAlignment = this.alignment;
	//this.alignment = DECIMAL;
	align(s);
	//this.alignment = oldAlignment;
	return new cern.colt.matrix.objectalgo.Formatter().toTitleString(cern.colt.matrix.ObjectFactory2D.dense.make(s), rowNames,columnNames,rowAxisName,columnAxisName,title);
}
 
Example 7
Source File: Formatter.java    From jAudioGIT with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
Returns a string representation of the given matrix with axis as well as rows and columns labeled.
Pass <tt>null</tt> to one or more parameters to indicate that the corresponding decoration element shall not appear in the string converted matrix.

@param matrix The matrix to format.
@param rowNames The headers of all rows (to be put to the left of the matrix).
@param columnNames The headers of all columns (to be put to above the matrix).
@param rowAxisName The label of the y-axis.
@param columnAxisName The label of the x-axis.
@param title The overall title of the matrix to be formatted.
@return the matrix converted to a string.
*/
protected String toTitleString(DoubleMatrix2D matrix, String[] rowNames, String[] columnNames, String rowAxisName, String columnAxisName, String title) {
	if (matrix.size()==0) return "Empty matrix";
	String[][] s = format(matrix);
	//String oldAlignment = this.alignment;
	//this.alignment = DECIMAL;
	align(s);
	//this.alignment = oldAlignment;
	return new cern.colt.matrix.objectalgo.Formatter().toTitleString(cern.colt.matrix.ObjectFactory2D.dense.make(s), rowNames,columnNames,rowAxisName,columnAxisName,title);
}