From 568505e0f3c717511aacc89f41e451b5e1b3e9f2 Mon Sep 17 00:00:00 2001 From: Marcus Cuda Date: Mon, 4 Jan 2010 18:47:33 +0800 Subject: [PATCH] added missing user defined matrix tests --- .../Double/UserDefinedMatrixTests.cs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs diff --git a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs new file mode 100644 index 00000000..14a6054e --- /dev/null +++ b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using MbUnit.Framework; + +namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double +{ + using LinearAlgebra.Double; + + internal class UserDefinedMatrix : Matrix + { + private readonly double[,] _data; + + public UserDefinedMatrix(int rows, int columns) : base(rows, columns) + { + _data = new double[rows, columns]; + } + + public UserDefinedMatrix(double[,] data) : base(data.GetLength(0), data.GetLength(1)) + { + _data = data; + } + + public override double At(int row, int column) + { + return _data[row, column]; + } + + public override void At(int row, int column, double value) + { + _data[row, column] = value; + } + + public override Matrix CreateMatrix(int numberOfRows, int numberOfColumns) + { + return new UserDefinedMatrix(numberOfRows, numberOfColumns); + } + } + + public class UserDefinedMatrixTests : MatrixTests + { + protected override Matrix CreateMatrix(int rows, int columns) + { + return new UserDefinedMatrix(rows, columns); + } + + protected override Matrix CreateMatrix(double[,] data) + { + return new UserDefinedMatrix(data); + } + } +}