0
我想有一個類作爲mpfr_t元素的矩陣。我認爲STL Vectors對於動態分配儘可能多的這些數據是一個好主意,但我在這裏遇到一些錯誤。動態分配mpfr_t矩陣與std :: vector
#ifndef GMPMATRIX_H
#define GMPMATRIX_H
#include <vector>
#include <mpfr.h>
typedef std::vector<mpfr_t> mpVector;
typedef std::vector<mpVector> mpMatrix;
class GmpMatrix
{
private:
int n;
int m;
mpMatrix elements;
public:
GmpMatrix() {}
GmpMatrix(int n, int m)
{
this->n = n;
this->m = m;
for (int i = 0; i < n; ++i)
{
mpVector e_push(m);
for (int j = 0; j < m; ++j)
{
mpfr_t e;
mpfr_init(e);
e_push.push_back(e);
}
}
}
~GmpMatrix() {}
};
#endif // GMPMATRIX_H
的錯誤是:
/usr/include/c++/5/ext/new_allocator.h:120:4: error: parenthesized initializer in array new [-fpermissive]
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
/usr/include/c++/5/ext/new_allocator.h:120:4: error: no matching function for call to ‘__mpfr_struct::__mpfr_struct(const __mpfr_struct [1])’
我真的很期待這個,我無法弄清楚。有沒有辦法使vector< vector<mpfr_t> >
工作?有誰知道發生了什麼?
這樣的包裝已經存在 - https://bitbucket.org/advanpix/mpreal –
非常感謝!這編譯使用你的包裝。 – p0licat