[Test] public virtual void SparseRowColumnMatrix() { Random r = new Random(); int n = Math.Max(TesterUtilities.getInt(nmax, r), 4); IElementalAccessMatrix A = new SparseRowColumnMatrix(n, n, 3); IElementalAccessVector b = new DenseVector(n), x = new DenseVector(n); Helper1(A, b, x); }
public void TestForeach() { var di = new double[] { 1, 2, 3 }; var al = new double[] { 3, 2, 1 }; var au = new double[] { 3, 2, 1 }; var ja = new int[] { 1, 1, 2 }; var ia = new int[] { 1, 1, 2, 4 }; SparseRowColumnMatrix sparseRowColumnMatrix = new SparseRowColumnMatrix(di, al, au, ia, ja); Assert.True(new HashSet <(double, int, int)>(sparseSymmetricRowColumnMatrix).SetEquals(sparseRowColumnMatrix)); }
public TestSparseRowColumnMatrix() { di = new double[] { 1, 2, 3 }; al = new double[] { 1, 2, 3 }; au = new double[] { 3, 2, 1 }; ja = new int[] { 1, 1, 2 }; ia = new int[] { 1, 1, 2, 4 }; vector = new Vector(new double[] { 1, 1, 1 }); sparseRowColumnMatrix = new SparseRowColumnMatrix(di, al, au, ia, ja); }
// TESTING MATRIX TRANSPOSITIONS /// <remarks>"This test been excluded from test fixture by Igor Sukhov on 17.10.2007"</remarks> //[TestMethod] public virtual void SparseRowColumnTranspose() { int n = TesterUtilities.getInt(nmax, _random), m = TesterUtilities.getInt(mmax, _random), nu = GetNu(n, m); for (int i = 0; i < repeat; ++i) { IElementalAccessMatrix A = new SparseRowColumnMatrix(n, m, nu); double[,] Am = TesterUtilities.SetAssembleRowMatrix(A, nu); TransposeCheck(A, Am); } }
public TestSparseRowColumnMatrix(ITestOutputHelper testOutputHelper) { di = new double[] { 1, 2, 3 }; al = new double[] { 1, 2, 3 }; au = new double[] { 3, 2, 1 }; ja = new int[] { 1, 1, 2 }; ia = new int[] { 1, 1, 2, 4 }; vector = new Vector(new double[] { 1, 1, 1 }); sparseRowColumnMatrix = new SparseRowColumnMatrix(di, al, au, ia, ja); _testOutputHelper = testOutputHelper; }
/// <summary>Testing <see cref="SparseRowColumnMatrix"/> class.</summary> [Test] public virtual void SparseRowColumnMatrix() { int n = TesterUtilities.getInt(nmax, r), m = TesterUtilities.getInt(mmax, r), nu = GetNu(n, m); for (int i = 0; i < repeat; ++i) { IElementalAccessMatrix A = new SparseRowColumnMatrix(n, m, nu); check(A, TesterUtilities.SetAssembleRowMatrix(A, nu)); A = new SparseRowColumnMatrix(n, m, nu); check(A, TesterUtilities.AddAssembleRowMatrix(A, nu)); } }
public virtual void SparseRowColumnTransMult() { int n = TesterUtilities.getInt(nmax, _random), m = TesterUtilities.getInt(mmax, _random), nu = GetNu(n, m); for (int i = 0; i < repeat; ++i) { IElementalAccessMatrix A = new SparseRowColumnMatrix(n, m, nu); IElementalAccessVector x = new DenseVector(n), y = new DenseVector(m), z = new DenseVector(m); transRowCheck(A, x, y, z, nu); } }
public void testSparseRowColumnMatrix() { //(int, int)[] coord = new(int, int)[64]; double[] di = new double[8] { 3, 5, 6, 5, 7, 9, 11, 11 }; int[] ig = new int[9] { 1, 1, 2, 3, 3, 5, 7, 8, 9 }; //Индексы начала строк int[] jg = new int[8] { 1, 1, 2, 4, 3, 5, 6, 5 }; //Номера столбцов для элементов double[] al = new double[8] { -1, 1, 3, 3, -2, 2, 1, 4 }; //Элементы нижней диагонали double[] au = new double[8] { 2, 8, 10, 12, -7, 3, 4, 1 }; //Элементы верхней диагонал // //double[] val = new double[64] { 3, 2, 8, 0, 0, 0, 0, 0, // -1, 5, 0, 0, 10, 0, 0, 0, // 1, 0, 6, 0, 0, -7, 0, 0, // 0, 0, 0, 5, 12, 0, 0, 0, // 0, 3, 0, 3, 7, 3, 0, 1, // 0, 0, -2, 0, 2, 9, 4, 0, // 0, 0, 0, 0, 0, 1, 11, 0, // 0, 0, 0, 0, 4, 0, 0, 11 }; //for (int i = 0; i < 64; i++) //{ // coord[i] = (i / 8, i % 8); //} IMatrix matr = new SparseRowColumnMatrix(ig, jg, di, al, au); IVector x = new SimpleVector(new double[8] { 1, 2, 3, 4, 5, 6, 7, 8 }); IVector result = matr.Mult(x); IVector right = new SimpleVector(new double[8] { 31, 59, -23, 80, 79, 86, 83, 108 }); Assert.IsTrue(result.CompareWith(right, 1e-5)); }
public void Fill() { FillFunc fillFunc = (row, col) => { return((row + 1) + (col + 1)); }; sparseRowColumnMatrix.Fill(fillFunc); //di = new double[] { 1, 2, 3 }; //al = new double[] { 1, 2, 3 }; //au = new double[] { 3, 2, 1 }; //ja = new int[] { 1, 1, 2 }; //ia = new int[] { 1, 1, 2, 4 }; di = new double[] { 2, 4, 6 }; al = new double[] { 3, 4, 5 }; au = new double[] { 3, 4, 5 }; ja = new int[] { 1, 1, 2 }; ia = new int[] { 1, 1, 2, 4 }; SparseRowColumnMatrix sparseRowColumn = new SparseRowColumnMatrix(di, al, au, ia, ja); Assert.True(new HashSet <(double, int, int)>(sparseRowColumnMatrix).SetEquals(sparseRowColumn)); }