小弟程序如下:
********************************************************************************************************
public static Matrix operator *(Matrix m1, Matrix m2)
{
return m1.Multiply(m2);
}
public Matrix Multiply(Matrix other)
{
if (this.numColumns != other.GetNumRows())
throw new Exception("矩阵的行/列数不匹配。"); Matrix result = new Matrix(numRows, other.GetNumColumns()); double value;
for (int i = 0; i < result.GetNumRows(); ++i)
{
for (int j = 0; j < other.GetNumColumns(); ++j)
{
value = 0.0;
for (int k = 0; k < numColumns; ++k)
{
value += GetElement(i, k) * other.GetElement(k, j);
} result.SetElement(i, j, value);
}
} return result;
}
*********************************************************************************************************
在主函数里面使用V=A*B.Transpose();报错:("矩阵的行/列数不匹配。");
使用V=A.Multiply(B.Transpose());就可以通过是什么原因呢?
********************************************************************************************************
public static Matrix operator *(Matrix m1, Matrix m2)
{
return m1.Multiply(m2);
}
public Matrix Multiply(Matrix other)
{
if (this.numColumns != other.GetNumRows())
throw new Exception("矩阵的行/列数不匹配。"); Matrix result = new Matrix(numRows, other.GetNumColumns()); double value;
for (int i = 0; i < result.GetNumRows(); ++i)
{
for (int j = 0; j < other.GetNumColumns(); ++j)
{
value = 0.0;
for (int k = 0; k < numColumns; ++k)
{
value += GetElement(i, k) * other.GetElement(k, j);
} result.SetElement(i, j, value);
}
} return result;
}
*********************************************************************************************************
在主函数里面使用V=A*B.Transpose();报错:("矩阵的行/列数不匹配。");
使用V=A.Multiply(B.Transpose());就可以通过是什么原因呢?
解决方案 »
- XML怎么修改父节点的值??已经在网上查找了7个小时了!!
- WCF如何实现Liskov替换原则?
- 大家帮我出出主意,关于如何从客户端收取信息
- windows mobile5.0里开发,使用平台.net2005 ,c#语言。为什么在模拟器里布署完后,模拟器里页面中的汉字变成了乱码?
- datagridview的问题 winform
- 修改DataView的行标题,为行标题加上文字
- 求救,关于线程中某个变量获取数值慢导致在WIN7中停止运行的问题
- C#中使用ListView的问题
- C#开发WINDOWS应用程序,怎么调用动态链接库DLL文件,请教教我,请把步骤写详细点,谢谢
- CSC.EXE 如何编译解决方案文件(*.SLN)
- TeeChart设置时间坐标问题,急急急 !
- 大家怎么看待微软Visual Studio 的更新速度的?
Transpose明显是他自己的矩阵类的方法。。你注意看他的最后一句。
给你个办法,调试,走到报错这步的时候,用监视器看看B.Transpose()到底是什么样的,他的GetNumRows是不是和A的numColumns相等,一看就知道了。
V=A*C;
可能是优先级问题;
可能B和B.Transpose类型一样