Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32945 > unrolled thread
| Started by | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
|---|---|
| First post | 2015-10-27 14:44 -0700 |
| Last post | 2015-10-27 14:44 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.java.programmer
parallel stream calculate matrix Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2015-10-27 14:44 -0700
| From | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
|---|---|
| Date | 2015-10-27 14:44 -0700 |
| Subject | parallel stream calculate matrix |
| Message-ID | <a3f9f833-77dd-40d0-9711-e036928f4bf8@googlegroups.com> |
Hello,
I would like to calculate row-wise a matrix with a parallel stream. In a short excerpt of my code:
Map<myData, Double> x = new HashMap();
ArrayList<myData> y = new ArrayList( x.keySet() );
Matrix m = new Matrix( y.size(), y.size() );
for( int i=0; i < y.size(); i++)
{
for( int j= i+1; j < y.size(); j++)
{
double v = calculate( y.get(i), y.get(j) );
m.set(i,j) = v;
m.set(j,i) = v;
}
m.normalize(i);
}
I would like to do the first loop in parallel, because each row is independed from the others, but the first element on x must be defined on the first row / column on my matrix. My problem is, that I need on one hand an index value to address the cells within the matrix and the key value to calculate the value. I'm searching for a solution like zip in Python:
for index, data in zip()
(How) Can I do this in Java?
Thanks
Phil
Back to top | Article view | comp.lang.java.programmer
csiph-web