Sparse matrix multiply dummy algorithm

Today almost the half an hour I was trying to write that algorithm which multiplies two sparse matrix. At the end this is what I’ve got. The matrix is represented as a linkedlist of triples, because this is how they want it in our university. There were some mistakes in the code like Sparce is not with “s”, but those are pretty much syntax mistakes and i didn’t want to make changes for our teacher :) .

public NumericMatrix multWith(SparseMatrix mat) throws CannotMult, 
   OutOfMatrixRange {
   if (!canMult(mat)){
       throw new CannotMult();
   }
   SparseMatrix result = new SparseMatrix(this.rows, mat.columns);
   if (body.isEmpty() || mat.body.isEmpty()){
       return result;
   }
   Iterator<Triple> itForThis = this.body.iterator();
 
   while (itForThis.hasNext()) {
       Triple thisElement = itForThis.next();
       Iterator<Triple> itForMat = mat.body.iterator();
       while (itForMat.hasNext()) {
           Triple thatElement = itForMat.next();
           if (thatElement.i > thisElement.j){
               break;
           }
           if (thisElement.j == thatElement.i) {
               double value = result.elementAt(thisElement.i,
                       thatElement.j);
               result.setElement(thisElement.i, thatElement.j, value
                       + thisElement.element * thatElement.element);
           }
       }
   }
   return result;
}

Sorry for the bad code formatting but java is kind of verbose :( . All in all the code is not so nice but it was the only thing that came up and worked so I am posting it here if someone need it, because there wasn’t good simple code for that algorithm. I didn’t have the time to look at performance libraries and how they implement that, but I read some interesting stuff on wikipedia.com. I didn’t know that there was an algorthm that can multiply two Ordinary matrices in O(n^2.376). Take a look at the page. If you find some free materials about the algorithm please let me know I will be glad to look into it, because I might need it for some graphic stuff I will be doing next year :)

UPDATE: Fixed some stuff and chan the name to SparseMatrix to be really normal :)

Trac and Eclipse

Yesterday I wanted to integrate Trac tasks from the kbgoffice task list in my IDE. I was sure that eclipse should have that feature so I search in google and found that indeed there is a connector for Trac in mylyn-extras. Well i wanted to find an update site for that but it seems there isn’t any. So i downloaded the the extras version from the main download page and installed it locally.

It seems that eclipse is getting really mature since last time i did that i had bad problems with dependencies not resolved and things like that. Now it included the package as just another update site source, so the package manager can resolve dependencies if any.

All in all the plugin is not really what i was hoping for. I had some tasks from mylyn throughout the project and wanted to synchronize those but i couldn’t. Also the trac tasks when opened just open a browser which is not really what i was hoping for(i wanted to get a nice view which should look like a normal mylyn task). It is better than opening an external browser and searching for the task you want though, but not the best and i hope they fix it for the next release.

Eclipse for c++

Hmm lately I started using eclipse more and more. It seems they made it to not crash so much with the new release. I am pretty happy with it for C++ development it seems to own. I am not sure but i think that I am even more productive with it now than with vim. I have used the 3.2 version but it was full crap back then ;) . Besides it is written in java it is worth looking in it.