Exemplo n.º 1
0
 public static GVector<GVolumeInformations> GetVolumes()
 {
     GVector<GVolumeInformations> list = new GVector<GVolumeInformations>();
     String[] drives = Environment.GetLogicalDrives();
     UInt32 i = 0;
     while (i < drives.Length)
     {
         GVolumeInformations t = new GVolumeInformations(drives[i]);
         list.PushBack(t);
         ++i;
     }
     return (list);
 }
Exemplo n.º 2
0
 public static GVector<GProcessus> GetProcessus()
 {
     System.Diagnostics.Process[] prc = Process.GetProcesses();
     UInt32 i = 0;
     GVector<GProcessus> list = new GVector<GProcessus>();
     while (i < prc.Length)
     {
         GProcessus p = new GProcessus(prc[i]);
         list.PushBack(p);
         ++i;
     }
     return (list);
 }
Exemplo n.º 3
0
 public GVector<GFileInfos> Ls()
 {
     String[] files;
     files = Directory.GetFileSystemEntries(this._directory);
     int filecount = files.GetUpperBound(0) + 1;
     GVector<GFileInfos> list = new GVector<GFileInfos>();
     int i = 0;
     while (i < filecount)
     {
         GFileInfos f = new GFileInfos(this._directory + "\\" + files[i]);
         list.PushBack(f);
         ++i;
     }
     return (list);
 }
Exemplo n.º 4
0
 public GVector GetGVector()
 {
     GVector ret = new GVector();
     HTCGSensorData data = GetRawSensorData();
     ret.X = data.TiltX;
     ret.Y = data.TiltY;
     ret.Z = data.TiltZ;
     // HTC's Sensor returns a vector which is around 1000 in length on average..
     // but it really depends on how the device is oriented.
     // When simply face up, my Diamond returns a vector of around 840 in length.
     // While face down, it returns a vector of around 1200 in length.
     // The vector direction is fairly accurate, however, the length is clearly not extremely precise.
     double htcScaleFactor = 1.0 / 1000.0 * 9.8;
     return ret.Scale(htcScaleFactor);
 }
