本文整理汇总了C#中System.Matrix.ShouldNotBeNull方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.ShouldNotBeNull方法的具体用法?C# Matrix.ShouldNotBeNull怎么用?C# Matrix.ShouldNotBeNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.ShouldNotBeNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMatrix
/// <summary>
/// <paramref name="m"/> matrix 의 요소값을 <paramref name="s"/>의 요소로 설정합니다.
/// </summary>
/// <param name="m"></param>
/// <param name="s"></param>
/// <param name="rows"></param>
/// <param name="c0"></param>
/// <param name="c1"></param>
public static void SetMatrix(this Matrix m, Matrix s, int[] rows, int c0, int c1) {
m.ShouldNotBeNull("m");
s.ShouldNotBeNull("s");
rows.ShouldNotBeNull("rows");
Guard.Assert(c1 > c0, "c1 should be greater than c0, c0=[{0}], c1=[{1}]", c0, c1);
var cols = new int[c1 - c0 + 1];
for(var c = 0; c < cols.Length; c++)
cols[c] = c0 + c;
SetMatrix(m, s, rows, cols);
}
示例2: IsSameDimension
/// <summary>
/// 두개의 <see cref="Matrix"/>가 같은 차원인지 검사합니다.
/// </summary>
/// <param name="m1"></param>
/// <param name="m2"></param>
/// <returns></returns>
public static bool IsSameDimension(this Matrix m1, Matrix m2) {
m1.ShouldNotBeNull("m1");
m2.ShouldNotBeNull("m2");
return IsSameDimension(m1.Data, m2.Data);
}
示例3: Divide
/// <summary>
/// result = a / s
/// </summary>
/// <param name="result"></param>
/// <param name="a"></param>
/// <param name="s"></param>
public static void Divide(this Matrix result, Matrix a, double s) {
result.ShouldNotBeNull("result");
a.ShouldNotBeNull("a");
Guard.Assert<DivideByZeroException>(s != 0.0, @"s is zero.");
CheckSameDimension(result, a);
for(var r = 0; r < a.Rows; r++)
for(var c = 0; c < a.Cols; c++)
result[r, c] = a[r, c] / s;
}
示例4: Multiply
/// <summary>
/// result = a * s
/// </summary>
/// <param name="result"></param>
/// <param name="a"></param>
/// <param name="s"></param>
public static void Multiply(this Matrix result, Matrix a, double s) {
result.ShouldNotBeNull("result");
a.ShouldNotBeNull("a");
CheckSameDimension(result, a);
for(var r = 0; r < a.Rows; r++)
for(var c = 0; c < a.Cols; c++)
result[r, c] = a[r, c] * s;
}
示例5: Subtract
/// <summary>
/// result = a b
/// </summary>
/// <param name="result"></param>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Subtract(this Matrix result, Matrix a, Matrix b) {
result.ShouldNotBeNull("result");
a.ShouldNotBeNull("a");
b.ShouldNotBeNull("b");
CheckSameDimension(a, b);
CheckSameDimension(a, result);
for(var r = 0; r < a.Rows; r++)
for(var c = 0; c < a.Cols; c++)
result[r, c] = a[r, c] - b[r, c];
}