[clean-list] My first side effect?

Siegfried Gonzi siegfried.gonzi@kfunigraz.ac.at
Mon, 05 Nov 2001 13:01:01 +0100


The following code is intented to transpose an array of the following shape (number
of columns 2 times that of rows):

0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5

to:

0 1 0 1 0 1
2 3 2 3 2 3
4 5 4 5 4 5

The code is working but only at good will. I used the code as part of the FFT in two
dimensions. Sometimes it is transposing correctly BUT sometimes it does not transpose
it correct. And this is on the Mac and Windows. I did not make a bug report (I fooled
myself to often and it turned out it was my fault) but I post it here.

I changed on Windows the array to strict and then it works but only when use (at
update):

  = Transpose_i (inc i) j jc {array & [jc,(2*i)] = a1,[jc,(2*i+1)] = a2,[i,j] =
(a3+0.0),[i,(inc j)] = (a4+0.0)}

and not:

= Transpose_i (inc i) j jc {array & [jc,(2*i)] = a1,[jc,(2*i+1)] = a2,[i,j] =
(a3),[i,(inc j)] = (a4)}


What should I do?

==
//MyArray:: !*{#*{#Real}}
MyArray:: !*{!*{!Real}}
MyArray = { { toReal(x) \\ x <- [0..(N-1)] } \\ y <- [0..(N2-1)] }
N:==6
N2 :== 3

//TransposeFFT:: !*{#*{#Real}} -> !*{#*{#Real}}
TransposeFFT:: !*{!*{!Real}} -> !*{!*{!Real}}
TransposeFFT array  = Transpose_j  0 array
where
  //Transpose_j::  !Int !*{#*{#Real}}  -> !*{#*{#Real}}
  Transpose_j::  !Int !*{!*{!Real}}  -> !*{!*{!Real}}
  Transpose_j i array
   | i == (size array  - 1 ) = array
   //| i == 1 = array
   #! trans_col = ( Transpose_i (i+1) (2*i) i  array  )
   = Transpose_j (inc i) trans_col
  //
  //Transpose_i:: !Int !Int  !Int !*{#*{#Real}}  -> !*{#*{#Real}}
  Transpose_i:: !Int !Int  !Int !*{!*{!Real}}  -> !*{!*{!Real}}
  Transpose_i i j jc  array
   | i == (size array  ) = array
   #! a1 = array.[i,j]
   #! a2 = array.[i,(inc j)]
   #! a3 = array.[jc,(2*i)]
   #! a4 = array.[jc,(2*i+1)]
   = Transpose_i (inc i) j jc {array & [jc,(2*i)] = a1,[jc,(2*i+1)] = a2,[i,j] =
(a3),[i,(inc j)] = (a4)}
   //= Transpose_i (inc i) j jc {array & [jc,(2*i)] = a1,[jc,(2*i+1)] = a2,[i,j] =
(a3+0.0),[i,(inc j)] = (a4+0.0)}


Start = TransposeFFT MyArray
==

Is this a side effect ever made in a functional language made by the fool Gonzi?


S. Gonzi