Package org.apache.mahout.math.matrix.impl

Examples of org.apache.mahout.math.matrix.impl.SparseDoubleMatrix2D


   * @throws IllegalArgumentException if <tt>for any 1 &lt;= row &lt; values.length: values[row].length !=
   *                                  values[row-1].length</tt>.
   */
  public DoubleMatrix2D make(double[][] values) {
    if (this == sparse) {
      return new SparseDoubleMatrix2D(values);
    } else {
      return new DenseDoubleMatrix2D(values);
    }
  }
View Full Code Here


  }

  /** Constructs a matrix with the given shape, each cell initialized with zero. */
  public DoubleMatrix2D make(int rows, int columns) {
    if (this == sparse) {
      return new SparseDoubleMatrix2D(rows, columns);
    }
    if (this == rowCompressed) {
      return new RCDoubleMatrix2D(rows, columns);
    }
    //if (this==rowCompressedModified) return new RCMDoubleMatrix2D(rows,columns);
View Full Code Here

   * @throws IllegalArgumentException if <tt>for any 1 &lt;= row &lt; values.length: values[row].length !=
   *                                  values[row-1].length</tt>.
   */
  public DoubleMatrix2D make(double[][] values) {
    if (this == SPARSE) {
      return new SparseDoubleMatrix2D(values);
    } else {
      return new DenseDoubleMatrix2D(values);
    }
  }
View Full Code Here

  }

  /** Constructs a matrix with the given shape, each cell initialized with zero. */
  public DoubleMatrix2D make(int rows, int columns) {
    if (this == SPARSE) {
      return new SparseDoubleMatrix2D(rows, columns);
    } else {
      return new DenseDoubleMatrix2D(rows, columns);
    }
  }
View Full Code Here

        if (featureIndex.length == 0)
        {
            return new DenseDoubleMatrix2D(stemToRowIndex.size(), 0);
        }

        final DoubleMatrix2D phraseMatrix = new SparseDoubleMatrix2D(stemToRowIndex
            .size(), featureIndex.length);

        final PreprocessingContext preprocessingContext = vsmContext.preprocessingContext;
        final int [] wordsStemIndex = preprocessingContext.allWords.stemIndex;
        final int [] stemsTf = preprocessingContext.allStems.tf;
        final int [][] stemsTfByDocument = preprocessingContext.allStems.tfByDocument;
        final int [][] phrasesWordIndices = preprocessingContext.allPhrases.wordIndices;
        final int documentCount = preprocessingContext.documents.size();
        final int wordCount = wordsStemIndex.length;

        for (int i = 0; i < featureIndex.length; i++)
        {
            final int feature = featureIndex[i];
            final int [] wordIndices;
            if (feature < wordCount)
            {
                wordIndices = new int []
                {
                    feature
                };
            }
            else
            {
                wordIndices = phrasesWordIndices[feature - wordCount];
            }

            for (int wordIndex = 0; wordIndex < wordIndices.length; wordIndex++)
            {
                final int stemIndex = wordsStemIndex[wordIndices[wordIndex]];
                if (stemToRowIndex.containsKey(stemIndex))
                {
                    final int rowIndex = stemToRowIndex.lget();

                    double weight = termWeighting.calculateTermWeight(stemsTf[stemIndex],
                        stemsTfByDocument[stemIndex].length / 2, documentCount);

                    phraseMatrix.setQuick(rowIndex, i, weight);
                }
            }
        }

        return phraseMatrix;
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.matrix.impl.SparseDoubleMatrix2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.