作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 fb_t 的 boost 矩阵,它是 relic表示有限域元素的对象。以下是文档中定义 fb_t 的方式:
typedef uint64_t dig_t
typedef align dig_t fb_t[FB_DIGS+PADDING(FB_BYTES)/(FB_DIGIT/8)]
这是我的代码:
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
extern "C" {
#include <relic.h>
}
#include "relic_test.h"
using namespace std;
typedef boost::numeric::ublas::matrix<fb_t> matrix;
int main(void) {
core_init();
fb_param_set_any();
fb_param_print();
matrix mat(2,2);
core_clean();
return 0;
}
我收到以下错误:
Compiling: main.cpp
In file included from /usr/include/boost/numeric/ublas/vector.hpp:19:0,
from /usr/include/boost/numeric/ublas/matrix.hpp:16,
from /home/Foo/main.cpp:2:
/usr/include/boost/numeric/ublas/storage.hpp: In instantiation of ‘boost::numeric::ublas::unbounded_array<T, ALLOC>::unbounded_array(boost::numeric::ublas::unbounded_array<T, ALLOC>::size_type, const ALLOC&) [with T = unsigned int [4]; ALLOC = std::allocator<unsigned int [4]>; boost::numeric::ublas::unbounded_array<T, ALLOC>::size_type = unsigned int]’:
/usr/include/boost/numeric/ublas/matrix.hpp:131:92: required from ‘boost::numeric::ublas::matrix<T, L, A>::matrix(boost::numeric::ublas::matrix<T, L, A>::size_type, boost::numeric::ublas::matrix<T, L, A>::size_type) [with T = unsigned int [4]; L = boost::numeric::ublas::basic_row_major<>; A = boost::numeric::ublas::unbounded_array<unsigned int [4], std::allocator<unsigned int [4]> >; boost::numeric::ublas::matrix<T, L, A>::size_type = unsigned int]’
/home/Foo/main.cpp:21:19: required from here
/usr/include/boost/numeric/ublas/storage.hpp:71:23: error: functional cast to array type ‘boost::numeric::ublas::unbounded_array<unsigned int [4], std::allocator<unsigned int [4]> >::value_type {aka unsigned int [4]}’
/usr/include/boost/numeric/ublas/storage.hpp: In instantiation of ‘static void boost::numeric::ublas::unbounded_array<T, ALLOC>::iterator_destroy(T*&) [with T = unsigned int [4]; ALLOC = std::allocator<unsigned int [4]>; boost::numeric::ublas::unbounded_array<T, ALLOC>::iterator = unsigned int (*)[4]]’:
/usr/include/boost/numeric/ublas/storage.hpp:106:25: required from ‘boost::numeric::ublas::unbounded_array<T, ALLOC>::~unbounded_array() [with T = unsigned int [4]; ALLOC = std::allocator<unsigned int [4]>]’
/usr/include/boost/numeric/ublas/matrix.hpp:90:11: required from here
/usr/include/boost/numeric/ublas/storage.hpp:290:13: error: request for member ‘~boost::numeric::ublas::unbounded_array<unsigned int [4], std::allocator<unsigned int [4]> >::value_type’ in ‘* i’, which is of non-class type ‘unsigned int [4]’
我不太确定错误消息是关于什么的。任何想法?
最佳答案
我不认为 boost::ublas 支持数组作为值类型。该错误消息可能是因为数组不可复制。为了解决这个问题,您可以将 fb_t
包装在一个类中:
struct fb_t_wrapper {
fb_t value;
};
或者使用std::array
using fb_t_array = std::array<dig_t, FB_DIGS+PADDING(FB_BYTES)/(FB_DIGIT/8)>;
关于c++ - boost 矩阵与遗物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18600632/
我开始在使用 New Relic 和 resque 时遇到奇怪的错误 INFO : Starting Agent shutdown ERROR : undefined method `write' f
我是一名优秀的程序员,十分优秀!