
org.carrot2.matrix.factorization.PartialSingularValueDecompositionFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of carrot2-mini Show documentation
Show all versions of carrot2-mini Show documentation
Carrot2 search results clustering framework. Minimal functional subset
(core algorithms and infrastructure, no document sources).
/*
* Carrot2 project.
*
* Copyright (C) 2002-2015, Dawid Weiss, Stanisław Osiński.
* All rights reserved.
*
* Refer to the full license file "carrot2.LICENSE"
* in the root folder of the repository checkout or at:
* http://www.carrot2.org/carrot2.LICENSE
*/
package org.carrot2.matrix.factorization;
import org.carrot2.mahout.math.matrix.*;
/**
* Factory for {@link PartialSingularValueDecomposition}s.
*/
public class PartialSingularValueDecompositionFactory implements
IMatrixFactorizationFactory
{
/** The desired number of base vectors */
protected int k;
/** The default desired number of base vectors */
protected static final int DEFAULT_K = -1;
/**
* Creates the factory that creates factorizations that compute the maximum number of
* base vectors.
*/
public PartialSingularValueDecompositionFactory()
{
this.k = DEFAULT_K;
}
public IMatrixFactorization factorize(DoubleMatrix2D A)
{
PartialSingularValueDecomposition partialSingularValueDecomposition = new PartialSingularValueDecomposition(
A);
partialSingularValueDecomposition.setK(k);
partialSingularValueDecomposition.compute();
return partialSingularValueDecomposition;
}
/**
* Sets the number of base vectors k .
*
* @param k the number of base vectors
*/
public void setK(int k)
{
this.k = k;
}
/**
* Returns the number of base vectors k .
*/
public int getK()
{
return k;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy