为什么我可以初始化一个普通的Boost矩阵像一个标量矩阵
Why can I initialize a regular Boost matrix like a scalar matrix?
为什么会这样?它不在文档中的任何地方…
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main()
{
boost::numeric::ublas::matrix<double> twoByTwoMat(2,2,-2);
std::cout << "This is the matrix: " << twoByTwoMat << std::endl;
return 0;
}
输出:This is the matrix: [2,2]((-2,-2),(-2,-2))
在<boost/numeric/ublas/matrix.hpp>
头文件中定义。
matrix (size_type size1, size_type size2, const value_type &init):
matrix_container<self_type> (),
size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) {
}
相关文章:
- 函数向量_指针有不同的原型,我可以构建一个吗
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- C++-我可以创建另一个类的成员并在构造函数中使用它吗
- 在一个读写器队列中,我可以用volatile替换原子吗
- 我可以创建一个包含两个变量的 for 循环,但时间复杂度仍然为 O(n) 吗?
- 为什么我可以在不重载 "=" 运算符的情况下将一个对象分配给另一个对象?
- 我可以将迭代器递增一个整数吗?
- 如果需要转换,我可以在读取参数的同时将其移动到另一个参数吗?
- 我可以在具有一个标头和一个接口的 cpp 文件中有多个嵌入吗?
- 我可以有一个 ELI5 作为参考和指针以及何时使用它们吗?
- 而不是那么多的 if 语句,我想要一个逻辑,我可以用一个语句或优化的方式来完成
- 为什么我可以使用 memcpy 将一个对象变量复制到另一个对象变量
- 我有一个线程 1:EXC_BAD_ACCESS(代码 = 1,地址 = 0x8)错误.我认为这是由于内存管理不好.我可以
- 通过将其中一个模板更改为 muliset 后,我可以在 PBDS 排序集上使用计数功能<int>less_equal<int>
- 有没有办法我可以在 C++ 中使用 if 语句来说明如果一个字符串不是两个名称的 eqal,它会给出一个输出,ATM i
- 我可以得到一个字符 * 到一个 std::sregex_iterator 匹配 str() 吗?
- 当我可以在头文件中声明和定义所有文件时,为什么要创建一个.cpp文件?
- 我可以定义一个 constexpr 匿名/未命名变量吗?
- 如何将 c++ 类包装到 python 中,以便我可以使用 pybind11 访问其成员的公共方法(成员是一个对象指针)
- 我可以使用 constexpr 函数声明一个静态数组吗?