The Source for Java Technology Collaboration
User: Password:



Alexander Schunk's Blog

August 2007 Archives


LinAlg API: Milestone 1 update 2

Posted by alexanderschunk on August 30, 2007 at 12:36 PM | Permalink | Comments (1)

New Features

This is update 2 of Milestone 1 i presented earlier. If you wonder why this is update 2 this has several reasons.

First, i have added several new Methods to the classes in particular to the Complex and Matrix class.

There are still some nice Features missing concerning Vector and Matrix conversions etc. but this will be added in future updates and Milestones.

Another reason is that LinAlg API is now available under two Licenses: GPL 2 and CDDL. The GPL 2 license can be used for people that love writing OpenSourc code and and want to use it as OpenSource Software. The CDDL license is for those people that dont want to be bound to GPL 2 and just want to use LinAlg API on an as is basis without the need to publish their code under GPL too.

Both API versions are technically the same, so, no matter if you use the GPL or CDDL version, you always get the full set of features.

Now, i will tell you a bit about implementatoin details, the new stuff i have added and other things that might be of interest for you.

Implementation details

In my last entries some people asked me about implementation details and why i did the why i did. To give you an answer to the last question: when I started i wanted to use a strict OOP design - as its used in the Java SDK for instance - and use concrete classes for concrete objects and abstract classes and interfaces for data abstraction.

So, basically, all types used in LinAlg are concrete classes. That means that you can (i) use them like any other object or class and (ii) that you can derive your own classes from them without worrying about their implementation.

The following is an example of the Vector3D class:

