- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 this page 上重现第二个示例Eigen 文档,但无法编译我的最小程序。我正在使用 Eigen 3.3~beta1-2。
使用以下参数运行 g++ 时 -std=c++11 -Wall -pipe -O3 -ffast-math -funsafe-math-optimizations -march=native -mtune=native -pedantic -Wno-unused -variable -I/usr/local/include/eigen3 -I/usr/include/eigen3 -c example.cpp
,我得到这个错误:
example.cpp:8:41 ("Eigen::MatrixXi B = indexing(A, ri, ci)" in program below)
/usr/include/eigen3/Eigen/src/Core/CoreEvaluators.h:348:27: error: no match for call to '(const indexing_functor<Eigen::Matrix<int, -1, -1>, Eigen::Array<int, 3, 1>, Eigen::Array<int, -1, 1> >) (Eigen::Index&)
return m_functor(index);
我的最小程序包含以下内容(基本上是从文档中的示例复制粘贴而来):
example.h
#include <iostream>
#include <stdio.h>
#include <Eigen/Core>
using namespace Eigen;
template<class ArgType, class RowIndexType, class ColIndexType>
class indexing_functor {
const ArgType &m_arg;
const RowIndexType &m_rowIndices;
const ColIndexType &m_colIndices;
public:
typedef Matrix<typename ArgType::Scalar,
RowIndexType::SizeAtCompileTime,
ColIndexType::SizeAtCompileTime,
ArgType::Flags&RowMajorBit?RowMajor:ColMajor,
RowIndexType::MaxSizeAtCompileTime,
ColIndexType::MaxSizeAtCompileTime> MatrixType;
indexing_functor(const ArgType& arg, const RowIndexType& row_indices, const ColIndexType& col_indices)
: m_arg(arg), m_rowIndices(row_indices), m_colIndices(col_indices)
{}
const typename ArgType::Scalar& operator() (Index row, Index col) const {
return m_arg(m_rowIndices[row], m_colIndices[col]);
}
};
template <class ArgType, class RowIndexType, class ColIndexType>
CwiseNullaryOp<indexing_functor<ArgType,RowIndexType,ColIndexType>, typename indexing_functor<ArgType,RowIndexType,ColIndexType>::MatrixType>
indexing(const Eigen::MatrixBase<ArgType>& arg, const RowIndexType& row_indices, const ColIndexType& col_indices)
{
typedef indexing_functor<ArgType,RowIndexType,ColIndexType> Func;
typedef typename Func::MatrixType MatrixType;
return MatrixType::NullaryExpr(row_indices.size(), col_indices.size(), Func(arg.derived(), row_indices, col_indices));
}
example.cpp
#include "example.h"
int main()
{
Eigen::MatrixXi A = Eigen::MatrixXi::Random(4,4);
Array3i ri(1,2,1);
ArrayXi ci(6); ci << 3,2,1,0,0,2;
Eigen::MatrixXi B = indexing(A, ri, ci);
std::cout << "A =" << std::endl;
std::cout << A << std::endl << std::endl;
std::cout << "A([" << ri.transpose() << "], [" << ci.transpose() << "]) =" << std::endl;
std::cout << B << std::endl;
}
我是否遗漏了有关模板在 C++ 中的工作原理的一些基本知识?
最佳答案
我确定 Ubuntu release对于 Eigen 3.3~beta1-2 必须有重大更改,或者以某种方式缺乏对此扩展的支持。该程序在使用最新 header 时有效。
关于c++ - 使用 CWiseNullaryOp 扩展 Eigen : Cannot reproduce example,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43749673/
是否可以确定性地运行多线程Java应用程序?我的意思是在我的应用程序的两次不同运行中始终具有相同的线程切换。 原因是在每次运行中都在完全相同的条件下运行模拟。 类似的情况是当使用随机数生成器获得始终相
这是否可能以确定性方式运行多线程 Java 应用程序?我的意思是在我的应用程序的两次不同运行中始终进行相同的线程切换。 这样做的原因是每次运行都在完全相同的条件下运行模拟。 类似的情况是当一个人在使用
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 2 年前。 Improv
我正在寻找一种以特定间隔滚动水平菜单的方法。 我有多个 child 在屏幕上可见 选中的状态在中心。 将 snapToInterval 与 snapToAlignement 结合使用完全满足了我的需求
我正在编写一个使用 Rcpp 包的 R 包。到目前为止,我一直在使用 R 版本 4.0.0 的 macOS Catalina 上工作和测试。使用 set.seed从 R 中,我可以从我的 Mac 获得
我正在尝试将一段基于 Dave Shapiro 的“RSA in Javascript”库 (http://ohdave.com/rsa/) 的 JS 代码转换为 PHP(我正在尝试为使用 JS 加密
我正在尝试在 this page 上重现第二个示例Eigen 文档,但无法编译我的最小程序。我正在使用 Eigen 3.3~beta1-2。 使用以下参数运行 g++ 时 -std=c++11 -Wa
我几天来一直在尝试仅使用 Canvas API 以及 getImageData 和 putImageData 来重现图像,遵循我在网上找到的一些教程。使用正方形或从 Canvas 上绘制的任何其他形式
我不完全确定 Docker 是否足以用于 R 开发,或者我应该与 Packrat 结合使用。我读过几篇文章说 docker 就足够了。唯一支持这种说法的地方是这个 post .但是,由于 git2r
在 official Guava's TypeToken wiki ,有下面的例子: Invokable, ?> invokable = new TypeToken>() {}.method(getM
我在一段测试代码中遇到了 FloatingPointError: invalid value encountered in subtract。在代码本身没有进行任何更改的情况下开始引发异常,因此我很难
这个问题已经有答案了: Comparison method violates its general contract Exception (1 个回答) 已关闭10 年前。 我正在尝试重现此异常(j
这本书JavaScript for PHP Developers包含以下注释代码(至我添加了alert()来显示单变量表达式语句的值形式 variable; 并且我还添加了“use strict”指令
我将为我的一个元素制作一个 jQuery 插件,我正在尝试使用 div 和 span 模拟输入以使其“更丰富”。 我将使用 [span(包含用于删除的 A)+ input] 而不是 [ input ]
我的build.gradle.kts(:app): plugins { id("com.android.application") kotlin("plugin.serializati
问题 我有一些 code每月创建一个包含许多点的 map ,并用一些统计数据进行注释。在我将 ggplot2 更新为 3.3.6 之前,此方法运行良好,之后绘图已损坏,我无法找出解决方案。据我所知,问
我正在尝试最小化一个函数,该函数采用长度为 N 的 1darray 并通过 Levenberg-Marquardt (:= LM) 返回标量。 它可以在 Matlab 中运行: beta_initia
我在本地有这个 Nodejs Typescript Azure 函数: ├── README.md ├── dist ├── host.json ├── local.settings.json ├─
我想创建一个 64 位 ASP.NET MVC 2 Web 应用程序并使用 64 位类库引用它。但是这样做我得到了一个“System.BadImageFormatException”-Exceptio
有人给我一些入门建议吗?我想从中吸取教训(即不想偷懒,不想让别人帮我回答这个问题)。 我想加深对数学 3D 曲面的理解。我自己的个人项目是在 MATLAB 中生成大厅结构的 3D 表面/图形。 我找到
我是一名优秀的程序员,十分优秀!