Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I find it is difficult to understand the pseudo-code on this Wiki page.

N = length(S);
s1 = S(1:2:N-1) + sqrt(3)*S(2:2:N);
d1 = S(2:2:N) - sqrt(3)/4*s1 - (sqrt(3)-2)/4*[s1(N/2); s1(1:N/2-1)];
s2 = s1 - [d1(2:N/2); d1(1)];<<<<<<<<<<<<<<<<<<<<<<<
s = (sqrt(3)-1)/sqrt(2) * s2;
d = (sqrt(3)+1)/sqrt(2) * d1;

I do not understand what does the square-bracket means.

share|cite|improve this question
I think the best way to understand the code is to implement it in Matlab. Can you do that? – Nana Jun 20 '11 at 6:41
up vote 3 down vote accepted

The pseudo code is heavily using Matlab syntax. The square brackets mean concatenation of vectors. In this case you take the vector d1 (which is supposed to be a row vector), extract the second to N/2the entries and put the first entry of d1 below these.

share|cite|improve this answer

To complement Dirk's answer, note that:
S(1:2:N-1) selects the 1st, 3rd and N-1 rows of the column vector, S.
s1(N/2) selects the N/2 row of s1 whereas s1(1:N/2-1) selects the 1st and N/2-1 rows of s1.

Hope this helps.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.