Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Compile function and AppendTo for lists (vrs. 8.0.4)
Replies: 8   Last Post: Feb 1, 2012 3:50 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Patrick Scheibe

Posts: 327
Registered: 5/22/07
Re: Compile function and AppendTo for lists (vrs. 8.0.4)
Posted: Jan 31, 2012 5:43 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi Fred,

some short notes:

> appendBag2a = Compile[{{k, _Integer, 0}}, Module[{p = Bag[Most[{0}]]},
> Do[StuffBag[p, Bag[{1, i}]], {i, 1, k}];
> Table[BagPart[BagPart[p, i], All], {i, 1, k}]]];
> That works fine and fast,

But look that your type p is clearly wrong. p is a bag of bags of
Integer and has to be initialized with


We can only guess about the reasons why it works anyway. If it is
implemented with pointers, than it seems the integers of your p-Bag are
used to store the pointers.

> The problem seems to be the initialization of the
> locale variable p. I tried compilation with the definitions p=Bag[],
> p=Bag[{}], p=Bag[Rest[{0}]], p=Bag[Rest[{{0,0}}]], or e.g.

Now you know how.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.