比较矩阵乘法
我必须将一个矩阵与其自身相乘,直到该矩阵在某种程度上不等于前面的矩阵之一。然后我需要获取矩阵相等的度数值。行数和列数相等。矩阵存储在二维数组中。值为 0 或 1。检查与先前矩阵是否相等的最佳方法是什么?我尝试使用向量
来存储矩阵:
vector<int[5][5]> m;
但出现错误cannot conversion from 'const int [5][5]' to 'int [5][5]'
。
等待建议。
I must multiply a matrix by itself until the matrix in some degree would not be equal to one of the preceding matrices. Then I need to get the values of degrees in which the matrices are equal. The number of rows and columns are equal. The matrix is stored in a two-dimensional array. Values are 0 or 1. What is the best way to check for equality with the previous matrices? I tried to use vector
to store matrices:
vector<int[5][5]> m;
but I got an error cannot convert from 'const int [5][5]' to 'int [5][5]'
.
Waiting for an advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以使用 boost,请查看 boost Matrix 类:
似乎缺少
==
运算符,但很容易添加:并像这样使用:
[Code]
If you can use boost, look at the boost Matrix class:
It seems to be missing an
==
operator, but it's easy to add:And used like so:
[Code]
如果您想使用矢量来实现,您可能需要矢量
矢量
矢量
,即整数向量的向量(即一种二维向量)。矢量
。向量<整数> >vector
将(如果有效)声明一个二维 5x5-int
数组的向量。If you want to do it with
vector
, you probably wantvector < vector < int > >
, i.e. a vector of vectors of ints (i.e. kind of 2-dimensional vector).vector<int[5][5]>
would (if it worked) declare a vector of 2-dimensional 5x5-int
-arrays.