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

    https://github.com/apache/spark/pull/7222#discussion_r34008171
  
    --- Diff: python/pyspark/mllib/linalg.py ---
    @@ -590,18 +590,14 @@ def dot(self, other):
                 return np.dot(other.array[self.indices], self.values)
     
             elif isinstance(other, SparseVector):
    -            result = 0.0
    -            i, j = 0, 0
    -            while i < len(self.indices) and j < len(other.indices):
    -                if self.indices[i] == other.indices[j]:
    -                    result += self.values[i] * other.values[j]
    -                    i += 1
    -                    j += 1
    -                elif self.indices[i] < other.indices[j]:
    -                    i += 1
    -                else:
    -                    j += 1
    -            return result
    +            # Find out common indices.
    +            self_cmind = np.in1d(self.indices, other.indices)
    --- End diff --
    
    Could you try `in1d1 with option `assume_unique=True`? Based on the 
documentation, it should be faster.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to