[Numpy-discussion] output arguments

2007-07-23 Thread Thomas Breuel

Hi,

core NumPy doesn't seem to support a lot of output arguments, or common
composite operations.  For example, a common operation is something like

a = outer(b,c)

or

a += outer(b,c)

There are some workarounds, but they aren't pretty.  Consistently providing
output arguments throughout NumPy would help; is there any reason this isn't
being done?  For example, it would be nice if "outer" supported:

outer(b,c,output=a)
outer(b,c,increment=a)
outer(b,c,increment=a,scale=eps)

or maybe one could specify an accumulation ufunc, with addition,
multiplication, min, and max being fast, and with an optional scale
parameter.

Another approach might be to provide, in addition to the convenient
high-level NumPy operations, direct bindings for BLAS and/or similar
libraries, with Fortran-like procedural interfaces, but I can't find any
such libraries in NumPy or SciPy.  Am I missing something?

It seems like writing native code to speed up these kinds of operations
isn't really so great because (1) it unnecessarily complicates development
and packaging, and (2) is likely to perform worse than BLAS and similar
libraries.

How are other people handling these cases?

Thanks,
Tom
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] output arguments

2007-07-23 Thread Robert Kern
Thomas Breuel wrote:
> Hi,
> 
> core NumPy doesn't seem to support a lot of output arguments, or common
> composite operations.  For example, a common operation is something like
> 
> a = outer(b,c)
> 
> or
> 
> a += outer(b,c)
> 
> There are some workarounds, but they aren't pretty.  Consistently
> providing output arguments throughout NumPy would help; is there any
> reason this isn't being done? 

Time.

> For example, it would be nice if "outer"
> supported:
> 
> outer(b,c,output=a)
> outer(b,c,increment=a)
> outer(b,c,increment=a,scale=eps)
> 
> or maybe one could specify an accumulation ufunc, with addition,
> multiplication, min, and max being fast, and with an optional scale
> parameter.

What would the increment and scale parameters do? Why should they be part of the
 outer() interface? Have you looked at the .outer() method on the add, multiply,
minimum, and maximum ufuncs?

> Another approach might be to provide, in addition to the convenient
> high-level NumPy operations, direct bindings for BLAS and/or similar
> libraries, with Fortran-like procedural interfaces, but I can't find any
> such libraries in NumPy or SciPy.  Am I missing something?

scipy.linalg.flapack, etc.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] output arguments

2007-07-25 Thread Thomas Breuel

> For example, it would be nice if "outer"
> supported:
>
> outer(b,c,output=a)
> outer(b,c,increment=a)
> outer(b,c,increment=a,scale=eps)
>
> or maybe one could specify an accumulation ufunc, with addition,
> multiplication, min, and max being fast, and with an optional scale
> parameter.

What would the increment and scale parameters do? Why should they be part
of the
outer() interface? Have you looked at the .outer() method on the add,
multiply,
minimum, and maximum ufuncs?



output=a would put the output of the operation into a
increment=a would increment the values in a by the result of the operation
increment=a,scale=eps would increment the values in a by the result of
multiplying the result by eps.

I think a good goal for a numerical scripting language should be to allow
people to express common numerical algorithms without extraneous array
allocations for intermediate results; with a few dozen such primitives, a
lot of native code can be avoided in my experience.


Another approach might be to provide, in addition to the convenient
> high-level NumPy operations, direct bindings for BLAS and/or similar
> libraries, with Fortran-like procedural interfaces, but I can't find any
> such libraries in NumPy or SciPy.  Am I missing something?

scipy.linalg.flapack, etc.



Thanks; I'll have to take a look. I don't remember whether LAPACK contains
these low-level ops itself.

Cheers,
Thomas.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] output arguments for dot(), tensordot()

2008-04-01 Thread Andreas Klöckner
Hi all,

is there a particular reason why dot() and tensordot() don't have output 
arguments?

Andreas


signature.asc
Description: This is a digitally signed message part.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] output arguments for dot(), tensordot()

2008-04-01 Thread Robert Kern
On Tue, Apr 1, 2008 at 11:56 AM, Andreas Klöckner
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
>  is there a particular reason why dot() and tensordot() don't have output
>  arguments?

No technical reason. It just hasn't been done. If you were to
implement it, we would be happy to accept it.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion