[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
no way for simple matrix lookup ?
From: |
D. Goel |
Subject: |
no way for simple matrix lookup ? |
Date: |
Wed, 16 Jun 2004 10:56:17 -0400 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux) |
Hi
[1] Suppose A is a nxn matrix. And b and 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))
Is the only way to do that a for loop? Is that inefficient?
This "simple lookup" seems too fundamental that there should be a way
to do it. Am I missing something? Else, should this be a feature
request?
[2] if (1) above is not possible, is it possible if b = c ?
[3] More generally, the problem i am struggling with is:
A is a nxmxl matrix. b and c are vectors.
I am looking for a vector D, such that D(i,:)= A(b(i), :, c(i)).
Any way to do that?
[4] A simple generalization of (1) to 3 D's possible?
D(i)=A(b(i), c(i), d(i)) ?
[5] BTW, i might be able to do (2) using the diag function, but is
there a way to use diag for 3 Dimensions? or use diag such that it
acts only on 2 of the indices? So one can implement (3), which is my
actual problem?
[6] Is there a way to transpose the 2nd and 3rd indices of a 3D
vector? transpose() complains that it is implemented only for
2D's... I am trying 2.1.57.
Thanks, please CC if you can..
DG http://gnufans.net/
--
- no way for simple matrix lookup ?,
D. Goel <=