我正在尝试使用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
其他数组操作(乘法,等等)正在运行。谁能解释我做错了什么?
UPD
看起来我错过了标题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>&)
有什么想法吗?
的完整代码示例答案 0 :(得分:1)
我想错过#include。也许是#include <blitz/array/stencilops.h>
,或者通过系统上的闪电标题来查找Laplacian3D。
答案 1 :(得分:0)
而不是
BZ_DECLARE_STENCIL4(test,P1,P2,P3,c)
P3 = 2 * P2 + c * Laplacian3D(P2) - P1;
BZ_END_STENCIL
尝试使用
BZ_DECLARE_STENCIL4(test,P1,P2,P3,c)
P3 = 2 * P2 + c * Laplacian3D_stencilop(P2) - P1;
BZ_END_STENCIL
我的理解是Laplacian
是一个模板(就像你声明的那个),而Laplacian3D_stencilop
是一个模板操作符(就像差异操作符),你可以在自己的模板对象中使用它。