![]() |
Blitz Support : |
From: Faheem Mitha (faheem_at_[hidden])
Date: 2005-05-30 21:18:43
Hi,
I've been looking at stencils, and I've noticed that the applyStencil
function does not like const references. I assume that is because stencils
are implemented in terms of non-const references.
As an illustration, consider the example below, which fails to compile
with a "no matching function for call to applyStencil" error.
However, observe that the compiler seems quite happy if only the first
argument is nonconst (commented out line).
Enlightment about this would be appreciated.
Also, I was very disappointed to discover that stencils do not accept
scalar values. This is a *major* usability problem. At least for me, this
means I won't be able to use stencils, since working around this in my
context would be so difficult as to be next to impossible.
I could not find much discussion about this, but in examples/cfd.cpp, I
read:
* - Stencil objects can't take scalar arguments, so all the scalars
* have to be globals. Big ugh. There is a fix for this,
* but it hasn't been implemented yet.
Apparently it still has not been implemented, since I get errors like
" error: `const double' is not a class, struct, or union type" when I try
to pass values as an argument.
Are there any plans to fix this, and what was the fix referred to?
Note this not clear from the documentation, which has at least one example
which will not work, namely.
*********************************************************************
BZ_DECLARE_STENCIL3(smooth2Db,A,B,c)
if ((c > 0.0) && (c < 1.0))
A = c * (B(0,0) + B(0,1) + B(0,-1) + B(1,0) + B(-1,0)) / 5.0
+ (1-c)*B;
else
A = 0;
BZ_END_STENCIL
*********************************************************************
I'm assuming here that c is a scalar, but I suppose it doesn't have to be,
if '>' and '-' are being overloaded here. It does look like a scalar is
meant, though.
Thanks. Faheem.
********************************************
#include <blitz/tinyvec.h>
#include <blitz/array.h>
typedef blitz::Array<double, 3> blitz3d;
using namespace blitz;
BZ_DECLARE_STENCIL2(test_stencil, P1, P2)
P2 = 2 * P2 + Laplacian3D(P2) - P1;
BZ_END_STENCIL
void foo(const blitz3d& A, const blitz3d& B)
//void foo(blitz3d& A, const blitz3d& B)
{
applyStencil(test_stencil(), A, B);
}
int main(void)
{
return 0;
}