是否有一种有效的内置方法可以从一个矩阵复制值(例如,double[,]
)到另一个?
换句话说,我正在寻找以下函数的替代品:
public static double[,]CloneMatrix(double[,] aMatrix)
{
var newMatrix = new double[aMatrix.GetLength(0),aMatrix.GetLength(1)];
for (int i = 0; i < aMatrix.GetLength(0); i++)
{
for (int j = 0; j < aMatrix.GetLength(1); j++)
{
newMatrix[i, j] = aMatrix[i, j];
}
}
return newMatrix;
}
使用克隆方法:
double[,] result = (double[,])aMatrix.Clone();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)