[SciPy-dev] Weave/blitz element index type-error (?)

eric eric at scipy.org
Tue Mar 26 09:39:51 CST 2002


Hey Keith,

>From my quick test, it looks like the version of Blitz that weave currently uses
(blitz-20001213) doesn't actually support this.  I included my little C++ test
program below.

My experience with newer Blitz versions was never to pleasant -- when I found
one that worked on Windows and Linux, I went with it.  However, I haven't played
with the most recent versions -- perhaps they are better?

What version of Blitz are you using?  Are you having good luck with it?  I'm
happy to upgrade the weave package if there is a "drop in solution".  In fact,
rumor has it that some of the newer Blitz versions are set up to compile in
about half the time for many situations, so upgrading would have this added
benefit.

eric


------ test command an program --------

C:\temp>g++.exe -O2 -w -Wstrict-prototypes -IC:\Python21\weave\blitz-20001213 -c
C:\temp\wt.cxx

#include "stdio.h"
#include "blitz/array.h"

int main()
{
    blitz::Array<int,2> a = blitz::Array<int,2>(5,5);
    blitz::TinyVector<int,2> _Na = a.shape();

    typedef unsigned int index_type;

    const index_type middle = 2;

    a(middle, middle) = 9;
    printf("middle: %d\n",a(middle,middle));
    return 0;
}

----- Original Message -----
From: "keith roscoe" <k.roscoe at freeuk.com>
To: <scipy-dev at scipy.org>
Sent: Tuesday, March 26, 2002 10:29 AM
Subject: [SciPy-dev] Weave/blitz element index type-error (?)


> Dear all,
>
> When trying to directly access the elements of a 2D Numeric array (
> passed to weave.inline as a blitz array), I get a compilation failure
> when using type 'unsigned int'  for the element index.  However, using
> type 'int' for the index compiles and executes perfectly.
>
> Blitz doesn't have this limitation when used in a stand-alone C++
> program, which leads me to believe it may be a bug.
>
> But the weave compilation doesn't fail for 1D arrays though, so I'm
> hoping that it's my understanding that's at fault.
>
> At the end of the message is some code that exhibits this behaviour.
> Change the value of _break_compilation to 1 to make the compilation
> fail.
>
> Regards,
>
> Keith
>
>
> My setup:
>
> Python:  2.2
> Numeric: 20.3
> weave:   CVS  (affects 0.2.3 also)
>
>
>
> # -------------- Start of problematic code ----
>
> import Numeric
> import weave
>
> """
> Demonstrates weave compilation failure when indexing type is
> unsigned for 2D arrays.
> Toggle '_break_compilation' flag to show bug.
>
> Working output (_break_compilation == 0)
> ---------------------------------------
>
> Before weave:
> [[0 0 0 0 0]
> [0 0 0 0 0]
> [0 0 0 0 0]
> [0 0 0 0 0]
> [0 0 0 0 0]]
>
> After weave:
> [[0 0 0 0 0]
> [0 0 0 0 0]
> [0 0 9 0 0]
> [0 0 0 0 0]
> [0 0 0 0 0]]
>
> Fails to compile for _break_compilation != 1
>
> """
>
> # set to 0 for working code, set to 1 to break it.
> _break_compilation = 0
>
>
> def main():
> a = Numeric.zeros((5, 5))
>
> if _break_compilation:
> index_type = "unsigned int"
> else:
> index_type = "int"
>
> print "Before weave:"
> print a
>
> code = \
> """
> typedef %s index_type;
>
> const index_type middle = 2;
>
> a(middle, middle) = 9;
> """ % index_type
>
> weave.inline(code, ['a',],
> type_converters = weave.converters.blitz)
>
> print "\nAfter weave:"
> print a
>
>
> if __name__ == '__main__':
> main()
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev
>





More information about the Scipy-dev mailing list