2009-01-19 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 19 Jan 2009 19:47:35 +0000 (19:47 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 19 Jan 2009 19:47:35 +0000 (19:47 -0000)
* Vector*.cs: Add ToString, single element constructors
and some helper constants.

svn path=/trunk/mcs/; revision=123824

mcs/class/Mono.Simd/Mono.Simd/Changelog
mcs/class/Mono.Simd/Mono.Simd/Vector16b.cs
mcs/class/Mono.Simd/Mono.Simd/Vector16sb.cs
mcs/class/Mono.Simd/Mono.Simd/Vector2d.cs
mcs/class/Mono.Simd/Mono.Simd/Vector2l.cs
mcs/class/Mono.Simd/Mono.Simd/Vector2ul.cs
mcs/class/Mono.Simd/Mono.Simd/Vector4f.cs
mcs/class/Mono.Simd/Mono.Simd/Vector4i.cs
mcs/class/Mono.Simd/Mono.Simd/Vector4ui.cs
mcs/class/Mono.Simd/Mono.Simd/Vector8s.cs
mcs/class/Mono.Simd/Mono.Simd/Vector8us.cs

index 4eac9ea0e02e0c91d66b89f4fe20c2aec9488b51..e3b27986eae77642bbe187c8eaebb1683e881120 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-19 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Vector*.cs: Add ToString, single element constructors
+       and some helper constants.
+
 2009-01-07 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * Vector*.cs: Use explicit layout to avoid the runtime
index 09d874089b292a057f127d814e0f7b1df52d793c..e626959aa1fb2b8e5abb583d369ac48d0b466892 100644 (file)
@@ -82,7 +82,28 @@ namespace Mono.Simd
                        this.v12 = v12;
                        this.v13 = v13;
                        this.v14 = v14;
-                       this.v15 = v15;         }
+                       this.v15 = v15;
+               }
+               
+               public Vector16b (byte b)
+               {
+                       this.v0 = b;
+                       this.v1 = b;
+                       this.v2 = b;
+                       this.v3 = b;
+                       this.v4 = b;
+                       this.v5 = b;
+                       this.v6 = b;
+                       this.v7 = b;
+                       this.v8 = b;
+                       this.v9 = b;
+                       this.v10 = b;
+                       this.v11 = b;
+                       this.v12 = b;
+                       this.v13 = b;
+                       this.v14 = b;
+                       this.v15 = b;
+               }
 
                public byte V0 { get { return v0; } set { v0 = value; } }
                public byte V1 { get { return v1; } set { v1 = value; } }
@@ -101,6 +122,16 @@ namespace Mono.Simd
                public byte V14 { get { return v14; } set { v14 = value; } }
                public byte V15 { get { return v15; } set { v15 = value; } }
 
+               public static Vector16b One
+               {
+                       get {return new Vector16b (1); }
+               }
+
+               public static Vector16b Zero
+               {
+                       get {return new Vector16b (0); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe byte this [int index]
                {
@@ -348,5 +379,13 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector16b *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
+                                       v4 + ", " + v5 + ", " + v6 + ", " + v7 + ", " + 
+                                       + v8 + ", " + v9 + ", " + v10 + ", " + v11 + ", " +
+                                       v12 + ", " + v13 + ", " + v14 + ", " + v15 + ">"; 
+               }
        }
 }
index faff838b615e5f1d790b1dce9101de5b88d4f2b2..e0dc37effe2946bae177b0facd6cc1d7df2e53ad 100644 (file)
@@ -83,7 +83,28 @@ namespace Mono.Simd
                        this.v12 = v12;
                        this.v13 = v13;
                        this.v14 = v14;
