LinAlg API: Milestone 1 update 2
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 e^{i*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); // e^{i*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.
- Login or register to post comments
- Printer-friendly version
- aschunkjava's blog
- 758 reads