[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: no way for simple matrix lookup ?

**From**: |
Jonathan C. Webster |

**Subject**: |
Re: no way for simple matrix lookup ? |

**Date**: |
Wed, 16 Jun 2004 17:16:41 -0400 |

**User-agent**: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 |

D. Goel wrote:

Hi
[1] Suppose A is a nxn matrix. And b and c are vectors. How do i

`return elements of A specified by b and c?
``
``i.e. Want to return a vector D, such that
``D(i) = A(b(i), c(i))
``
`

Ravel the matrix A out into one long vector, A_vec, using fortran indexing if
you want.
Then combine vec_b and vec_c into a single index vector into your A_vec.
.
vec_3 = vec_b + size(A)(1) * (vec_c - 1)
Finally, your new reordered result vector D_vec
D_vec = A_vec(vec_3)
I think thats right, but check it. Think carefully about which should be vec_b
and vec_c.
Jonathan Webster
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------

**no way for simple matrix lookup ?**, *D. Goel*, `2004/06/16`
**Re: no way for simple matrix lookup ?**, *Mike Miller*, `2004/06/16`
**Re: no way for simple matrix lookup ?**, *D. Goel*, `2004/06/16`
**Re: no way for simple matrix lookup ?**, *Mike Miller*, `2004/06/16`
**Re: no way for simple matrix lookup ?**, *Quentin Spencer*, `2004/06/16`
**Re: no way for simple matrix lookup ?**, *Julius Smith*, `2004/06/18`
**Re: no way for simple matrix lookup ?**, *Julius Smith*, `2004/06/18`
**Re: no way for simple matrix lookup ?**, *Mike Miller*, `2004/06/18`
**Re: no way for simple matrix lookup ?**, *Julius Smith*, `2004/06/18`

**Re: no way for simple matrix lookup ?**, *Etienne Grossmann*, `2004/06/16`
**Re: no way for simple matrix lookup ?**,
*Jonathan C. Webster* **<=**