[concurrency-interest] jsr166y common ops

Kasper Nielsen kasper at kav.dk
Wed Feb 6 06:19:13 EST 2008


Hi,

I've started on a small library with different Op implementations. So
far its mostly various Predicate, Op, Comparator implementations.

I'll be moving it somewhere permanently soon, but for now you can find
it here:

javadoc/jar/dist
http://www.itu.dk/~kav/cake/apidocs/
http://www.itu.dk/~kav/cake/cake-jsr166y.jar
http://www.itu.dk/~kav/cake/cake-jsr166y.tar.gz

the source can be build with Ant

The naming is still a bit inconsistent, for example, I haven't yet
changed the name of Mappers.java to something else after Ops.Mapper has
been renamed to Ops.Op. (Let's see what Doug comes up with next time :)

There is also the _very_ beginning of a ParallelDoubleMatrix. Internally 
it is based on a single array of doubles
(http://artisans-serverintellect-com.si-eioswww6.com/default.asp?W40
uses a double[][]).

I haven't implemented matrix multiplication yet (or
anything fancy such as diagonalization, decomposition, etc.) If someone 
wants to have a bit of fun the matrix multiply demo by Doug is a good 
start 
http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/taskDemo/MatrixMultiply.java

http://theory.csail.mit.edu/classes/6.895/fall03/scribe/lecture-2.ps 
describes how it works.

Now, back to ParallelDoubleMatrix here is sample usage:
ParallelDoubleMatrix A = ParallelDoubleMatrix.create(3, 4,
ParallelDoubleMatrix.defaultExecutor());
ParallelDoubleMatrix B = ParallelDoubleMatrix.create(3, 4,
ParallelDoubleMatrix.defaultExecutor());

// fill randomly
A.replaceWithGeneratedValue(CommonOps.doubleRandom(1, 50));
B.fill(12); // sets all elements to 12
A.add(5); // scalar add
B.multiply(3); // scalar multiplication
ParallelDoubleMatrix C = A.copy().add(B); // copy A and  add (matrix) B
System.out.println(C.toString(new DecimalFormat("00.000")));

prints

| 75,275 64,167 78,069 85,196 |
| 59,765 87,388 72,701 77,251 |
| 73,585 71,770 83,098 56,890 |

Eventually, I hope to end up with a number of different standard 
libraries utilizing the fork-join-framework that aren't likely JDK 
components. I'm also working on a distributed ParallelMap (long way to 
go though).

Contributions and comments are more then welcome.

cheers
   Kasper





More information about the Concurrency-interest mailing list