Code Monkey home page Code Monkey logo

Comments (6)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
1. Clarification: I was referring to the get(int, int) and set(int, int) 
methods.

2. Correction: MatrixMatrixMult was a bad exmaple as it does not contain calls 
to these methods, but many other classes in org.ejml.alg.dense contain 
references to get(int, int) or set(int, int), which could be replaced by 
unsafe_get(int, int) and unsafe_set(int, int) for DenseMatrix64, the most 
commonly used matrix type.

Original comment by [email protected] on 23 Nov 2011 at 10:58

from efficient-java-matrix-library.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
Do you see any place where calls to set(int,int)/get(int,int) are being called 
in the inner most loops?  Just noticed that insert/extract does that and that 
is being changed.  

In an ideal world, all calls would be made to those routines since it is 
possible to catch simple errors that would otherwise go unnoticed.  There might 
be a few places where those calls were left in place because it was thought 
that it would not effect performance.

Original comment by [email protected] on 23 Nov 2011 at 12:24

from efficient-java-matrix-library.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
There are other instances too, e.g. in CommonOpts, MatrixComponent, 
MatrixFeatures, plus most decomposition classes.

Original comment by [email protected] on 23 Nov 2011 at 12:36

from efficient-java-matrix-library.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
Some places inside of CommonOps might benefit from the change.  Other places, 
like in MatrixComponent, would not.  Inside of MatrixComponent it works with 
Graphics2D at the pixel level, which is "slowish" and rendering for 
visualization tends to not be a time critical task.  The general rule is that 
unless there is a good reason to change it is better to use the safe method.

Interested in check out some functions inside of CommonOps and benchmarking 
them across a range of matrix sizes to see if they would benefit from the 
change?

For examples of how to benchmark see "benchmarks/src/org/ejml/*". 

Original comment by [email protected] on 24 Nov 2011 at 5:59

from efficient-java-matrix-library.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
I agree on MatrixComponent, but I think MatrixFeatures, e.g. isSymmetric(), 
could benefit if the method is called often.

I kinda disagree with "don't change because it's safer" for the following 
reasons:
- The bounds checks made in get(int, int) and set(int, int) can be moved 
outside of the  inner loops without sacrificing safety at all.
- It is library code, and library code "is allowed" to use unsafe methods 
because the library "knows what it's doing".
- Library code should be very well unit-tested to avoid any errors introduced 
by using unsafe methods.

Anyway, up to you really, but I think the changes might make a difference in 
benchmarks (I haven't run any), and by simply moving the bound check out of the 
inner loops you don't sacrifice any safety.

Original comment by [email protected] on 25 Nov 2011 at 9:27

from efficient-java-matrix-library.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
Its very hard to prove that code is correct in all situations.  In EJML I try 
to test as many situations as possible but even then I do occasionally find 
nasty bugs in code that was deemed to be correct.  If you want to have fun take 
a moderate sized C/C++ program which is "bug free" that no one has run a memory 
checker on and see what valgrind finds.  valgrind does a good job of detecting 
buffer overruns and bad pointers.

I'm going to close this ticket, but there are probably some simple functions 
that would be improved with this change.

Original comment by [email protected] on 2 Dec 2011 at 2:56

  • Changed state: Done

from efficient-java-matrix-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.