[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dot product (nx1).*(nxm)
From: |
Joao Cardoso |
Subject: |
Re: Dot product (nx1).*(nxm) |
Date: |
Mon, 06 Dec 1999 14:50:25 +0000 |
Mike Miller wrote:
...
> octave:4> t0=cputime; for i=1:1000, p2=p*q; end , cputime-t0
> octave:5> t0=cputime; for i=1:1000, p2=p(:,q); end , cputime-t0
...
> > As I never really understood the line 5 syntax, I always use the line
> > 4 method -- I understand it.
>
> Joao--
>
> I think it's pretty simple to understand.
...
> You can repeat rows or columns if you like:
>
> A(:,[2 2 2 4])
>
> That will return the all rows of A (the colon ':' means 'all'), but it
> will repeat the second column three times followed by the fourth column.
> There will be no other columns. So, if we have a column vector 'p' and we
> write this:
>
> p(:,[1 1 1 1])
>
> That yields a matrix containing only four copies of p in the four columns
> of the matrix. So, of course,
ah, yes, now I understand it. But your explanation skips an important step:
you was speaking of matrix A, and suddenly starts speaking of column vector p
:-)
My problem was (is!) that the notation p(:,[1 1 1]) is applied to matrices,
and if p is a column vector, how can one specify its columns?
...
> Does that clarify the meaning of line 5 above?
yes, thanks. But the notation is not self-evident, as I said.
...
> So far so good, but in MATLAB you can get those elements out of the matrix
> and into a column vector using this command:
>
> A(find(A<.5))
>
> That doesn't work in Octave. Is there some other way that Octave can
> extract those numbers from the matrix? Is it as efficient?
As John Eaton said, use do_fortran_indexing=1 for this case.
Thanks,
Joao
> Regards,
>
> Mike
--
Joao Cardoso | e-mail: address@hidden
INESC, R. Jose Falcao 110 | tel: + 351 2 2094322
4050 Porto, Portugal | fax: + 351 2 2008487
-----------------------------------------------------------------------
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
-----------------------------------------------------------------------
- Dot product (nx1).*(nxm), Andre Bonfrer, 1999/12/04
- RE: Dot product (nx1).*(nxm), Heber Farnsworth, 1999/12/04
- RE: Dot product (nx1).*(nxm), Mike Miller, 1999/12/04
- Re: Dot product (nx1).*(nxm), Joao Cardoso, 1999/12/05
- Re: Dot product (nx1).*(nxm), Joao Cardoso, 1999/12/05
- Re: Dot product (nx1).*(nxm), Mike Miller, 1999/12/06
- Re: Dot product (nx1).*(nxm), John W. Eaton, 1999/12/06
- Re: Dot product (nx1).*(nxm),
Joao Cardoso <=
- Re: Dot product (nx1).*(nxm), Mike Miller, 1999/12/06
- speed issues (was Re: Dot product (nx1).*(nxm)), Mike Miller, 1999/12/06
- Re: Dot product (nx1).*(nxm), Dr Andre Bonfrer, 1999/12/05