public void BuildFromLowerRow_DimensionsDoesNotFitInputData_ThrowsException() { MatrixBuilder builder = new MatrixBuilder(); builder.BuildFromLowerRow(new double[] { 1, 2, 3, 4, 5, 6 }, 10); Assert.Fail(); }
/// <summary> /// Loads weight matrix from tsp data /// </summary> /// <returns>Edge weight matrix</returns> protected double[,] LoadWeightMatrix() { MatrixBuilder matrixBuilder = new MatrixBuilder(); switch (tspFile.EdgeWeightFormat) { case Defines.EdgeWeightFormat.FullMatrix: return matrixBuilder.BuildFromFullMatrix(tspFile.EdgeWeights, tspFile.Dimension); case Defines.EdgeWeightFormat.UpperRow: case Defines.EdgeWeightFormat.LowerColumn: return matrixBuilder.BuildFromUpperRow(tspFile.EdgeWeights, tspFile.Dimension); case Defines.EdgeWeightFormat.LowerRow: case Defines.EdgeWeightFormat.UpperColumn: return matrixBuilder.BuildFromLowerRow(tspFile.EdgeWeights, tspFile.Dimension); case Defines.EdgeWeightFormat.UpperDiagonalRow: case Defines.EdgeWeightFormat.LowerDiagonalColumn: return matrixBuilder.BuildFromUpperDiagonalRow(tspFile.EdgeWeights, tspFile.Dimension); case Defines.EdgeWeightFormat.LowerDiagonalRow: case Defines.EdgeWeightFormat.UpperDiagonalColumn: return matrixBuilder.BuildFromLowerDiagonalRow(tspFile.EdgeWeights, tspFile.Dimension); default: throw new NotSupportedException(); } }
public void ValidateBuildFromLowerRow() { MatrixBuilder builder = new MatrixBuilder(); int dimension = 4; double[] input = { 1, 2, 4, // only bottom left triangle w/o diagonal, read by rows 3, 5, 6 }; double[,] expectedOutput = { { 0, 1, 2, 3 }, { 1, 0, 4, 5 }, { 2, 4, 0, 6 }, { 3, 5, 6, 0 } }; var output = builder.BuildFromLowerRow(input, dimension); AssertArraysAreEqual(expectedOutput, output); }