Re: [Vala] [Fwd: Re: 2D Static Array]
- From: michele cremasco <michele cremasco gmail com>
- To: JM <interflug1 gmx net>, vala-list gnome org
- Subject: Re: [Vala] [Fwd: Re: 2D Static Array]
- Date: Tue, 20 Apr 2010 16:21:58 +0200
It works, but it is not what I want.
Now I have tried this solution:
[Compact]
public class Matrix
{
public float mat[16];
public inline float get(int row, int col)
{
return mat[row*4 + col];
}
public inline void set(int row, int col, float val)
{
mat[row*4 + col] = val;
}
public Matrix()
{
}
public Matrix.identity()
{
this[0, 0] = 1.0f;
this[1, 1] = 1.0f;
this[2, 2] = 1.0f;
this[3, 3] = 1.0f;
}
}
It work very well and also I can use the square brackets notation directly
on the matrix object! Wow!
Inline functions must be declared before their first use, so get() and set()
now are the first method declared.
I test the resulting matrix performance looping for 10'000'000 times a
transpose operation.
Without compiler optimization, inlined and not inlined version has no
differences.
Activating the optimization (-X -O2) the inline versione is 2.5 times
faster.
So they work.
bye ;-)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]