Questions on using or implementing more or less common data structures such as linked lists, structs, trees, tries, heaps etc. in Mathematica.
8
votes
1answer
174 views
Efficient way to solve equal sums $x_1^k+x_2^k+\dots+x_5^k=y_1^k+y_2^k+\dots+y_5^k$ with Mathematica?
I need to solve the system of equations, call it $S_1$, in the integers
$$x_1x_2x_3x_4x_5 = y_1y_2y_3y_4y_5$$
$$x_1^k+x_2^k+\dots+x_5^k=y_1^k+y_2^k+\dots+y_5^k,\;\; k= 2,4,6$$
I used a very ...
2
votes
2answers
122 views
How to populate a table using a rule replacement
I am trying to populate the rows and columns of a table by using a rule replacment.
To generate a table that looks like this
For example Sc would be row 1, column 1.
An example of a record looks ...
6
votes
2answers
114 views
DownValue “associative array” to list? [duplicate]
I have a "sparse array" like this
arr[1.5]=0.4, arr[3.5]=0.7, arr[7]=0.3
which is not really a sparse array since the keys are not all integers. This is like a ...
1
vote
2answers
104 views
Efficient Data Entry / Manipulation with Many Datasets
I currently have a simple task of graphing many different datasets (26 here, with many different instances where I'll need to do, say, 26 different ones from the same template). I'm trying to ...
1
vote
1answer
89 views
How do I create a graph with randomly directed edges starting from a undirected graph?
I have an undirected graph $G$. How would I randomly assign directions to some fraction $p$ of the edges? How might I do this efficiently / quickly provided I have a large graph structure?
For ...
0
votes
0answers
39 views
tree of values representation
Main Question
Is there an efficient way to output a tree of values similar to the output of TreeForm?
Something like
...
0
votes
2answers
65 views
Iterating Reads From a Text File and Writing the Results of Operation
I have a very large text (TSV) file. I am able to now read single line, thanks to StackExchange. I am able to read a part of that line using the part operator. I want to iterate through the whole ...
1
vote
0answers
133 views
Data structure for a list of actions
The idea: I need to generate a sequence of events then run a "propagator" over the list of events where the "propagator" will update the state of the following event. I can then write functions that ...
0
votes
1answer
102 views
Read a file into a list of vectors [closed]
I have file structured as (Axis 1) (Axis 2) Data.
As an example:
...
11
votes
1answer
270 views
Efficient code for tallying entries in very large lists
I am dealing with data sets containing tens of millions of (hashable) entries and simply using the Tally function to count the frequency of each unique list element ...
5
votes
1answer
144 views
Processing and storing a graph with a large number of vertices s.t. k-hop neighborhoods are efficiently retrievable
I have an unweighted, undirected graph $G$ with $(v_1, ..., v_N) \in V$ vertices, where each vertex in the lattice represents a string of some length ($\leq 200$ characters), and I need to construct ...
12
votes
1answer
240 views
Creating a R DataFrame like construct in Mathematica
I kept getting my data mixed up so I decided to see if I could construct a package adding a R DataFrame like construct to Mathematica. I managed to cobble something together that sort of works, but ...
1
vote
1answer
138 views
pointer like operations in mathematica and evaluation control
I would like to create a data structure of the type "header[pointer]" where pointer would point to a list. I will shown on an example how I'd like this to work, and where the problems are.
...
1
vote
1answer
112 views
Initialization Time Out (Weighted Financial Data)
I've been playing with WeightedData and wanted a financial engineering example, a colleague suggested working with the fractional return (...
18
votes
4answers
498 views
Efficient circular buffer?
I wish to create an efficient circular buffer. That is, I wish to keep a fixed length list while appending a new value and dropping the oldest, repeatedly.
As we know lists in Mathematica are ...
1
vote
1answer
184 views
How can I create Arguments Maps with Mathematica's graph functions?
I am relatively new to Mathematica, and I would like to know how I could use it to represent an Argument Map, such as those that you generate on online tools such as http://debategraph.org.
The ...
4
votes
1answer
110 views
Accessing the Data of an RLink RDataFrame
I am trying to extract the data table itself from an RLink-generated RDataFrame:
...
6
votes
1answer
170 views
Return a Part by Reference? (For accessing hierarchical / structured data)
Is there a way to return a part of a list by reference, for reading and writing?
I want to do this so I can easily manipulate "rule-styled structured", i.e., hierarchical data that is loaded from a ...
1
vote
0answers
143 views
What's a good data structure to represent a, b, a and b, a or b? [closed]
I have a function foobar[x_] that can produce 4 types of output
a
b
a or b
a and b
What's a good data structure, or better ...
18
votes
4answers
429 views
How can a big table be treated as a database?
I often work with big tables that I want to treat kind of like a database. Here's an example table.
...
18
votes
3answers
548 views
Emulating R data frame getters with UpValues
What's the best way to emulate R's data frames functionality? This includes the ability to select rows and columns in a 2-dimensional table by the string identifiers positioned typically in the first ...
7
votes
2answers
210 views
How to get the list of defined values for an indexed variable?
I would like a table with rational indexes - thus it would be practical to use a dictionary, which, in Mathematica are implemented with the indexed variables. I would like to be able to do:
...
4
votes
2answers
195 views
Access pairs of vectors, rather than the matrices, in partitioned data structure at a levelspec
I have some old code to analyze correlation between 2 time series by looking at windows of different lengths shifting across the time series data. The code:
gets 2 sets of time series data (in ...
8
votes
3answers
865 views
Excel Headers --> Mathematica
I have a large Excel .xls file. Miniature version shown below:
(formatting should appear as two columns...)
...
15
votes
1answer
369 views
Mouse motion heat map - live visualization and analysis
Mouse motion heat map is an great way to study spatial attention distribution, styles of movement, reaction, etc. I am trying to design a code that visualizes such heat map. The requirements: 1) It ...
16
votes
3answers
324 views
How to get complete Documentation Center graph of guide pages?
On the very last image below you can see a typical path of walking through Documentation Center guide pages. What is the best way to get the graph data and visualize the whole structure of these ...
13
votes
2answers
370 views
Question about designing a particular data structure
Background: I store polygons with a color assigned at the face level. In some occasions I want to use vertex colors but I want to store data efficiently, i.e. don't want to duplicate data to the ...
5
votes
2answers
215 views
Extracting parts of nested lists of rules using a syntax similar to JsonPath or Xpath
Given an example data set:
...
5
votes
0answers
213 views
Is it possible to construct a function to make a poor man's Mathematica database?
I have a function that is set up to write to a database with 10-20 standard variables with 10 fields each, but the application is going to a place where database access is not available. Can ...
32
votes
2answers
9k views
How can I use Mathematica's graph functions to cheat at Boggle?
This question is inspired by a Stack Overflow question that I decided to solve using Mathematica. In addition to Mathematica, I thought I'd use some of the new version's graph-related functionality, ...
13
votes
3answers
340 views
Using Memoization with a Mutable Object
In looking for a solution to this question, I ran across some old binary tree code by Daniel Lichtblau, reproduced below:
...
14
votes
4answers
532 views
How to create strong types?
In a program I'm writing, I create a list of lists, that looks something like this:
{{100, {1,2,3,4,5}},
{105, {2,4,6,8}},
{42, {42,39,56}}}
I then pass this ...
13
votes
4answers
293 views
Short syntax for accessing System`Utilities`HashTableAdd and System`Utilities`HashTableGet
I have a need for a struct analogue in Mathematica. After reading this post I came to the conclusion that System`Utilities`HashTable is one of the best options. But ...
8
votes
2answers
176 views
Cases[data,Colon[key,_]] vs. Cases[data,key:_] toward XPath, XQuery
Exploring methods to index and search tree-structured key:value pairs via named-entity index (key paths) as opposed to Position-based indexing.
Using Rule as ...
29
votes
2answers
864 views
What is a Mathematica packed array?
A simple sounding question with a few sub questions:
What is the difference between unpacked vs packed array?
Are packed arrays more space efficent, how much so?
Are packed arrays more time ...
4
votes
1answer
166 views
What's the most intelligent way to store the information of a selfmade graph?
I have a very long list of element, say $a1,a2, a3$,..., and they are all connected in that each is the child of many parents. E.g. $a74$ is associated with $a2,a55,a71$, and also contains ...
17
votes
2answers
472 views
How can one define a custom data object?
In Mathematica there are different objects like InterpolatingFunction or SparseArray? How can I define a custom data object with ...
2
votes
1answer
193 views
Conditional Data Selection, efficiency
Building up on the solution proposed here : Simplifying nested If statements
You can find here the data set : allGazes.dat
...
52
votes
7answers
4k views
Struct equivalent in Mathematica?
I really miss having something like a struct in Mathematica. I know of (and regularly use) a couple of programming techniques which feel like a ...
20
votes
2answers
584 views
Can a Trie be implemented efficiently?
What is the most space and time efficient way to implement a Trie in Mathematica?
Will it be practically faster than what is natively available in appropriate cases?
65
votes
1answer
2k views
File-backed lists/variables for handling large data
Background
Currently I am working with some large data (most of it generated by Mathematica itself). I usually find it a hassle to do this. For example, I just exported a large amount of data to ...



