[SciPy-user] can basearray using somehow be tried already?

dmitrey openopt@ukr....
Fri Mar 23 15:05:57 CDT 2007


Ok, but isn't it possible to add derive class to numpy, based on 
ndarray, with MATLAB-like dotwise & matrix operations with any of 
ndarray & matrix instances? I.e. x*y (x^y, x/y etc) is matrix & x .* y 
(x.^y, x./y etc) is dotwise, if any of x & y are something like mat_array?
Currently I use it in my code things like
    def _matmult(self, x, y):
        return asarray(x) ** asarray(y)
 
    def _dotmult(self, x, y):
        return asarray(x) * asarray(y)

>See my response to that post for why it's not quite the
project you think it is, why I think it is dead, and what is replacing it.

Can't you give exact URL, please? I'm not familiar enough with mailing 
lists interface & browsing so I can't find it by myself.
WBR, D.


Robert Kern wrote:
> Perry Greenfield wrote:
>   
>> On Mar 23, 2007, at 3:08 PM, Robert Kern wrote:
>>
>>     
>>> dmitrey wrote:
>>>
>>>       
>>>> first of all I'm very interested in operators (matmult, dotmult  
>>>> etc) -
>>>> will they have MATLAB/Octave/omatrix/etc -like style
>>>> dot is present => dotwise operation
>>>> dot is absent => matrix operation
>>>> or other?
>>>>         
>>> No, we do not have the ability to change Python's syntax to add  
>>> operators. For
>>> the array object, operators all act element-wise. numpy also  
>>> provides a matrix
>>> object based on the array object which implements the relevant  
>>> operators as
>>> matrix operations (e.g. * is a matrix multiplication rather than  
>>> element-wise
>>> multiplication).
>>>       
>> While strictly true, there was a cool hack a while back that had  
>> nearly the same effect. I forget if it was looked into and found  
>> wanting for this purpose. Perhaps someone remembers if there was a  
>> reason this couldn't be used (or wouldn't be considered symbolic  
>> enough).
>>     
>
> What do you mean by "used"? There's no reason an individual couldn't use it, no.
> It's entirely decoupled from anything else; i.e. no one else has to modify
> anything in order to support it. Personally, I think the hack is pretty cool,
> but its verbosity and precedence problems prevent me from actually using it.
> Unfortunately, I think it simply doesn't solve the problem and creates more
> magic in the process. I wouldn't want to see such pseudo-operators added to
> numpy, for example.
>
>   



More information about the SciPy-user mailing list