将std与特征库中的Vectorxd一起使用
use std with Vectorxd from eigen library
它是否可能像这样使用std::swap函数来替换特征库中VectorXd的元素?它正确吗?
Eigen::VectorXd val2;
std::swap(val2[i], val2[k + i]);
是的,您可以:
#include <iostream>
#include <algorithm>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
VectorXd e_vec(5);
e_vec << 1, 2, 3, 4, 5;
std::swap(e_vec[0], e_vec[2]);
std::cout << e_vec << std::endl;
return 0;
}
产品:
3
2
1
4
5
相关文章:
- 如何将enable-if与模板参数和参数包一起使用
- 如何将PERF_AMPLE_READ与mmap一起使用
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 如何将C++中的库和头与MinGW一起使用
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 为什么我不能将 rand() 与数组的大小一起使用?
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 不能将复制初始化与隐式转换的多个步骤一起使用
- 将fold表达式与std::一起用于两个元组
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 将 std::allocate_shared 与多态资源分配器一起使用
- 如何在没有数据拷贝的情况下从指针创建一个Eigen VectorXd对象
- 为什么常量词在重载运算符中不与 ostream 对象一起使用<<?
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- 将 exprtk 与自定义类的对象一起使用
- 将 std::set 与基于键的比较器一起使用
- 将 C++ 类与 Rcpp 一起使用,从 C 或 R 修改它
- 如何将 Eigen::Ref 与 pybind11 一起使用?
- 如何将AERT_Allocate与 std:vector 一起使用
- 将std与特征库中的Vectorxd一起使用