0

mpfr_t 要素のマトリックスとして機能するクラスが必要です。STL ベクトルは、必要な数だけ動的に割り当てるのに最適なアイデアだと思いましたが、ここでいくつかのエラーが発生します。

#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> >ますか?誰が何が起こっているのか知っていますか?

4

1 に答える 1

0

mpfr_tC スタイルの配列型です。に保管することはできませんstd::vector

mpfr_tシンプルにラッピングしてstruct 収納できます。

于 2016-11-10T16:59:21.663 に答える