< Summary

Information
Class: Morpho25.Geometry.Matrix2d
Assembly: Morpho25
File(s): D:\a\Morpho\Morpho\project\Morpho\Morpho25\Geometry\Matrix2d.cs
Line coverage
43%
Covered lines: 17
Uncovered lines: 22
Coverable lines: 39
Total lines: 93
Line coverage: 43.5%
Branch coverage
33%
Covered branches: 4
Total branches: 12
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Item(...)100%1100%
set_Item(...)100%1100%
.ctor(...)100%10%
.ctor(...)100%4100%
GetLengthX()100%1100%
GetLengthY()100%1100%
MergeMatrix(...)0%80%

File(s)

D:\a\Morpho\Morpho\project\Morpho\Morpho25\Geometry\Matrix2d.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3namespace Morpho25.Geometry
 4{
 5    /// <summary>
 6    /// Matrix 2D class.
 7    /// </summary>
 8    public class Matrix2d
 9    {
 10        private readonly string[,] _values;
 11
 12        /// <summary>
 13        /// Get a value.
 14        /// </summary>
 15        /// <param name="x">X index.</param>
 16        /// <param name="y">Y index.</param>
 17        /// <returns>Value.</returns>
 18        public string this[int x, int y]
 19        {
 320            get { return _values[x, y]; }
 321            set { _values[x, y] = value; }
 22        }
 23
 24        /// <summary>
 25        /// Create a new Matrix 2D.
 26        /// </summary>
 27        /// <param name="x">Size in X.</param>
 28        /// <param name="y">Size in Y.</param>
 029        public Matrix2d(int x, int y)
 030        {
 031            _values = new string[x, y];
 032        }
 33
 34        /// <summary>
 35        /// Create a new Matrix 2D.
 36        /// </summary>
 37        /// <param name="x">Size in X.</param>
 38        /// <param name="y">Size in Y.</param>
 39        /// <param name="value">Default value to use.</param>
 140        public Matrix2d(int x, int y, string value)
 141        {
 142            _values = new string[x, y];
 2243            for (int i = 0; i < x; i++)
 22044                for (int j = 0; j < y; j++)
 10045                {
 10046                    _values[i, j] = value;
 10047                }
 148        }
 49        /// <summary>
 50        /// Get X size.
 51        /// </summary>
 52        /// <returns>X size.</returns>
 53        public int GetLengthX()
 154        {
 155            return _values.GetLength(0);
 156        }
 57        /// <summary>
 58        /// Get Y size.
 59        /// </summary>
 60        /// <returns>Y size.</returns>
 61        public int GetLengthY()
 162        {
 163            return _values.GetLength(1);
 164        }
 65        /// <summary>
 66        /// Merge multiple Matrix 2D matrix.
 67        /// </summary>
 68        /// <param name="matrixList">Collection of matrix to merge.</param>
 69        /// <param name="mask">Value to use for merging.</param>
 70        /// <returns></returns>
 71        public static Matrix2d MergeMatrix(List<Matrix2d> matrixList,
 72            string mask)
 073        {
 074            Matrix2d result = new Matrix2d(matrixList[0].GetLengthX(),
 075                matrixList[0].GetLengthY(), mask);
 76
 077            foreach (Matrix2d matrix in matrixList)
 078            {
 079                for (int i = 0; i < matrix.GetLengthX(); i++)
 080                {
 081                    for (int j = 0; j < matrix.GetLengthY(); j++)
 082                    {
 083                        if (matrix[i, j] != mask)
 084                        {
 085                            result[i, j] = matrix[i, j];
 086                        }
 087                    }
 088                }
 089            }
 090            return result;
 091        }
 92    }
 93}