Skip to content
axelanglet edited this page May 11, 2017 · 22 revisions

This project is a utility project, which gathers commons classes/methods from different projects.
To use classes/methods for a project you'll need to add a reference from this project and this using directive :

  using Hybridizer.Basic.Utilities

Naive Matrix Class

This class is a simple matrix class with one attribute: an 1D array of float and two properties: the height and the width of the matrix.
You can create an Matrix with your height and width or use the default constructor to have a 1024*1024 matrix.

  NaiveMatrix a = new NaiveMatrix();
  NaiveMatrix b = new NaiveMatrix(5,5); //use a matrix 5*5

The matrix can be filled with some random float that are between two values (default is between 0 and 1), you can access on a value with the following syntax : matrix[indice]

  a.FillMatrix(); 
  b.FillMatrix(1.0f,1.0f);
  float c = b[4] ;

You can Write the matrix on the console.

  b.WriteMatrix();

  /* the display will be the following:
   * 1  1  1  1  1
   * 1  1  1  1  1
   * 1  1  1  1  1
   * 1  1  1  1  1
   * 1  1  1  1  1 */

Random Extension

This class is an extension to the random class, we implement a random for float, float2 and float4 type . There is a default value that are between 0 and 1.

  Random a = new random(Guid.NewGuid().GetHashCode()); 
  float f1 = a.NextFloat();
  float2 f2 = a.NextFloat2();
  float4 f4 = a.nextFloat4(10.0f,15.0f);

Vector Operation

This class regroup three basics operation between 1D arrays of float, there are the addition, the substration and the multiplication between a float and an array.

  float[] a = new float[5] {1,2,3,4,5};
  float[] b = new float[5] {10,20,30,40,50};
  float[] add = VectorOperation.AddVector(a,b); // {11,22,33,44,55}
  float[] sub = VectorOperation.SubstractVector(b,a); // {9,18,27,36,45}
  float[] multiply = VectorOperation.Multiply(5,a); // {5,10,15,20,25}

Vector Reader

This class is used to create some 1D arrays of float and specialy from a mtx file like those which we can find here.

  float[] random = VectorReader.GetRandomVector(10); // array of 10 float with values between 0 and 1
  float[] flat = VectorReader.GetFlatVector(10, 4); // {4,4,4,4,4,4,4,4,4,4}
  float[] fromFile = VectorReader.ReadVectorFromFile("PathToMtxFile"); //generate the vector corresponding to the mtx file.

Home Hello World
Clone this wiki locally