-                       this.v15 = v15;         }
+                       this.v15 = v15;
+               }
+               
+               public Vector16sb (sbyte sb)
+               {
+                       this.v0 = sb;
+                       this.v1 = sb;
+                       this.v2 = sb;
+                       this.v3 = sb;
+                       this.v4 = sb;
+                       this.v5 = sb;
+                       this.v6 = sb;
+                       this.v7 = sb;
+                       this.v8 = sb;
+                       this.v9 = sb;
+                       this.v10 = sb;
+                       this.v11 = sb;
+                       this.v12 = sb;
+                       this.v13 = sb;
+                       this.v14 = sb;
+                       this.v15 = sb;
+               }
 
                public sbyte V0 { get { return v0; } set { v0 = value; } }
                public sbyte V1 { get { return v1; } set { v1 = value; } }
@@ -102,6 +123,21 @@ namespace Mono.Simd
                public sbyte V14 { get { return v14; } set { v14 = value; } }
                public sbyte V15 { get { return v15; } set { v15 = value; } }
 
+               public static Vector16sb One
+               {
+                       get { return new Vector16sb (1); }
+               }
+
+               public static Vector16sb Zero
+               {
+                       get { return new Vector16sb (0); }
+               }
+
+               public static Vector16sb MinusOne
+               {
+                       get { return new Vector16sb (-1); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe sbyte this [int index]
                {
@@ -343,5 +379,13 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector16sb *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
+                                       v4 + ", " + v5 + ", " + v6 + ", " + v7 + ", " + 
+                                       + v8 + ", " + v9 + ", " + v10 + ", " + v11 + ", " +
+                                       v12 + ", " + v13 + ", " + v14 + ", " + v15 + ">"; 
+               }
        }
 }
index 385d36961fd8f5e5a04c1d9e37a3f4276da06e70..9c57b793928aef0a7a454e5b5d0339a9709c2841 100644 (file)
@@ -42,6 +42,31 @@ namespace Mono.Simd
                public double X { get { return x; } set { x = value; } }
                public double Y { get { return y; } set { y = value; } }
 
+               public static Vector2d Pi 
+               {
+                       get { return new Vector2d (System.Math.PI); }
+               }
+
+               public static Vector2d E 
+               {
+                       get { return new Vector2d (System.Math.E); }
+               }
+
+               public  static Vector2d One 
+               {
+                       get { return new Vector2d (1); }
+               }
+
+               public  static Vector2d Zero 
+               {
+                       get { return new Vector2d (0); }
+               }
+
+               public  static Vector2d MinusOne 
+               {
+                       get { return new Vector2d (-1); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe double this [int index]
                {
@@ -67,6 +92,12 @@ namespace Mono.Simd
                        this.y = y;
                }
 
+               public Vector2d (double d)
+               {
+                       this.x = d;
+                       this.y = d;
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static unsafe Vector2d operator & (Vector2d v1, Vector2d v2)
                {
@@ -274,5 +305,10 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector2d *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + x + ", " + y + ">"; 
+               }
        }
 }
index 9806c11b3b0dda7cce1fa06e5b4040c0f8f9e65e..0e5a1d80e2f634333c7f57a35b73f4eaed3a51e9 100644 (file)
@@ -40,6 +40,21 @@ namespace Mono.Simd
                public long X { get { return x; } set { x = value; } }
                public long Y { get { return y; } set { y = value; } }
 
+               public static Vector2l One
+               {
+                       get { return new Vector2l (1); }
+               }
+
+               public static Vector2l Zero
+               {
+                       get { return new Vector2l (0); }
+               }
+
+               public static Vector2l MinusOne
+               {
+                       get { return new Vector2l (-1); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe long this [int index]
                {
@@ -65,6 +80,12 @@ namespace Mono.Simd
                        this.y = y;
                }
 
+               public Vector2l (long l)
+               {
+                       this.x = l;
+                       this.y = l;
+               }
+
                [Acceleration (AccelMode.SSE2)]
                public static Vector2l operator + (Vector2l v1, Vector2l v2)
                {
@@ -241,5 +262,10 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector2l *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + x + ", " + y + ">"; 
+               }
        }
 }
index 73fedd8e9d1091a021c6c6271725e13838273bd4..de273f596b62fae978e96716f2e992f5638de56c 100644 (file)
@@ -41,6 +41,16 @@ namespace Mono.Simd
                public ulong X { get { return x; } set { x = value; } }
                public ulong Y { get { return y; } set { y = value; } }
 
+               public static Vector2ul One
+               {
+                       get { return new Vector2ul (1); }
+               }
+
+               public static Vector2ul Zero
+               {
+                       get { return new Vector2ul (0); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe ulong this [int index]
                {
@@ -65,6 +75,12 @@ namespace Mono.Simd
                        this.x = x;
                        this.y = y;
                }
+               
+               public Vector2ul (ulong ul)
+               {
+                       this.x = ul;
+                       this.y = ul;
+               }
 
                [Acceleration (AccelMode.SSE2)]
                public static Vector2ul operator + (Vector2ul v1, Vector2ul v2)
@@ -242,5 +258,10 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector2ul *res)
                {
                }
+               public override string ToString()
+               {
+                       return "<" + x + ", " + y + ">"; 
+               }
+               
        }
 }
