gpt4 book ai didi

c++ - Blitz 中的模板++ 0.10

转载 作者:太空宇宙 更新时间:2023-11-04 11:40:44 25 4
gpt4 key购买 nike

我正在尝试使用 Blitz++ 用户指南中的模板对象

#include <blitz/array.h>
using namespace blitz;

BZ_DECLARE_STENCIL4(test,P1,P2,P3,c)
P3 = 2 * P2 + c * Laplacian3D(P2) - P1;
BZ_END_STENCIL

applyStencil(test(), P1, P2, P3, c);

但是编译后出现这个错误

test_blitz.cpp: In static member function ‘static void test::apply(T1&, T2&, T3&, T4&, T5, T6, T7, T8, T9, T10, T11) [with T1 = blitz::FastArrayIterator<long double, 3>, T2 = blitz::FastArrayIterator<long double, 3>, T3 = blitz::FastArrayIterator<long double, 3>, T4 = blitz::FastArrayIterator<long double, 3>, T5 = blitz::dummy<double>, T6 = blitz::dummy<double>, T7 = blitz::dummy<double>, T8 = blitz::dummy<double>, T9 = blitz::dummy<double>, T10 = blitz::dummy<double>, T11 = blitz::dummy<double>]’:
/usr/include/blitz/array/stencils.cc:288:13: instantiated from ‘void blitz::applyStencil_imp(const T_stencil&, blitz::Array<T_numtype1, 3>&, T_array2&, T_array3&, T_array4&, T_array5&, T_array6&, T_array7&, T_array8&, T_array9&, T_array10&, T_array11&) [with T_stencil = test, T_numtype1 = long double, T_array2 = blitz::Array<long double, 3>, T_array3 = blitz::Array<long double, 3>, T_array4 = blitz::Array<long double, 3>, T_array5 = blitz::dummyArray, T_array6 = blitz::dummyArray, T_array7 = blitz::dummyArray, T_array8 = blitz::dummyArray, T_array9 = blitz::dummyArray, T_array10 = blitz::dummyArray, T_array11 = blitz::dummyArray]’
/usr/include/blitz/array/stencils.cc:535:5: instantiated from ‘void blitz::applyStencil(const T_stencil&, blitz::Array<T_numtype1, N_rank>&, T_array2&, T_array3&, T_array4&) [with T_stencil = test, T_numtype1 = long double, int N_rank = 3, T_array2 = blitz::Array<long double, 3>, T_array3 = blitz::Array<long double, 3>, T_array4 = blitz::Array<long double, 3>]’
test_blitz.cpp:35:36: instantiated from here
test_blitz.cpp:9:5: error: ‘Laplacian3D’ was not declared in this scope

其他数组操作(乘法、where 等)正在运行。谁能解释我做错了什么?

UPD

看起来我错过了 header blitz/array/stencil-et.h(在示例 stencil2.cpp 中),但还有另一个错误

test_blitz.cpp: In static member function ‘static void test::apply(T1&, T2&, T3, T4, T5, T6, T7, T8, T9, T10, T11) [with T1 = blitz::FastArrayIterator<long double, 3>, T2 = blitz::FastArrayIterator<long double, 3>, T3 = blitz::dummy<double>, T4 = blitz::dummy<double>, T5 = blitz::dummy<double>, T6 = blitz::dummy<double>, T7 = blitz::dummy<double>, T8 = blitz::dummy<double>, T9 = blitz::dummy<double>, T10 = blitz::dummy<double>, T11 = blitz::dummy<double>]’:
/usr/include/blitz/array/stencils.cc:288:13: instantiated from ‘void blitz::applyStencil_imp(const T_stencil&, blitz::Array<T_numtype1, 3>&, T_array2&, T_array3&, T_array4&, T_array5&, T_array6&, T_array7&, T_array8&, T_array9&, T_array10&, T_array11&) [with T_stencil = test, T_numtype1 = long double, T_array2 = blitz::Array<long double, 3>, T_array3 = blitz::dummyArray, T_array4 = blitz::dummyArray, T_array5 = blitz::dummyArray, T_array6 = blitz::dummyArray, T_array7 = blitz::dummyArray, T_array8 = blitz::dummyArray, T_array9 = blitz::dummyArray, T_array10 = blitz::dummyArray, T_array11 = blitz::dummyArray]’
/usr/include/blitz/array/stencils.cc:515:5: instantiated from ‘void blitz::applyStencil(const T_stencil&, blitz::Array<T_numtype1, N_rank>&, T_array2&) [with T_stencil = test, T_numtype1 = long double, int N_rank = 3, T_array2 = blitz::Array<long double, 3>]’
test_blitz.cpp:38:30: instantiated from here
test_blitz.cpp:12:5: error: no matching function for call to ‘Laplacian3D(blitz::FastArrayIterator<long double, 3>&)’
test_blitz.cpp:12:5: note: candidates are:
/usr/include/blitz/array/stencil-classes.cc:15348:3: note: template<class T1> blitz::_bz_ArrayExpr<blitz::Laplacian3D_et<typename blitz::asExpr<T>::T_expr::T_range_result, typename blitz::asExpr<T>::T_expr::T_numtype> > blitz::Laplacian3D(const blitz::ETBase<T>&)
/usr/include/blitz/array/stencil-classes.cc:15356:3: note: template<class T, int N> blitz::_bz_ArrayExpr<blitz::Laplacian3D_et<typename blitz::asExpr<blitz::Array<T, N> >::T_expr::T_range_result, T> > blitz::Laplacian3D(const blitz::Array<T, N>&)
/usr/include/blitz/array/stencil-classes.cc:15361:3: note: template<class T, int N> blitz::_bz_ArrayExpr<blitz::Laplacian3D_et<typename blitz::asExpr<blitz::Array<T, N> >::T_expr::T_range_result, T> > blitz::Laplacian3D(blitz::Array<T, N>&)

有什么想法吗?

链接到带有错误消息的完整代码示例 https://gist.github.com/erthalion/8784150

最佳答案

我认为您缺少#include。也许#include <blitz/array/stencilops.h> ,或通过系统上的 blitz header 进行 grep 查找 Laplacian3D。

关于c++ - Blitz 中的模板++ 0.10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21497477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com