Re: adding rows to a table of data by looking in the table
- To: mathgroup at smc.vnet.net
- Subject: [mg81481] Re: [mg81381] adding rows to a table of data by looking in the table
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Wed, 26 Sep 2007 06:27:23 -0400 (EDT)
- References: <200709210708.DAA07784@smc.vnet.net>
Mitch Stonehocker wrote: > I' m struggling to get something clean and efficient and would like some > help. Given a set of data in the form: > > data ={ > {x1,1, x1,2, .., x1,n}, > {x2,1, x2,2, .., x2,n}, > {:, :, =83, :}, > {xm,1, xm,2, .., xm,n} > } > > where n columns are of fixed width but m rows grow by appending new rows to > the data set. Exactly what gets appended depends on values of specific data > elements in the data set. For example, nextRow If[xm,1>0&&xm,2=A3xm,3,{},{}]. > > If the nextRow condition is True then appending[data,nextRow] the next > iteration of data should look like: > > data ={ > {x1,1, x1,2, .., x1,n}, > {x2,1, x2,2, .., x2,n}, > {:, :, =83, :}, > {xm,1, xm,2, .., xm,n}, > {, , .., } > } > > And so the process goes for some number of steps continuing to add rows to > data. > > Thanks for the help, > > Mitch If the total number of added rows is small you can just use data = Append[data, nextrow] I assume this is not the case (or else you wouldn't likely be raising the question). Some ideas for how to do this relatively efficiently can be found at: http://library.wolfram.com/conferences/devconf99/lichtblau/ In particular you might have a look at the "Sparse arrays (hash tables)" and "Queues" sections. What works best will depend on what sorts of array elements you have, the extent to which memory footprint is or might become an issue, lookup speed requirements, etc. Daniel Lichtblau Wolfram Research
- References:
- adding rows to a table of data by looking in the table
- From: "Mitch Stonehocker" <mitch@aitoconsulting.com>
- adding rows to a table of data by looking in the table