index a5273069c50287810c299c4307ac4e917d61e175..77ba2cd6def328504fde43dabe8d54f3660ce61d 100644 (file)
@@ -103,6 +103,31 @@ namespace Mono.Simd
                public float Z { get { return z; } set { z = value; } }
                public float W { get { return w; } set { w = value; } }
 
+               public static Vector4f Pi 
+               {
+                       get { return new Vector4f ((float)System.Math.PI); }
+               }
+
+               public static Vector4f E 
+               {
+                       get { return new Vector4f ((float)System.Math.E); }
+               }
+
+               public  static Vector4f One 
+               {
+                       get { return new Vector4f (1); }
+               }
+
+               public  static Vector4f Zero 
+               {
+                       get { return new Vector4f (0); }
+               }
+
+               public  static Vector4f MinusOne 
+               {
+                       get { return new Vector4f (-1); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe float this [int index]
                {
@@ -129,6 +154,14 @@ namespace Mono.Simd
                        this.z = z;
                        this.w = w;
                }
+               
+               public Vector4f (float f)
+               {
+                       this.x = f;
+                       this.y = f;
+                       this.z = f;
+                       this.w = f;
+               }
 
                [Acceleration (AccelMode.SSE1)]
                public static unsafe Vector4f operator & (Vector4f v1, Vector4f v2)
@@ -348,5 +381,10 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector4f *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + x + ", " + y + ", " + z + ", " + w + ">"; 
+               }
        }
 }
index 47103699a6717852fc6795333061fbc8e3e78063..aa5ee39d697716244c4439b01230101895748295 100644 (file)
@@ -46,6 +46,21 @@ namespace Mono.Simd
                public int Z { get { return z; } set { z = value; } }
                public int W { get { return w; } set { w = value; } }
 
+               public static Vector4i Identity
+               {
+                       get { return  new Vector4i (1); }
+               }
+
+               public static Vector4i Zero
+               {
+                       get { return  new Vector4i (0); }
+               }
+
+               public static Vector4i MinusOne
+               {
+                       get { return new Vector4i (-1); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe int this [int index]
                {
@@ -72,6 +87,14 @@ namespace Mono.Simd
                        this.z = z;
                        this.w = w;
                }
+               
+               public Vector4i (int i)
+               {
+                       this.x = i;
+                       this.y = i;
+                       this.z = i;
+                       this.w = i;
+               }
 
                [Acceleration (AccelMode.SSE2)]
                public static Vector4i operator + (Vector4i v1, Vector4i v2)
@@ -274,5 +297,10 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector4i *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + x + ", " + y + ", " + z + ", " + w + ">"; 
+               }
        }
 }
index ee2119ab3e13698b088676137587dd442ce99d82..c62365c61a3337906905f93b8f3ee23b9c04d23d 100644 (file)
@@ -47,6 +47,16 @@ namespace Mono.Simd
                public uint Z { get { return z; } set { z = value; } }
                public uint W { get { return w; } set { w = value; } }
 
