[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: meaning of matrix operation A(B)
From: |
Joao Rodrigues |
Subject: |
Re: meaning of matrix operation A(B) |
Date: |
Sat, 01 Nov 2014 08:08:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
On 10/31/2014 07:17 AM, kankan wrote:
Dear all,
I have two matrix A and B. Size of A is 512x1 and size of B is 132x108.
There is an operation in octave: A(B). Output of this operation is a matrix
132x108. What is the name of this operation and what does it is doing.
Actualy I want to know the algorithm of this operation and want to use in
fortran.
The source code of applylut function of image-processing package of octave
used this operation (at line no 42 of applylut.m).
The command is : A=LUT(filter2(w,BW)+1);
Here LUT is a matrix of dimension 512x1 and filter2(w,BW) is 132x108. I want
to know how A has been calculated.
Please help me.
Thanks in advance.
Regards,
Kankan
what A(B) does is to return the elements of A indexed in B
octave:1> A = [1.1 2.2 3.3]'; B = [2 3 1]'; [A, B, A(B)]
ans =
1.1000 2.0000 2.2000
2.2000 3.0000 3.3000
3.3000 1.0000 1.1000
octave:2> B = [2 3 1 4]'; [B, A(B)]
error: A(I): index out of bounds; value 4 out of bound 3
octave:2> B = [2 3 1 3]'; [B, A(B)]
ans =
2.0000 2.2000
3.0000 3.3000
1.0000 1.1000
3.0000 3.3000
octave:3> B = [2 3; 1 3]'; [B, A(B)]
ans =
2.0000 1.0000 2.2000 1.1000
3.0000 3.0000 3.3000 3.3000
Now if A is a matrix:
octave:4> A = [1.1 2.2 3.3; 4.4 5.5 6.6; 7.7 8.8 9.9]'
A =
1.1000 4.4000 7.7000
2.2000 5.5000 8.8000
3.3000 6.6000 9.9000
Then A(B) returns the A values in indices B by reading A as a vector of
concatenated columns:
octave:5> B = [2 4; 6 8]'; [B, A(B)]
ans =
2.0000 6.0000 2.2000 6.6000
4.0000 8.0000 4.4000 8.8000
You can also extract a sub-matrix from a matrix by specifying two index
vectors (row and column);
octave:6> B = [2 3]'; C = [1 3]'; A(B,C)
ans =
2.2000 8.8000
3.3000 9.9000
I hope this helps.
- Re: meaning of matrix operation A(B),
Joao Rodrigues <=