public static CreateRowMatrix ( double input ) : Matrix | ||
input | double | A 1D array to make the matrix from. |
리턴 | Matrix |
public void Bipolar2Double() { // test a 1x4 bool[] boolData1 = { true, false, true, false }; double[] checkData1 = { 1, -1, 1, -1 }; Matrix matrix1 = Matrix.CreateRowMatrix(BiPolarUtil.Bipolar2double(boolData1)); Matrix checkMatrix1 = Matrix.CreateRowMatrix(checkData1); Assert.IsTrue(matrix1.Equals(checkMatrix1)); // test a 2x2 bool[][] boolData2 = { new[] { true, false }, new[] { false, true } }; double[][] checkData2 = { new[] { 1.0, -1.0 }, new[] { -1.0, 1.0 } }; var matrix2 = new Matrix(BiPolarUtil.Bipolar2double(boolData2)); var checkMatrix2 = new Matrix(checkData2); Assert.IsTrue(matrix2.Equals(checkMatrix2)); }
public void RowMatrix() { double[] matrixData = { 1.0, 2.0, 3.0, 4.0 }; Matrix matrix = Matrix.CreateRowMatrix(matrixData); Assert.AreEqual(matrix[0, 0], 1.0); Assert.AreEqual(matrix[0, 1], 2.0); Assert.AreEqual(matrix[0, 2], 3.0); Assert.AreEqual(matrix[0, 3], 4.0); }
public void IsVector() { double[] matrixData = { 1.0, 2.0, 3.0, 4.0 }; Matrix matrixCol = Matrix.CreateColumnMatrix(matrixData); Matrix matrixRow = Matrix.CreateRowMatrix(matrixData); Assert.IsTrue(matrixCol.IsVector()); Assert.IsTrue(matrixRow.IsVector()); double[][] matrixData2 = { new[] { 1.0, 2.0 }, new[] { 3.0, 4.0 } }; var matrix = new Matrix(matrixData2); Assert.IsFalse(matrix.IsVector()); }
public void VectorLength() { double[] vectorData = { 1.0, 2.0, 3.0, 4.0 }; Matrix vector = Matrix.CreateRowMatrix(vectorData); Assert.AreEqual(5, (int)MatrixMath.VectorLength(vector)); var nonVector = new Matrix(2, 2); try { MatrixMath.VectorLength(nonVector); Assert.IsTrue(false); } catch (MatrixError) { } }