help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: matrix-vector-op class ?


From: Jonathan King
Subject: Re: matrix-vector-op class ?
Date: Thu, 6 Apr 2000 17:51:53 -0500 (CDT)

On Thu, 6 Apr 2000, John W. Eaton wrote:

> On  6-Apr-2000, Paul Kienzle <address@hidden> wrote:
> 
> | Why not just stick with the ".*" operator?

[snip]

> OK, this has been discussed some before, but is still not implemented
> even though it is something that even I would like to have.  So, if we
> can agree on semantics for the operators, I think I could implement it
> reasonably soon.

And specifically:
 
> How should we decide whether the rows or columns are to be scaled?
> 
> A simple definition would be that
> 
>   v .* M  ==  diag (v) * M  (row scaling)
>   M .* v  ==  M * diag (v)  (column scaling)
> 
> I like this because it is consistent and easy to describe.

I like it because it is what I often wishcast would happen when I write
these. :-)

[snip]

> The justification for using a column vector to do row scaling is that
> it is easy for me to visualize:
> 
>   [1]    [1 2]    [1   2]
>   [2] .* [4 5] => [8  10]
>   [3]    [7 8]    [21 24]
> 
> Similarly for column scaling by a row vector (just slide the row
> vector above or below the matrix).

Again, I think these are perfectly natural.  The column vector case
is just like the definition you gave above, and the scaling by a
row vector case is the "natural" (or least surprising) meaning
of r .* M

So that gives us, for c a column vector, r a row vector and M an
appropriate matrix:

   c .* M  => row scaling
   r .* M  => column scaling
   M .* c  => column scaling
   M .* r  => hmm...

I guess some people might want row scaling in the last case, but what I
think might be more useful is returning a matrix with cols(r) times as
many columns as M, where each submatrix the size of the original M is 
r(n)*M for 0<n<cols(r).  In otherwords, repmat with scalar multiplication.
 
> I expect to extend the meanings of the operators .+, .-, and ./ in
> addition to the .* operator.  Someone once suggested that it might
> also make sense to have .== or .!= operators that work in a similar
> way, but I'm not sure how useful that would be.

I could see some use for the latter where you want to find different
values in different rows/columns of a matrix.  But I can only recall
one case in my personal life where this would have been really handy.

jking




-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]