Re: [Vala] [Fwd: Re: 2D Static Array]
- From: JM <interflug1 gmx net>
- To: michele cremasco <michele cremasco gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] [Fwd: Re: 2D Static Array]
- Date: Tue, 20 Apr 2010 18:22:28 +0200
Using methods with syntax support. That's a nice one!
Regards
Am Dienstag, den 20.04.2010, 16:21 +0200 schrieb michele cremasco:
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]