+               public static Vector4ui Identity
+               {
+                       get { return  new Vector4ui (1); }
+               }
+
+               public static Vector4ui Zero
+               {
+                       get { return  new Vector4ui (0); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe uint this [int index]
                {
@@ -73,6 +83,14 @@ namespace Mono.Simd
                        this.z = z;
                        this.w = w;
                }
+               
+               public Vector4ui (uint ui)
+               {
+                       this.x = ui;
+                       this.y = ui;
+                       this.z = ui;
+                       this.w = ui;
+               }
 
                [Acceleration (AccelMode.SSE2)]
                public static Vector4ui operator + (Vector4ui v1, Vector4ui v2)
@@ -268,5 +286,10 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector4ui *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + x + ", " + y + ", " + z + ", " + w + ">"; 
+               }
        }
 }
index 0d48cf0a770d87cd8f97135cdba64d25733958dc..be178470a85e19f302f9cbffe4419624c7bc2e2e 100644 (file)
@@ -60,6 +60,18 @@ namespace Mono.Simd
                        this.v6 = v6;
                        this.v7 = v7;
                }
+               
+               public Vector8s (short s)
+               {
+                       this.v0 = s;
+                       this.v1 = s;
+                       this.v2 = s;
+                       this.v3 = s;
+                       this.v4 = s;
+                       this.v5 = s;
+                       this.v6 = s;
+                       this.v7 = s;
+               }
 
                public short V0 { get { return v0; } set { v0 = value; } }
                public short V1 { get { return v1; } set { v1 = value; } }
@@ -70,6 +82,21 @@ namespace Mono.Simd
                public short V6 { get { return v6; } set { v6 = value; } }
                public short V7 { get { return v7; } set { v7 = value; } }
 
+               public static Vector8s Identity
+               {
+                       get { return  new Vector8s (1); }
+               }
+
+               public static Vector8s Zero
+               {
+                       get { return  new Vector8s (0); }
+               }
+
+               public static Vector8s MinusOne
+               {
+                       get { return new Vector8s (-1); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe short this [int index]
                {
@@ -352,5 +379,11 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector8s *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
+                                       v4 + ", " + v5 + ", " + v6 + ", " + v7 + ">"; 
+               }
        }
 }
index ec4f2a5e394904cb884e511532eac81cc193766f..2c9afd33c0b3076ff0180196ed3f32a12558f5a5 100644 (file)
@@ -61,6 +61,18 @@ namespace Mono.Simd
                        this.v6 = v6;
                        this.v7 = v7;
                }
+               
+               public Vector8us (ushort us)
+               {
+                       this.v0 = us;
+                       this.v1 = us;
+                       this.v2 = us;
+                       this.v3 = us;
+                       this.v4 = us;
+                       this.v5 = us;
+                       this.v6 = us;
+                       this.v7 = us;
+               }
 
                public ushort V0 { get { return v0; } set { v0 = value; } }
                public ushort V1 { get { return v1; } set { v1 = value; } }
@@ -71,6 +83,16 @@ namespace Mono.Simd
                public ushort V6 { get { return v6; } set { v6 = value; } }
                public ushort V7 { get { return v7; } set { v7 = value; } }
 
+               public static Vector8us Identity
+               {
+                       get { return  new Vector8us (1); }
+               }
+
+               public static Vector8us Zero
+               {
+                       get { return  new Vector8us (0); }
+               }
+
                [System.Runtime.CompilerServices.IndexerName ("Component")]
                public unsafe ushort this [int index]
                {
@@ -351,5 +373,11 @@ namespace Mono.Simd
                public static unsafe void PrefetchNonTemporal (Vector8us *res)
                {
                }
+               
+               public override string ToString()
+               {
+                       return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
+                                       v4 + ", " + v5 + ", " + v6 + ", " + v7 + ">"; 
+               }
        }
 }