public class Vector3D 
extends BasicVector{
    
    public double x;
    
     public double y;
    
    public double z;
     
    public double w;
    
    public Vector3D(){
       //nothing 
    }
    
    public Vector3D(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
        
    }
     
    public Vector3D(double x, double y, double z, double w){
        this.x = x;
        this.y = y;
        this.z = z;
        this.w = w;
    }
    public Vector3D scalarMul(double s){       
        return new Vector3D(this.x * s, this.y * s, this.z * s);
    }

   public Vector3D add(Vector3D u){
        return new Vector3D(this.x + u.x, this.y + u.y, this.z + u.z);
        
    }
   public Vector3D mul(Vector3D u){
        return new Vector3D(this.x* u.x, this.y * u.y, this.z * u.z);
        
    }
   
  public Vector3D div(Vector3D u){
        return new Vector3D(this.x/ u.x, this.y / u.y, this.z / u.z);
    }

This does not show all methods but you can an idea of how the methods were implemented. If you think this implementation is not good or should be replaced by a different one, well, you are free to download the GPL version and modify it.

As you see from above, the methods, in particular methods that perform basic operations are implemented in a way that you can concatenate them. That is, those methods return a new object of the particular type with the computed values.

This design is used for all classes of LinAlg API.

New Features

I have added some useful utility methods to the Complex class and operations like Division of Complex numbers. Also i have added some new features to the Matrix class. Now its possible to compute the Determinant of any 4 x 4 Matrix.

The following list sums up the new features of LinAlg API:

  • createFromEuler(), createFromTrigo(), getCos(), getSin(), getTan()
  • det2(), scale(), translate()

The first methods are part of the Complex class. Now its possible to create a Complex number from Euler notation using ei*phi and from trigonometric functions using cos(phi)+isin(phi).

The getCos(), getSin() and getTan() methods return the sin(), cos() and tan() of Complex numbers.

You can use thes methods like the Vector methods presented before:

Matrix m = new Matrix(2, 3, 4, 5, 2);

m.det2(); // compute Determinant
Vector3D u = new Vector3D(2, 1, 1);
m.scale(u); //scale m by u
Vector3D v = new Vector3D(1, 3, 1);
m.translate(v); //translate m by v
Complex c = new Complex();
c.createFromEuler(30); // ei*phi
Complex d = new Complex();
d.createFromTrigo(1, 2, 30); //1 = real, 2 = imaginary and 30 = radian

For the createFromEuler() method you need to specify the angle for e function.This also goes for the createFromTrigo() method.

Things to come

I have found a few intersting Tutorials at Intels developer website for using SIMD instructions. It looks like the new SIMD3 instruction set supports Complex number operations, so this may be used for implementing fast complex number operations.

I am not aware about AMDs 3DNOW features but i will Google at the week end.



LinAlg API: Licenses

Posted by alexanderschunk on August 29, 2007 at 07:38 AM | Permalink | Comments (0)

LinAlg API: Dual license-ship

In previous Blogs on LinAlg API i have received questions concerning licenses. Some people fear or dont want to be bound to GPL 2 license because they dont want to opensource their software too.

This is reasonable in particular if you are in the commercial world. To make use of LinAlg API easier for those people i have opted to choose CDDL license - Common Development and Distribution License - which does not imply users to publish their software as opensource and under GPL 2.

The CDDL allows you to use LinAlg API without publishing it under GPL 2 nor publishing it as opensource software. Also you can link to LinAlg API and use this as a library.

In any case, using two licenses makes life easier - both for me and for users of LinAlg API. I think this is also the reason why SUN uses two different licenses.

In the next update of LinAlg for Milestone 1 - which will be released at weekend - it will be shipped with a CDDL License in PDF format.



LinAlg API: Milestone 1 release

Posted by alexanderschunk on August 27, 2007 at 02:12 PM | Permalink | Comments (4)

LinAlg API: Scope, Features, Whichlist

In my previous Blogs on LinAlg API i already received some nice compliments and also some thoughtful advises. Both were helpful in development and help me understand the need and requirements of the community. Therefore i would like to thank you anyone who gave advise and or suggestions.

Baering all this in mind i have fixed some Bugs and added the missing features of this API. As i have written in my headline, this is Milestone 1 of LinAlg which means that development of this API will continue, no matter if and where it will be used in the final end.

Since LinAlg is released under GPL 2 you are free to redistribute, copy and use it as you which. So any help from the community to improve this API and its features is welcome. You do not need to be a Math professional to implement such an API. What you need is programming skills and a good reference book for Math on linear Algebra.

Features

Last time i have already outlined the features of the missing Matrix class and the Vector implementation. Today and over the week end i have extended the Matrix class so it can work with 3D Vectors.

Besides the basic Matrix operations i have outlined before the Matrix class now offers the following features:

For example its possible now to mulitply a Matrix by a 3D Vector and to create a Matrix from a 3D Vector. This also required a redesign of the Vector3D class so the Matrix class can work with it.

Also i have added further Constructors so it is possible to create different kind of Matrices.

The following examples show what you can do with LinAlg Milestone 1:

     Vector3D x = new Vector3D(1,3 ,4);
     Vector3D y = new Vector3D(2, 4, 1);
     Vector3D t = new Vector3D(1, 1, 1);
     Vector3D u = x.add(y);
     Vector3D z = x.add(y).add(t).scalarMul(2);
     Matrix m = new Matrix(z);
     Matrix k = new Matrix(3, 2, 3, 1);
     double det = k.det();
     double det2 = m.det();
     Matrix l = m.vectorMul(x);

One thing thats nice is - because all methods return references of the specific type - that you can concatenate methods as in this example where you can add three Vectors in a single line:

 Vector3D z = x.add(y).add(t).scalarMul(2);

In this line you add Vectors x, y, t and multiply the result by 2 given the Vectors specified above. The result is [8.0 16.0 12.0].

Another thing you can do is to calculate the Determinant of a Matrix:

 
     Matrix m = new Matrix(z);
     Matrix k = new Matrix(3, 2, 3, 1);
     double det = k.det();
     double det2 = m.det();
     Matrix l = m.vectorMul(x);

In this example you have two Matrices. The first is created by the Vector z from the example above. The second is a simple 2x2 Matrix. The next two lines determine the Determinant using the following formula: det(A) = m11*m22-m21*m12.

In the last line Matrix l is multiplied by Vector x.

Of course the examples above only show only a fraction of LinAlg fetures. You can also rotate a Matrix around the three Axes by a specified angle. For example you can rotate a Matrix first around X-Axis, then around Z-Axis and finally around Y-Axis:

  Matrix p = m.RotX(30).rotZ(10).RotY(20);

This is, again, possible because the methods return references of type Matrix.

LinAlg API: Code organization

To give LinAlg a more professional look and feel and organization of the code i have reorganized the package structure. With LinAlg API Milestone 1 the classes mentioned before are now hold into a seperate package with a corresponding name. So the Matrix class is hold in a package named matrix and the Vector classes are hold in a package namedVector.

License

LinAlg API Milestone 1 is published under GPL version 2.

Todo

Since the scope of LinAlg API is - compared to other APIs mentioned before - rather narrow and more general the Todo list of LinAlg is not so long as of other APIs offering similar features. However one or another feature will sure show up in the Todo list so stay tune for updates.

LinAlg API Milestone 1 will be available at linalg.dev.java.net.



Java Consumer JRE: really a winner

Posted by alexanderschunk on August 22, 2007 at 12:06 PM | Permalink | Comments (9)

Consumer JRE: a real winner

No, i dont want to get too optimisitc nor enthusiastic but the changes of Java 6 described in Chets Blog really look great.

According to Chet, one of the next coming Java 6 updates will include the following features:

  • Quickstarter
  • Java kernel Project
  • Nimbus look and feel
  • new Windows graphics pipeline
  • other improvements

Personally, i think Quickstarter and Java kernel are the two main improvements. Nimbus look and feel looks great. Just have a look at the screenshots in the Blog.

The other improvements on the installer and the like just seem to be of cosmetic nature but i want to test Quickstarter and Java Kernel as soon as possible.

Great Work guys.





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds