[Numpy-discussion] Optimized sum of squares
Tue Oct 20 12:16:18 CDT 2009
On Sun, Oct 18, 2009 at 6:06 AM, Gary Ruben <email@example.com> wrote:
> Hi Gaël,
> If you've got a 1D array/vector called "a", I think the normal idiom is
> For the more general case, I think
> np.tensordot(a, a, axes=something_else)
> should do it, where you should be able to figure out something_else for
> your particular case.
Is it really possible to get the same as np.sum(a*a, axis) with
tensordot if a.ndim=2 ?
Any way I try the "something_else", I get extra terms as in np.dot(a.T, a)
> Gary R.
> Gael Varoquaux wrote:
>> On Sat, Oct 17, 2009 at 07:27:55PM -0400, firstname.lastname@example.org wrote:
>>>>>> Why aren't you using logaddexp ufunc from numpy?
>>>>> Maybe because it is difficult to find, it doesn't have its own docs entry.
>> Speaking of which...
>> I thought that there was a readily-written, optimized function (or ufunc)
>> in numpy or scipy that calculated the sum of squares for an array
>> (possibly along an axis). However, I cannot find it.
>> Is there something similar? If not, it is not the end of the world, the
>> operation is trivial to write.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion