Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8258
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Compile function and AppendTo for lists (vrs. 8.0.4) |
| Date | 2012-01-31 10:43 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jg8gk0$147$1@smc.vnet.net> (permalink) |
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
Internal`Bag[Most[{Internal`Bag[{1}]}]]
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.
Cheers
Patrick
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Compile function and AppendTo for lists (vrs. 8.0.4) Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2012-01-31 10:43 +0000
csiph-web