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 ;-)


_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to