本文整理汇总了C#中MatrixD.GetRow方法的典型用法代码示例。如果您正苦于以下问题:C# MatrixD.GetRow方法的具体用法?C# MatrixD.GetRow怎么用?C# MatrixD.GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixD
的用法示例。
在下文中一共展示了MatrixD.GetRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiplyMatrix
public void MultiplyMatrix()
{
double[] values = new double[] { 12, 23, 45, 56,
67, 89, 90, 12,
43, 65, 87, 43,
34, -12, 84, 44 };
MatrixD m = new MatrixD(4, 4, values, MatrixOrder.RowMajor);
Assert.AreEqual(new MatrixD(4, 4), MatrixD.Multiply(m, new MatrixD(4, 4)));
Assert.AreEqual(new MatrixD(4, 4), MatrixD.Multiply(new MatrixD(4, 4), m));
Assert.AreEqual(m, MatrixD.Multiply(m, MatrixD.CreateIdentity(4, 4)));
Assert.AreEqual(m, MatrixD.Multiply(MatrixD.CreateIdentity(4, 4), m));
Assert.IsTrue(MatrixD.AreNumericallyEqual(MatrixD.CreateIdentity(4, 4), MatrixD.Multiply(m, m.Inverse)));
Assert.IsTrue(MatrixD.AreNumericallyEqual(MatrixD.CreateIdentity(4, 4), MatrixD.Multiply(m.Inverse, m)));
MatrixD m1 = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor);
MatrixD m2 = new MatrixD(4, 4, values, MatrixOrder.RowMajor);
MatrixD result = MatrixD.Multiply(m1, m2);
Assert.AreEqual(3, result.NumberOfRows);
Assert.AreEqual(4, result.NumberOfColumns);
for (int column = 0; column < 4; column++)
for (int row = 0; row < 3; row++)
Assert.AreEqual(VectorD.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]);
}
示例2: GetRowException2
public void GetRowException2()
{
MatrixD m = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor);
m.GetRow(3);
}
示例3: SetRow
public void SetRow()
{
MatrixD m = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor);
m.SetRow(0, new VectorD(new double[]{ 0.1, 0.2, 0.3, 0.4 }));
Assert.AreEqual(new VectorD(new double[] { 0.1, 0.2, 0.3, 0.4 }), m.GetRow(0));
Assert.AreEqual(new VectorD(new double[] { 5.0, 6.0, 7.0, 8.0 }), m.GetRow(1));
Assert.AreEqual(new VectorD(new double[] { 9.0, 10.0, 11.0, 12.0 }), m.GetRow(2));
m.SetRow(1, new VectorD(new double[] { 0.4, 0.5, 0.6, 0.7 }));
Assert.AreEqual(new VectorD(new double[] { 0.1, 0.2, 0.3, 0.4 }), m.GetRow(0));
Assert.AreEqual(new VectorD(new double[] { 0.4, 0.5, 0.6, 0.7 }), m.GetRow(1));
Assert.AreEqual(new VectorD(new double[] { 9.0, 10.0, 11.0, 12.0 }), m.GetRow(2));
m.SetRow(2, new VectorD(new double[] { 0.7, 0.8, 0.9, 1.0 }));
Assert.AreEqual(new VectorD(new double[] { 0.1, 0.2, 0.3, 0.4 }), m.GetRow(0));
Assert.AreEqual(new VectorD(new double[] { 0.4, 0.5, 0.6, 0.7 }), m.GetRow(1));
Assert.AreEqual(new VectorD(new double[] { 0.7, 0.8, 0.9, 1.0 }), m.GetRow(2));
}
示例4: GetRow
public void GetRow()
{
MatrixD m = new MatrixD(3, 4, rowMajor, MatrixOrder.RowMajor);
Assert.AreEqual(new VectorD(new double[] { 1.0, 2.0, 3.0, 4.0 }), m.GetRow(0));
Assert.AreEqual(new VectorD(new double[] { 5.0, 6.0, 7.0, 8.0 }), m.GetRow(1));
Assert.AreEqual(new VectorD(new double[] { 9.0, 10.0, 11.0, 12.0 }), m.GetRow(2));
}
示例5: MultiplyVectorOperator
public void MultiplyVectorOperator()
{
VectorD v = new VectorD(new double[] { 2.34, 3.45, 4.56, 23.4 });
Assert.AreEqual(v, MatrixD.CreateIdentity(4, 4) * v);
Assert.AreEqual(new VectorD(4), new MatrixD(4, 4) * v);
double[] values = new double[] { 12, 23, 45, 56,
67, 89, 90, 12,
43, 65, 87, 43,
34, -12, 84, 44 };
MatrixD m = new MatrixD(4, 4, values, MatrixOrder.RowMajor);
Assert.IsTrue(VectorD.AreNumericallyEqual(v, m * m.Inverse * v));
for (int i = 0; i < 4; i++)
Assert.IsTrue(Numeric.AreEqual(VectorD.Dot(m.GetRow(i), v), (m * v)[i]));
}