Github user mateiz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/117#discussion_r10775165
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala 
---
    @@ -0,0 +1,136 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.mllib.linalg
    +
    +import breeze.linalg.{Vector => BreezeVector, DenseVector => 
BreezeDenseVector,
    +  SparseVector => BreezeSparseVector}
    +
    +/**
    + * Represents a numeric vector, whose index type is Int and value type is 
Double.
    + */
    +trait Vector extends Serializable {
    +
    +  /**
    +   * Size of the vector.
    +   */
    +  def size: Int
    +
    +  /**
    +   * Converts the instance to a breeze vector.
    +   */
    +  private[mllib] def toBreeze: BreezeVector[Double]
    +}
    +
    +/**
    + * Represents a vector with random access to its elements.
    + *
    + */
    +trait RandomAccessVector extends Vector {
    +  // empty
    +}
    +
    +/**
    + * Factory methods for [[org.apache.spark.mllib.linalg.Vector]].
    + */
    +object Vectors {
    +
    +  /** Creates a dense vector. */
    +  def dense(values: Array[Double]): Vector = new DenseVector(values)
    +
    +  /**
    +   * Creates a sparse vector providing its index array and value array.
    +   *
    +   * @param size vector size.
    +   * @param indices index array, must be strictly increasing.
    +   * @param values value array, must have the same length as indices.
    +   */
    +  def sparse(size: Int, indices: Array[Int], values: Array[Double]): 
Vector =
    +    new SparseVector(size, indices, values)
    +
    +  /**
    +   * Creates a sparse vector using unordered (index, value) pairs.
    +   *
    +   * @param size vector size.
    +   * @param elements vector elements in (index, value) pairs.
    +   */
    +  def sparse(size: Int, elements: Iterable[(Int, Double)]): Vector = {
    --- End diff --
    
    You should add a Java-friendly version of this too that takes a 
java.util.Iterable


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to