Beispiel #1
0
 public void Setup()
 {
     _matrix       = BuildMatrix.RandomInt(1024, 1024, 0, 20);
     _matrixByte   = BuildMatrix.RandomByte(1024, 1024, 0, 20);
     _matrixFloat  = BuildMatrix.RandomFloat(1024, 1024, 0, 20);
     _matrixDouble = BuildMatrix.RandomDouble(1024, 1024, 0, 20);
 }
Beispiel #2
0
        public static string Run()
        {
            StringBuilder builder = new StringBuilder();
            // initialize random matrix.
            Matrix <int> matrix = BuildMatrix.RandomInt(4, 4, -10, 10);

            // gets vector of matrix by row index.
            Vector <int> arr1 = matrix[0, State.Row];

            builder.AppendLine("gets vector by row index: " + arr1);

            // gets vector of matrix by column index
            Vector <int> arr2 = matrix[0, State.Column];

            builder.AppendLine("gets vector by column index: " + arr2);

            // gets vector via method
            Vector <int> arr3 = matrix.GetColumn(1);
            Vector <int> arr4 = matrix.GetRow(2);

            builder.AppendLine("gets vector by column index via method: " + arr3);
            builder.AppendLine("gets vector by row index via method: " + arr4);

            // assign vector to matrix by column and row.
            matrix[0, State.Column] = arr3.Array;
            matrix[1, State.Row]    = arr4.Array;
            builder.AppendLine("matrix after conversion: ");
            builder.AppendLine(matrix.ToString());

            return(builder.ToString());
        }
Beispiel #3
0
        public async Task StrassenParallelTest_AssertMustBeEqual()
        {
            // Arrange
            Matrix <int> matrixA  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> matrixB  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> expected = matrixA * matrixB;

            // Act
            var actual = await Optimization.MultiplyStrassenAsync(matrixA, matrixB);

            // Assert
            Assert.Equal(expected, actual);
        }
Beispiel #4
0
        public void StrassenTest_AssertMustBeEqual()
        {
            // Arrange
            Matrix <int> matrixA  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> matrixB  = BuildMatrix.RandomInt(1024, 1024, 1, 2);
            Matrix <int> expected = matrixA * matrixB;

            // Act
            var actual = Optimization.MultiplyStrassen(matrixA, matrixB);

            // Assert
            Assert.Equal(expected, actual);
        }
Beispiel #5
0
        // Below you can see all ways how to execute routine operations with vector.
        public static string Run()
        {
            StringBuilder builder = new StringBuilder();

            // init vector va with fill three value.
            Vector <int> va = new Vector <int>(5, 3);

            builder.AppendLine("va = " + va);

            // init vector vb.
            Vector <int> vb = new[] { 1, 2, 3, 4, 5 };

            builder.AppendLine("vb = " + vb);

            // add of two vectors.
            var vc = vb + va;

            builder.AppendLine("vc = " + vc);

            // multiply vectors on constant.
            var vk = 5 * vc;

            builder.AppendLine("vk = " + vk);

            // subtract of two vectors.
            var vd = vk - vc;

            builder.AppendLine("vd = " + vd);

            // subtract of two vectors.
            var ve = vd - vk;

            builder.AppendLine("ve = " + ve);

            // multiply vectors on constant.
            var vg = ve * vc;

            builder.AppendLine("vg = " + vg);

            // multiply vector on matrix and vice versa
            Matrix <int> ma = BuildMatrix.RandomInt(5, 5, -10, 10);
            var          vq = ma * ve;
            var          vt = ve * ma;

            builder.AppendLine("vq = " + vq);
            builder.AppendLine("vt = " + vt);

            return(builder.ToString());
        }
 public void Setup()
 {
     _matrix1 = BuildMatrix.RandomInt(1024, 1024, 1, 123);
 }
Beispiel #7
0
            public IEnumerator <object[]> GetEnumerator()
            {
                yield return(new object[] { BuildMatrix.RandomInt(4, 4), new[] { 1, 2, 3, 4, 5 } });

                yield return(new object[] { BuildMatrix.RandomInt(4, 4), new[] { 1, 2, 3 } });
            }
Beispiel #8
0
 public void Setup()
 {
     _matrix = BuildMatrix.RandomInt(Size, Size);
 }
Beispiel #9
0
 public Matrix <int> RandomInt()
 {
     return(BuildMatrix.RandomInt(N, N));
 }
Beispiel #10
0
 public void Setup()
 {
     _matrix1 = BuildMatrix.RandomInt(1024, 1024, 1, 123);
     _matrix2 = _matrix1.Clone() as Matrix <int>;
 }
Beispiel #11
0
 public void Setup()
 {
     _matrixShort = BuildMatrix.RandomShort(1024, 1024, 0, 20);
     _matrixInt   = BuildMatrix.RandomInt(1024, 1024, 0, 20);
     _matrixSByte = BuildMatrix.RandomSByte(1024, 1024, 0, 20);
 }
Beispiel #12
0
 public void Setup()
 {
     _matrix = BuildMatrix.RandomInt(4096, 4096, 1, 123);
 }