Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • thank you for your response, but please note the last para of my question. Commented May 18, 2012 at 20:21
  • If you're worried about performance, this is about as good as it can get. These are still vector operations and are very fast. Commented May 18, 2012 at 20:27
  • yes, i understand; but a sophisticated implementation could effectively do this as an optimization of a pure matrix operations specification. Commented May 18, 2012 at 20:28
  • -1: You can do it faster without the sum: use matrix multiplication on the transpose instead of elementwise. Commented May 18, 2012 at 20:42
  • 1
    @Phonon My downvote is locked, but if agksmehx finds your solution to be consistently faster you deserve an upvote and I will stand corrected. Edit your answer somehow and I will change my vote to an upvote instead. Commented May 18, 2012 at 21:38