本文整理汇总了C#中Matrix.ClearSubMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.ClearSubMatrix方法的具体用法?C# Matrix.ClearSubMatrix怎么用?C# Matrix.ClearSubMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix.ClearSubMatrix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTransposeThisAndMultiply
/// <summary>
/// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix.
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoTransposeThisAndMultiply(Matrix<double> other, Matrix<double> result)
{
var diagonalOther = other as DiagonalMatrix;
var diagonalResult = result as DiagonalMatrix;
if (diagonalOther != null && diagonalResult != null)
{
var thisDataCopy = new double[diagonalResult._data.Length];
var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
var denseOther = other.Storage as DenseColumnMajorMatrixStorage<double>;
if (denseOther != null)
{
var dense = denseOther.Data;
var diagonal = _data;
var d = Math.Min(denseOther.RowCount, ColumnCount);
if (d < ColumnCount)
{
result.ClearSubMatrix(denseOther.RowCount, ColumnCount - denseOther.RowCount, 0, denseOther.ColumnCount);
}
int index = 0;
for (int i = 0; i < denseOther.ColumnCount; i++)
{
for (int j = 0; j < d; j++)
{
result.At(j, i, dense[index]*diagonal[j]);
index++;
}
index += (denseOther.RowCount - d);
}
return;
}
if (ColumnCount == RowCount)
{
other.Storage.MapIndexedTo(result.Storage, (i, j, x) => x*_data[i], Zeros.AllowSkip, ExistingData.Clear);
}
else
{
result.Clear();
other.Storage.MapSubMatrixIndexedTo(result.Storage, (i, j, x) => x*_data[i], 0, 0, other.RowCount, 0, 0, other.ColumnCount, Zeros.AllowSkip, ExistingData.AssumeZeros);
}
}
示例2: DoMultiply
/// <summary>
/// Multiplies this matrix with another matrix and places the results into the result matrix.
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoMultiply(Matrix<double> other, Matrix<double> result)
{
var denseOther = other as DenseMatrix;
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
denseOther._values,
denseOther._rowCount,
denseOther._columnCount,
denseResult._values);
return;
}
var diagonalOther = other.Storage as DiagonalMatrixStorage<double>;
if (diagonalOther != null)
{
var diagonal = diagonalOther.Data;
var d = Math.Min(ColumnCount, other.ColumnCount);
if (d < other.ColumnCount)
{
result.ClearSubMatrix(0, RowCount, ColumnCount, other.ColumnCount - ColumnCount);
}
int index = 0;
for (int j = 0; j < d; j++)
{
for (int i = 0; i < RowCount; i++)
{
result.At(i, j, _values[index]*diagonal[j]);
index++;
}
}
return;
}
base.DoMultiply(other, result);
}
示例3: DoTransposeAndMultiply
/// <summary>
/// Multiplies this matrix with transpose of another matrix and places the results into the result matrix.
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoTransposeAndMultiply(Matrix<double> other, Matrix<double> result)
{
var diagonalOther = other as DiagonalMatrix;
var diagonalResult = result as DiagonalMatrix;
if (diagonalOther != null && diagonalResult != null)
{
var thisDataCopy = new double[diagonalResult._data.Length];
var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
var denseOther = other.Storage as DenseColumnMajorMatrixStorage<double>;
if (denseOther != null)
{
var dense = denseOther.Data;
var diagonal = _data;
var d = Math.Min(denseOther.ColumnCount, RowCount);
if (d < RowCount)
{
result.ClearSubMatrix(denseOther.ColumnCount, RowCount - denseOther.ColumnCount, 0, denseOther.RowCount);
}
int index = 0;
for (int j = 0; j < d; j++)
{
for (int i = 0; i < denseOther.RowCount; i++)
{
result.At(j, i, dense[index]*diagonal[j]);
index++;
}
}
return;
}
base.DoTransposeAndMultiply(other, result);
}