Java Code Examples for cern.colt.matrix.DoubleMatrix1D#aggregate()

The following examples show how to use cern.colt.matrix.DoubleMatrix1D#aggregate() . 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: CPLSAIAFactorizationModelFactory.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Normalizes matrix of p(i|z) such that \forall_z: \sum_i p(i|z) = 1.
 *
 * @param piz normalized matrix of p(i|z)
 */
@Override
protected void normalizePiz(DoubleMatrix2D piz) {
    for (int i = 0; i < piz.columns(); i++) {
        DoubleMatrix1D tmp = piz.viewColumn(i);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
Example 2
Source File: Algebra.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns the infinity norm of vector <tt>x</tt>, which is <tt>Max(abs(x[i]))</tt>.
 */
public double normInfinity(DoubleMatrix1D x) {
	// fix for bug reported by [email protected]
	if (x.size()==0) return 0;
	return x.aggregate(cern.jet.math.Functions.max ,cern.jet.math.Functions.abs);
//	if (x.size()==0) return 0;
//	return x.aggregate(cern.jet.math.Functions.plus,cern.jet.math.Functions.abs);
//	double max = 0;
//	for (int i = x.size(); --i >= 0; ) {
//		max = Math.max(max, x.getQuick(i));
//	}
//	return max;
}
 
Example 3
Source File: Algebra.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the infinity norm of vector <tt>x</tt>, which is <tt>Max(abs(x[i]))</tt>.
 */
public double normInfinity(DoubleMatrix1D x) {
	// fix for bug reported by [email protected]
	if (x.size()==0) return 0;
	return x.aggregate(cern.jet.math.Functions.max ,cern.jet.math.Functions.abs);
//	if (x.size()==0) return 0;
//	return x.aggregate(cern.jet.math.Functions.plus,cern.jet.math.Functions.abs);
//	double max = 0;
//	for (int i = x.size(); --i >= 0; ) {
//		max = Math.max(max, x.getQuick(i));
//	}
//	return max;
}
 
Example 4
Source File: PLSAIAFactorizationModelFactory.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Normalizes matrix of p(i|z) such that \forall_z: \sum_i p(i|z) = 1.
 *
 * @param piz normalized matrix of p(i|z)
 */
@Override
protected void normalizePiz(DoubleMatrix2D piz) {
    for (int i = 0; i < piz.columns(); i++) {
        DoubleMatrix1D tmp = piz.viewColumn(i);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
Example 5
Source File: PLSAIAFactorizationModelFactory.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Normalizes matrix of p(z|u) such that \forall_u: \sum_z p(z|u) = 1.
 *
 * @param pu_z normalized matrix of p(z|u)
 */
@Override
protected void normalizePuz(DoubleMatrix2D pu_z) {
    for (int u = 0; u < pu_z.rows(); u++) {
        DoubleMatrix1D tmp = pu_z.viewRow(u);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
Example 6
Source File: CPLSAIAFactorizationModelFactory.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Normalizes matrix of p(z|u) such that \forall_u: \sum_z p(z|u) = 1.
 *
 * @param pu_z normalized matrix of p(z|u)
 */
@Override
protected void normalizePuz(DoubleMatrix2D pu_z) {
    for (int u = 0; u < pu_z.rows(); u++) {
        DoubleMatrix1D tmp = pu_z.viewRow(u);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
Example 7
Source File: Statistic.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.plus, F.chain(F.abs,F.minus)) / a.aggregate(b, F.plus, F.plus);
}
 
Example 8
Source File: Statistic.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.plus, fun);
}
 
Example 9
Source File: Statistic.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.max, F.chain(F.abs,F.minus));
}
 
Example 10
Source File: Statistic.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.plus, F.chain(F.abs,F.minus));
}
 
Example 11
Source File: Algebra.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the one-norm of vector <tt>x</tt>, which is <tt>Sum(abs(x[i]))</tt>.
 */
public double norm1(DoubleMatrix1D x) {
	if (x.size()==0) return 0;
	return x.aggregate(cern.jet.math.Functions.plus,cern.jet.math.Functions.abs);
}
 
Example 12
Source File: SeqBlas.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public double dasum(DoubleMatrix1D x) {
	return x.aggregate(F.plus, F.abs);
}
 
Example 13
Source File: Statistic.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.plus, F.chain(F.abs,F.minus)) / a.aggregate(b, F.plus, F.plus);
}
 
Example 14
Source File: Statistic.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.plus, fun);
}
 
Example 15
Source File: Statistic.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.max, F.chain(F.abs,F.minus));
}
 
Example 16
Source File: Statistic.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
public final double apply(DoubleMatrix1D a, DoubleMatrix1D b) {	
	return a.aggregate(b, F.plus, F.chain(F.abs,F.minus));
}
 
Example 17
Source File: Algebra.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Returns the one-norm of vector <tt>x</tt>, which is <tt>Sum(abs(x[i]))</tt>.
 */
public double norm1(DoubleMatrix1D x) {
	if (x.size()==0) return 0;
	return x.aggregate(cern.jet.math.Functions.plus,cern.jet.math.Functions.abs);
}
 
Example 18
Source File: SeqBlas.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
public double dasum(DoubleMatrix1D x) {
	return x.aggregate(F.plus, F.abs);
}