Exemplo n.º 5
0
 /// <summary>Places the values of the specified row into the vector parameter.</summary>
 /// <remarks>Places the values of the specified row into the vector parameter.</remarks>
 /// <param name="row">the target row number</param>
 /// <param name="vector">the vector into which the row values will be placed</param>
 public void GetRow(int row, GVector vector)
 {
     if (vector.GetSize() < nCol)
     {
         vector.SetSize(nCol);
     }
     for (int i = 0; i < nCol; i++)
     {
         vector.values[i] = values[row][i];
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Copy the values from the vector into the specified row of this
 /// matrix.
 /// </summary>
 /// <remarks>
 /// Copy the values from the vector into the specified row of this
 /// matrix.
 /// </remarks>
 /// <param name="row">
 /// the row of this matrix into which the array values
 /// will be copied
 /// </param>
 /// <param name="vector">the source vector</param>
 public void SetRow(int row, GVector vector)
 {
     for (int i = 0; i < nCol; i++)
     {
         values[row][i] = vector.values[i];
     }
 }
Exemplo n.º 7
0
 /// <summary>Places the values of the specified column into the vector parameter.</summary>
 /// <remarks>Places the values of the specified column into the vector parameter.</remarks>
 /// <param name="col">the target column number</param>
 /// <param name="vector">the vector into which the column values will be placed</param>
 public void GetColumn(int col, GVector vector)
 {
     if (vector.GetSize() < nRow)
     {
         vector.SetSize(nRow);
     }
     for (int i = 0; i < nRow; i++)
     {
         vector.values[i] = values[i][col];
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Computes the outer product of the two vectors; multiplies the
 /// the first vector by the transpose of the second vector and places
 /// the matrix result into this matrix.
 /// </summary>
 /// <remarks>
 /// Computes the outer product of the two vectors; multiplies the
 /// the first vector by the transpose of the second vector and places
 /// the matrix result into this matrix.  This matrix must be
 /// be as big or bigger than getSize(v1)xgetSize(v2).
 /// </remarks>
 /// <param name="v1">the first vector, treated as a row vector</param>
 /// <param name="v2">the second vector, treated as a column vector</param>
 public void Mul(GVector v1, GVector v2)
 {
     int i;
     int j;
     if (nRow < v1.GetSize())
     {
         throw new MismatchedSizeException("GMatrix.mul(GVector, GVector): matrix does not have enough rows");
     }
     if (nCol < v2.GetSize())
     {
         throw new MismatchedSizeException("GMatrix.mul(GVector, GVector): matrix does not have enough columns");
     }
     for (i = 0; i < v1.GetSize(); i++)
     {
         for (j = 0; j < v2.GetSize(); j++)
         {
             values[i][j] = v1.values[i] * v2.values[j];
         }
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Copy the values from the vector into the specified column of this
 /// matrix.
 /// </summary>
 /// <remarks>
 /// Copy the values from the vector into the specified column of this
 /// matrix.
 /// </remarks>
 /// <param name="col">
 /// the column of this matrix into which the array values
 /// will be copied
 /// </param>
 /// <param name="vector">the source vector</param>
 public void SetColumn(int col, GVector vector)
 {
     for (int i = 0; i < nRow; i++)
     {
         values[i][col] = vector.values[i];
     }
 }
Exemplo n.º 10
0
 public static void Print(GVector vector)
 {
     Console.WriteLine("[ " + vector.x + ", " + vector.y + " ]");
 }
Exemplo n.º 11
0
 /// <summary>
 /// LU Decomposition: this matrix must be a square matrix and the
 /// LU GMatrix parameter must be the same size as this matrix.
 /// </summary>
 /// <remarks>
 /// LU Decomposition: this matrix must be a square matrix and the
 /// LU GMatrix parameter must be the same size as this matrix.
 /// The matrix LU will be overwritten as the combination of a
 /// lower diagonal and upper diagonal matrix decompostion of this
 /// matrix; the diagonal
 /// elements of L (unity) are not stored.  The GVector parameter
 /// records the row permutation effected by the partial pivoting,
 /// and is used as a parameter to the GVector method LUDBackSolve
 /// to solve sets of linear equations.
 /// This method returns +/- 1 depending on whether the number
 /// of row interchanges was even or odd, respectively.
 /// </remarks>
 /// <param name="Lu">
 /// The matrix into which the lower and upper decompositions
 /// will be placed.
 /// </param>
 /// <param name="permutation">
 /// The row permutation effected by the partial
 /// pivoting
 /// </param>
 /// <returns>
 /// +-1 depending on whether the number of row interchanges
 /// was even or odd respectively
 /// </returns>
 public int Lud(GMatrix Lu, GVector permutation)
 {
     int size = Lu.nRow * Lu.nCol;
     double[] temp = new double[size];
     int[] even_row_exchange = new int[1];
     int[] row_perm = new int[Lu.nRow];
     int i;
     int j;
     if (nRow != nCol)
     {
         throw new MismatchedSizeException("cannot perform LU decomposition on a non square matrix");
     }
     if (nRow != Lu.nRow)
     {
         throw new MismatchedSizeException("LU must have same dimensions as this matrix");
     }
     if (nCol != Lu.nCol)
     {
         throw new MismatchedSizeException("LU must have same dimensions as this matrix");
     }
     if (Lu.nRow != permutation.GetSize())
     {
         throw new MismatchedSizeException("row permutation must be same dimension as matrix");
     }
     for (i = 0; i < nRow; i++)
     {
         for (j = 0; j < nCol; j++)
         {
             temp[i * nCol + j] = values[i][j];
         }
     }
     // Calculate LU decomposition: Is the matrix singular?
     if (!LuDecomposition(Lu.nRow, temp, row_perm, even_row_exchange))
     {
         // Matrix has no inverse
         throw new SingularMatrixException("cannot invert matrix");
     }
     for (i = 0; i < nRow; i++)
     {
         for (j = 0; j < nCol; j++)
         {
             Lu.values[i][j] = temp[i * nCol + j];
         }
     }
     for (i = 0; i < Lu.nRow; i++)
     {
         permutation.values[i] = (double)row_perm[i];
     }
     return even_row_exchange[0];
 }
Exemplo n.º 12
0
 /// <summary>
 /// casts this vector onto aOther.
 /// can be used to find the angle between two vectors
 /// </summary>
 1public float Dot(GVector aOther)
 {
     return(x * aOther.x + y * aOther.y);
 }
Exemplo n.º 13
0
 public GVector Div(GVector aOther)
 {
     return(new GVector(x / aOther.x, y / aOther.y));
 }
Exemplo n.º 14
0
 public GVector Mult(GVector aOther)
 {
     return(new GVector(x * aOther.x, y * aOther.y));
 }
Exemplo n.º 15
0
 public GVector Sub(GVector aOther)
 {
     return(new GVector(x - aOther.x, y - aOther.y));
 }
Exemplo n.º 16
0
 public GVector Add(GVector aOther)
 {
     return(new GVector(x + aOther.x, y + aOther.y));
 }