c++ - 使用符号 C++ 库 : Ho to print Matrix output description in objective c? 因为我添加了两个矩阵。代码如下。谢谢

标签 c++

如何获取mp3矩阵的描述?

Matrix<int> mp2= Matrix<int>(2, 2);

mp2[0][0]=_arr[0][0];   
mp2[0][1]=_arr[0][1];
mp2[1][0]=_arr[1][0];
mp2[1][1]=_arr[1][1];

Matrix<int> mp1= Matrix<int>(2, 2);

mp1[0][0]=1;
mp1[0][1]=2;
mp1[1][0]=3;
mp1[1][1]=4;

矩阵 mp3= 矩阵(3, 3);

mp3=mp1+mp2;

最佳答案

我假设您想将两个 Matrix 加在一起?您可以像这样迭代:

Matrix<int> mp3 = Matrix<int>(2, 2);

for (unsigned int i = 0; i < 2; i++)
{
   for (unsigned int j = 0; j < 2; j++)
   {
        mp3[i][j] = mp1[i][j] + mp2[i][j];
   }
}

关于c++ - 使用符号 C++ 库 : Ho to print Matrix output description in objective c? 因为我添加了两个矩阵。代码如下。谢谢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31260138/

相关文章:

c++ - C++中的std::vector与[]比较慢-为什么?

c++ - 使用 boost 序列化保存和检索多个对象

c++ - 为什么 GL_LEQUAL 推荐用于 GL 深度函数(为什么它对我不起作用)?

c++ - 在一行中删除多个指针。 C++

c++ - 将可执行文件与 DLL 分开(这是显式链接吗?)

c++ - 调用 GetWindowRect 时出现编译器错误

c++ - 检查几个组合框的索引是否唯一

c++ - Qt - 复制一个 QTableWidget 的数据并将其粘贴到另一个 QTableWidget

c++ - 使用指向 vector 的指针,其中涉及使用 'new'

c++ - C++ 中的 Utf-8 : quick & dirty tricks