Example #1
0
        public byte[] transpose(byte[] b)
        {
            UInt32 length = (UInt32)b.Length;

            Fibonacci fib = new Fibonacci();
            fib.start();

            //initialize value, i=1, j=2
            UInt32 i = fib.next(), j = fib.next();

            //from-start tranposition
            while(j<length)
            {
                Byte temp = b[i];
                b[i] = b[j];
                b[j] = temp;

                i = j; j = fib.next();
            }

            //from-end transposition
            fib.start();
            //initialize i=1, j=2
            i = fib.next(); j = fib.next();

            while(j<length)
            {
                Byte temp = b[length - i - 1];
                b[length - i - 1] = b[length - j - 1];
                b[length - j - 1] = temp;

                i = j; j = fib.next();
            }

            return b;
        }
Example #2
0
        public byte[] transpose(byte[] b)
        {
            UInt32 length = (UInt32)b.Length;
            UInt32 maxi = 0, maxj = 1;

            Fibonacci fib = new Fibonacci();
            fib.start();

            //initialize value
            UInt32 i = 0, j = 0;

            //find fibonacci limit
            UInt32 sem = 0;
            while ((sem = fib.next()) < length)
            {
                maxi = maxj; maxj = sem;
            }

            Console.WriteLine("maxi {0} maxj {1}", maxi, maxj);

            //from-start backward-transposition
            i = maxi;
            j = maxj;
            fib.start(i, j);

            i = fib.prev();
            while (i > 0)
            {
                Byte temp = b[length - i - 1];
                b[length - i - 1] = b[length - j - 1];
                b[length - j - 1] = temp;

                j = i; i = fib.prev();
            }

            //from-end backward-transposition
            i = maxi;
            j = maxj;
            fib.start(i, j);

            i = fib.prev();
            while(i > 0)
            {
                Byte temp = b[i];
                b[i] = b[j];
                b[j] = temp;

                j = i; i = fib.prev();
            }

            return b;
        }