Object-oriented Implementation of Numerical Methods

Didier H. Besset

Mentioned 4

Numerical methods naturally lend themselves to an object-oriented approach. Mathematics builds high- level ideas on top of previously described, simpler ones. Once a property is demonstrated for a given concept, it can be applied to any new concept sharing the same premise as the original one, similar to the ideas of reuse and inheritance in object-oriented (OO) methodology. Few books on numerical methods teach developers much about designing and building good code. Good computing routines are problem-specific. Insight and understanding are what is needed, rather than just recipes and black box routines. Developers need the ability to construct new programs for different applications. Object-Oriented Implementation of Numerical Methods reveals a complete OO design methodology in a clear and systematic way. Each method is presented in a consistent format, beginning with a short explanation and following with a description of the general OO architecture for the algorithm. Next, the code implementations are discussed and presented along with real-world examples that the author, an experienced software engineer, has used in a variety of commercial applications. On the enclosed CD-ROM, you'll find files containing tested source code implementations of all the algorithms discussed in the book in both Java and Smalltalk. This includes repository files for VisualAge for Java and VisualAge for Smalltalk under ENVY. * Reveals the design methodology behind the code, including design patterns where appropriate, rather than just presenting canned solutions. * Implements all methods side by side in both Java and Smalltalk. This contrast can significantly enhance your understanding of the nature of OO programming languages. * Provides a step-by-step pathway to new object-oriented techniques for programmers familiar with using procedural languages such as C or Fortran for numerical methods. * Includes a chapter on data mining, a key application of numerical methods.

More on Amazon.com

Mentioned in questions and answers.

Coming from a non-OO background in Matlab, I'm looking to perform some of the operations I am used to in a best-practice manner for C#.

I have a class, which imports data from a source, and formats it into, amongst other things, an array of ints. I am going to want to perform some operations on this array. To keep it simple, lets say I want to take the average of all the values. The way I see it, I have three options:

  • The array is part of MyClass, so I could extend MyClass to return the average of MyArray.double arrayAverage=MyClass.ArrayAve;
  • I could develop a static class, giving me access to the average by double arrayAverage= zotty.arrayMath.average(MyArray);

  • There is apparently some way in which I can inherit or interface so that I create a class specifically for performing such operations, which Id then be able to access by instantiating this new class, and passing it the array:

OperatorClass oc = new OperatorClass();

oc.data=MyClass.MyArray;

double arrayAverage = oc.ArrayAverage();

Extending the class seems risky, since it's also responsible for importing and formatting the data. I could become quite large if I add all the data processing to it too, and it wouldn't be straightforward for other people to add-to & work on alongside me.

Future code will require more complex operations on the array, and I've no idea what they will be at the moment. I will have use for some of the basic operations in future programs, which would be useful as part of the static class - the complex ones however would be redundant.

The separate class for performing the data processing allows the import/formatting class to remain isolated. It can provide both general and specific functions, but at the cost of instantiating another variable in the code, which seems to me to be a bit untidy.

I'd appreciate some input if you have thoughts on the matter!

I highly recommend picking up this book from Didier Besset on creating object oriented numerical methods. The concepts have been very helpful to me over the years. Even though the examples are in Java, the code transfers easily to C#.

-Scott

What are good resource to read up on for implementing numerical algorithms in pure java?

I know nothing about the interactions of the JVM & GC, and would love to learn more.

I enjoyed Object Oriented Implementation of Numerical Methods by Didier Besset. To be honest I use C++ almost exclusively but found this book interesting and fun nonetheless. It doesn't always use the best algorithm for the job, however.

I would also point you towards Matrix Computations by Golub & Van Loan. Not about Java by any means, but a mandatory text for anybody working in this area.

I am writing a program in java that models a carnot engine and I want to calculate the work done and I need to use integration. I have been looking around on google and haven't found quite what I am looking for, have any suggestions?

Look at Object-Oriented Implemenation of Numerical Methods, by Didier H Besset.

http://www.amazon.com/Object-Oriented-Implementation-Numerical-Methods-Introduction/dp/1558606793/ref=sr_1_1?ie=UTF8&s=books&qid=1260512473&sr=8-1

There are various equations you can use, depending on what you need, precisely.

This is a bit of a longshot.
Suppose I am sampling signal at a fixed rate (say once per second).
Is there mathematical Java Library I can use to calculate/extract the following metrics from the sampled data?
1) The rate of change of the signal
2) An extrapolation/prediction of what the signal value will be in X seconds/minutes time
Thanks

If you need some equations you can look at

Object-Oriented Implementatin of Numerical Methods by Didier Besset. http://www.amazon.com/Object-Oriented-Implementation-Numerical-Methods-Introduction/dp/1558606793/ref=sr_1_1?ie=UTF8&s=books&qid=1257821447&sr=8-1

This is mainly for your second part, as, depending on how you want to predict you may need various equations to get a better idea, if you are trying to do a best fit, then extend.

For the first part, I think that has been sufficiently dealt with, determine the slope.