New Mint Release: r15700

On Friday, I created a new release of Mint and DrJava with Mint: August 20, 2010 (r15700). The latest release is, as always, available from the Mint implementation page:

The only changes that we made were a small change to the build process on Mac OS, and the addition of the Range and Lift utility classes.

The Lift class allows the user to manually lift primitive values and strings when the compiler did not do that already, for example when working with arrays.

The Range class provides methods that allow many for loops to be written as foreach loops with a final loop variable that can be used across bracket boundaries immediately. Consider this example of a staged sparse matrix multiplication:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static separable
Code<Void> smmult(final double[][] a,
                  Code<double[][]> b,
                  Code<double[][]> output,
                  int l, int m, int n) {
  Code<Void> stats = <| { } |>;
  for(final int i: range(0, l)) {
    for(final int j: range(0, m)) {
      Code<Double> c = <| 0.0 |>;
      for(final int k: range(0, n)) {
        if(a[i][k] == 0.0)
          continue;
        else if(a[i][k] == 1.0)
          c = <| `c + (`b)[k][j] |>;
        else
          c = <| `c + (`(lift(a[i][k])) * (`b)[k][j]) |>;
      }
      stats = <| { `stats; (`output)[i][j] = `c; } |>;
    }
  }
  return stats;
}

is a lot cleaner than

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public static separable
Code<Void> smmult(final double[][] a,
                  Code<double[][]> b,
                  Code<double[][]> output,
                  int l, int m, int n) {
  Code<Void> stats = <| { } |>;
  for(int i = 0; i < l; i++) {
    for(int j = 0; j < m; j++) {
      final int ii = i;
      final int jj = j;
      Code<Double> c = <| 0.0 |>;
      for(int k = 0; k < n; k++) {
        final int kk = k;
        if(a[i][k] == 0.0)
          continue;
        else if(a[i][k] == 1.0)
          c = <| `c + (`b)[kk][jj] |>;
        else
          c = <| `c + (`(lift(a[ii][kk])) * (`b)[kk][jj]) |>;
      }
      stats = <| { `stats; (`output)[ii][jj] = `c; } |>;
    }
  }
  return stats;
}

The ii, jj, and kk variables aren’t necessary anymore.

(Re-posted from The Java Mint Blog.)

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Mint. Bookmark the permalink.

Leave a Reply