public override void SetupMatrices()
        {
            TestData2D = new Dictionary <string, Complex[, ]>
            {
                { "Singular3x3", new[, ] {
                      { new Complex(1.0, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(3.0, 1) }
                  } },
                { "Square3x3", new[, ] {
                      { new Complex(-1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(6.6, 1) }
                  } },
                { "Square4x4", new[, ] {
                      { new Complex(-1.1, 1), Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(6.2, 1), Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, new Complex(-7.7, 1) }
                  } },
                { "Singular4x4", new[, ] {
                      { new Complex(-1.1, 1), Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(-2.2, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, new Complex(-4.4, 1) }
                  } },
                { "Tall3x2", new[, ] {
                      { new Complex(-1.1, 1), Complex.Zero }, { Complex.Zero, new Complex(1.1, 1) }, { Complex.Zero, Complex.Zero }
                  } },
                { "Wide2x3", new[, ] {
                      { new Complex(-1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero }
                  } }
            };

            TestMatrices = new Dictionary <string, Matrix <Complex> >();
            foreach (var name in TestData2D.Keys)
            {
                TestMatrices.Add(name, DiagonalMatrix.OfArray(TestData2D[name]));
            }
        }
Exemple #2
0
        public override void SetupMatrices()
        {
            TestData2D = new Dictionary <string, float[, ]>
            {
                { "Singular3x3", new[, ] {
                      { 1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 3.0f }
                  } },
                { "Square3x3", new[, ] {
                      { -1.1f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f }, { 0.0f, 0.0f, 6.6f }
                  } },
                { "Square4x4", new[, ] {
                      { -1.1f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f, 0.0f }, { 0.0f, 0.0f, 6.2f, 0.0f }, { 0.0f, 0.0f, 0.0f, -7.7f }
                  } },
                { "Singular4x4", new[, ] {
                      { -1.1f, 0.0f, 0.0f, 0.0f }, { 0.0f, -2.2f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, -4.4f }
                  } },
                { "Tall3x2", new[, ] {
                      { -1.1f, 0.0f }, { 0.0f, 1.1f }, { 0.0f, 0.0f }
                  } },
                { "Wide2x3", new[, ] {
                      { -1.1f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f }
                  } }
            };

            TestMatrices = new Dictionary <string, Matrix <float> >();
            foreach (var name in TestData2D.Keys)
            {
                TestMatrices.Add(name, DiagonalMatrix.OfArray(TestData2D[name]));
            }
        }
        public void PermuteMatrixColumnsThrowsInvalidOperationException()
        {
            var matrixp     = DiagonalMatrix.OfArray(TestData2D["Singular3x3"]);
            var permutation = new Permutation(new[] { 2, 0, 1 });

            Assert.That(() => matrixp.PermuteColumns(permutation), Throws.InvalidOperationException);
        }
Exemple #4
0
        public override void SetupMatrices()
        {
            TestData2D = new Dictionary <string, double[, ]>
            {
                { "Singular3x3", new[, ] {
                      { 1.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 3.0 }
                  } },
                { "Square3x3", new[, ] {
                      { -1.1, 0.0, 0.0 }, { 0.0, 1.1, 0.0 }, { 0.0, 0.0, 6.6 }
                  } },
                { "Square4x4", new[, ] {
                      { -1.1, 0.0, 0.0, 0.0 }, { 0.0, 1.1, 0.0, 0.0 }, { 0.0, 0.0, 6.2, 0.0 }, { 0.0, 0.0, 0.0, -7.7 }
                  } },
                { "Singular4x4", new[, ] {
                      { -1.1, 0.0, 0.0, 0.0 }, { 0.0, -2.2, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, -4.4 }
                  } },
                { "Tall3x2", new[, ] {
                      { -1.1, 0.0 }, { 0.0, 1.1 }, { 0.0, 0.0 }
                  } },
                { "Wide2x3", new[, ] {
                      { -1.1, 0.0, 0.0 }, { 0.0, 1.1, 0.0 }
                  } }
            };

            TestMatrices = new Dictionary <string, Matrix <double> >();
            foreach (var name in TestData2D.Keys)
            {
                TestMatrices.Add(name, DiagonalMatrix.OfArray(TestData2D[name]));
            }
        }
        public void CanCreateMatrixFrom2DArray(string name)
        {
            var matrix = DiagonalMatrix.OfArray(TestData2D[name]);

            for (var i = 0; i < TestData2D[name].GetLength(0); i++)
            {
                for (var j = 0; j < TestData2D[name].GetLength(1); j++)
                {
                    Assert.AreEqual(TestData2D[name][i, j], matrix[i, j]);
                }
            }
        }
 /// <summary>
 /// Creates a matrix from a 2D array.
 /// </summary>
 /// <param name="data">The 2D array to create this matrix from.</param>
 /// <returns>A matrix with the given values.</returns>
 protected override Matrix <Complex> CreateMatrix(Complex[,] data)
 {
     return(DiagonalMatrix.OfArray(data));
 }
Exemple #7
0
 /// <summary>
 /// Creates a matrix from a 2D array.
 /// </summary>
 /// <param name="data">The 2D array to create this matrix from.</param>
 /// <returns>A matrix with the given values.</returns>
 protected override Matrix <float> CreateMatrix(float[,] data)
 {
     return(DiagonalMatrix.OfArray(data));
 }
Exemple #8
0
 /// <summary>
 /// Creates a matrix from a 2D array.
 /// </summary>
 /// <param name="data">The 2D array to create this matrix from.</param>
 /// <returns>A matrix with the given values.</returns>
 protected override Matrix <double> CreateMatrix(double[,] data)
 {
     return(DiagonalMatrix.OfArray(data));
 }