Skip to content

Commit

Permalink
Added Dst_First_1: Similar to Src_First_2 but different order of loops
Browse files Browse the repository at this point in the history
  • Loading branch information
pzemtsov committed May 2, 2014
1 parent c3620ae commit 472d121
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions E1.java
@@ -1,4 +1,4 @@
/** E1 demultiplexer, revision 6
/** E1 demultiplexer, revision 7
* Created reference implementation
* Added test and measurement code
* Added correctness test
Expand All @@ -8,6 +8,9 @@
* Added Src_First_2: Multiplication in the inner loop
* Fixed a bug in Src_First_2: double increment of an outer loop variable
* Added Src_First_3: Loop along source with division and modulo operations
*
* Started destination-first family of solutions:
* Added Dst_First_1: Similar to Src_First_2 but different order of loops
*/

import java.util.Random;
Expand Down Expand Up @@ -135,11 +138,26 @@ public void demux (byte[] src, byte[][] dst)
}
}

static final class Dst_First_1 implements Demux
{
public void demux (byte[] src, byte[][] dst)
{
assert src.length % NUM_TIMESLOTS == 0;

for (int dst_num = 0; dst_num < NUM_TIMESLOTS; ++ dst_num) {
for (int dst_pos = 0; dst_pos < src.length / NUM_TIMESLOTS; ++ dst_pos) {
dst [dst_num][dst_pos] = src [dst_pos * NUM_TIMESLOTS + dst_num];
}
}
}
}

public static void main (String [] args)
{
// measure (new Reference ());
// measure (new Src_First_1 ());
// measure (new Src_First_2 ());
measure (new Src_First_3 ());
// measure (new Src_First_3 ());
measure (new Dst_First_1 ());
}
}

0 comments on commit 472d121

Please sign in to comment.