Package org.apache.mahout.math

Examples of org.apache.mahout.math.Vector.normalize()


          result.setName(id);
        } else {
          result.setName(String.valueOf(doc));
        }
        if (normPower != NO_NORMALIZING) {
          result = result.normalize(normPower);
        }
      } catch (IOException e) {
        // Log?
        throw new IllegalStateException(e);
      }
View Full Code Here


    while (values.hasNext()) {
      VectorWritable value = values.next();
      value.get().addTo(vector);
    }
    if (normPower != PartialVectorMerger.NO_NORMALIZING) {
      vector = vector.normalize(normPower);
    }
    if (sequentialAccess) {
      vector = new SequentialAccessSparseVector(vector);
    }
    vectorWritable.set(vector);
View Full Code Here

      DoubleMatrix1D ejCol = eigenVects.viewColumn(basis.numRows() - i - 1);
      for (int j = 0; j < ejCol.size(); j++) {
        double d = ejCol.getQuick(j);
        realEigen.assign(basis.getRow(j), new PlusMult(d));
      }
      realEigen = realEigen.normalize();
      eigenVectors.assignRow(i, realEigen);
      log.info("Eigenvector {} found with eigenvalue {}", i, eigenVals.get(i));
      eigenValues.add(eigenVals.get(i));
    }
    log.info("LanczosSolver finished.");
View Full Code Here

    final DoubleFunction random = Functions.random();
    List<Vector> basisVectors = Lists.newArrayList();
    for (int i = 0; i < numProjections; ++i) {
      Vector basisVector = new DenseVector(numDimensions);
      basisVector.assign(random);
      basisVector.normalize();
      basisVectors.add(basisVector);
    }
    return  basisVectors;
  }
View Full Code Here

    @Override
    protected void map(IntWritable r, VectorWritable v, Context ctx) throws IOException, InterruptedException {
      int rowIndex = r.get();

      Vector row = v.get();
      row = row.normalize(1);
      if (stayingProbability != 1.0) {
        row.assign(Functions.MULT, stayingProbability);
      }

      Iterator<Vector.Element> it = row.iterateNonZero();
View Full Code Here

          name = String.valueOf(doc);
        }
        if (normPower == NO_NORMALIZING) {
          result = new NamedVector(result, name);
        } else {
          result = new NamedVector(result.normalize(normPower), name);
        }
      } catch (IOException e) {
        // Log?
        throw new IllegalStateException(e);
      }
View Full Code Here

    }
    if (normPower != PartialVectorMerger.NO_NORMALIZING) {
      if (logNormalize) {
        vector = vector.logNormalize(normPower);
      } else {
        vector = vector.normalize(normPower);
      }
    }
    if (sequentialAccess) {
      vector = new SequentialAccessSparseVector(vector);
    }
View Full Code Here

      DoubleMatrix1D ejCol = eigenVects.viewColumn(basis.numRows() - i - 1);
      for (int j = 0; j < ejCol.size(); j++) {
        double d = ejCol.getQuick(j);
        realEigen.assign(basis.getRow(j), new PlusMult(d));
      }
      realEigen = realEigen.normalize();
      eigenVectors.assignRow(i, realEigen);
      log.info("Eigenvector {} found with eigenvalue {}", i, eigenVals.get(i));
      eigenValues.add(eigenVals.get(i));
    }
    log.info("LanczosSolver finished.");
View Full Code Here

      //value.get().addTo(vector);
      vector.assign(value.get(), Functions.PLUS);
    }

    if (vector != null && normPower != PartialVectorMerger.NO_NORMALIZING) {
      vector = logNormalize ? vector.logNormalize(normPower) : vector.normalize(normPower);
    }

    VectorWritable vectorWritable = new VectorWritable(vector);
    context.write(key, vectorWritable);
  }
View Full Code Here

      }

      if (normPower == LuceneIterable.NO_NORMALIZING) {
        result = new NamedVector(result, name);
      } else {
        result = new NamedVector(result.normalize(normPower), name);
      }
      return result;
    } catch (IOException ioe) {
      throw new IllegalStateException(ioe);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.