Questions tagged [data-structures]

Questions on using or implementing more or less common data structures such as linked lists, structs, trees, tries, heaps etc. in Mathematica.

Filter by
Sorted by
Tagged with
0
votes
0answers
25 views

Problem of application of HashTable in Fibonacci

As we can see the example in ref/datastructure/HashTable This code show the usage of HashTable, Fib is the implement of Fibonacci Number with HashTable. If we ...
1
vote
0answers
42 views

Going through all the cases in a rule list

So, I want to have explainable equations derived from replacement rules. I made a Mathematica function that does the following, it takes a list of rules, and it applies them (using ReplaceAll), then ...
5
votes
2answers
87 views

Customized priority function in DataStructure[“PriorityQueue”]?

I'm using Mathematica 12.1. The documentation for DataStructure["PriorityQueue"] claims that, ... the highest-priority element is always returned. The ...
7
votes
2answers
208 views

Best way to insert element into an ordered list at the correct position?

Suppose I have an ordered list orderedList and I want to write some code that will involve regularly inserting new elements into ...
0
votes
0answers
55 views

Is a tree structure possible in Mathematica?

Let's say I have a vector, vector={1,2,3,4,5,6,7}; and I want to use its items as leaf nodes in a tree datasctructure, then work with them as such, adding new ...
1
vote
1answer
59 views

A more efficient way to interrogate data inside a Dataset: a generic relational map

I have a Dataset that stores the relationships between people IDs (in columns) and the events they attended (in rows). I want to produce a linear text report of those relationships. How can I do this ...
16
votes
2answers
351 views

How to determine if two mutable data structures are the same?

How can I determine if two mutable data structures (DataStructure) are truly the same? I do not mean checking if they have the same value. I mean checking if they ...
13
votes
1answer
216 views

How to use DataStructure in FunctionCompile?

The official document said compile a function that can work with data structures but how to use it? There is no doubt that it is possible to use DataStructure as a function parameter: ...
10
votes
1answer
203 views

How to use the new DataStructure in V 12.1 as is done in classical struct?

There is new DataStructure in V 12.1. I thought at first it is similar to classical struct or record found in other languages and discussed in Struct equivalent in Mathematica? How to use classical ...
13
votes
2answers
609 views

COVID-19 Wolfram Data Repository Retrieval

I'm using this dataset to check out the data on new COVID-19 cases. But there are two issues: Two days ago it was working great and it had data up to March 13; 1 day lag. Now when I run the cell in ...
5
votes
1answer
144 views

Implement abstract algebraic structure

I would like to implement algebraic structures in Mathematica such as groups, algebras, Lie-algebras, Hopf-algebras, ... In particular, after initialising such a structure, I would like to have ...
0
votes
1answer
45 views

How to discritize a function domain (break xy-plane to a grid/mesh of squares with vertex values for evaluation)? [closed]

I wrote a code using MATLAB to discritize a function's 2D domain into squares/rectangles, whose vertex data (x,y) I can use to evaluate the function at. Then I sum these values over all vertices to ...
2
votes
1answer
39 views

How to increase the pointsize of the point-markers in the legend of a cluster-chart?

I start the following mock data set: data = RandomReal[{0, 700}, {10^4, 2}]; I use k to define the number of cluster points: ...
1
vote
1answer
32 views

How to view data labels corresponding to cluster points when using FindClusters and Tooltip?

I go straight to the subject; I have the following data set: ...
3
votes
2answers
68 views

Format table output

I'm trying to make a quick code to give me coordinates of some circles to be read in AUTOCAD. When I use the format "Table" or ...
5
votes
4answers
292 views

Threading data on TimeSeries

Say I have two TimeSeries: x = TimeSeries[{2, 4, 1, 10}, {{1, 2, 4, 5}}] y = TimeSeries[{6, 2, 6, 3, 9}, {{1, 2, 3, 4, 5}}] x has a value at times: 1,2,4,5 y ...
7
votes
2answers
422 views

How to import .txt file with missing data?

I have a .txt file that looks like this (direct copy from the file): ...
1
vote
1answer
93 views

How to join N datasets with common headers?

I am new to Dataset. I'm trying to join many datasets, naively trying to use Join, but I think I'm not using it correctly, or ...
8
votes
1answer
212 views

Most efficient method for export/import of non-traditional tensor-style dimensions of matrices/tables/lists-of-lists-of-lists(-of lists)?

Hello World! (I did it for my first answer, so it only feels proper...I'm not nostalgic, you are!) OKAY, here we go! Let's start off with the good-stuff, here's my code, made relatively arbitrary, ...
11
votes
1answer
155 views

Implementing core data structures

Data structures are your friend. Using the right data structure in the right place means better performance and less work on the programmer's part. This poses a problem in Mathematica, of course, ...
6
votes
2answers
607 views

Convert a huge txt-file into a dataset

My friend has this huge txt-log of sea levels. He wants to organize it into a dataset. After importing it this file a used StringSplit to separate it into rows, then to singular elements ...
0
votes
1answer
139 views

How can I translate some JavaScript code into Mathematica code? [closed]

I am a programmer and would like to understand another field outside of the procedural thinking of if-else and for. I would like ...
13
votes
1answer
624 views

Pascal records and Mathematica programming

Background: "experienced" Pascal-programmer (DOS-era, never got into OOP) proud owner of Mathematica ver 11.2 have used Mathematica for years to do my share of number crunching and plotting to ...
13
votes
6answers
249 views

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

I have an arbitrary ragged nested list-of-lists (a tree) like A = {{a, b}, {c, d}, {{{e, f, g, h, i}, {j, k, l}}, m}, n}; Its structure is given by the rules <...
4
votes
2answers
321 views

Converting from “matrix” data into “coordinate” data

Say I have data which looks like data1 - this is "matrix" like data (is there a better descriptor?). The data looks like a matrix, and at each point in the matrix, ...
3
votes
0answers
140 views

Approximate Nearest Neighbors in Mathematica?

Is there any support for Approximate Nearest Neighbors (ANN) in Mathematica or third-party packages? I'm looking for a good implementation of locality sensitive hashing for applications where ...
3
votes
1answer
73 views

What's the best way to import such dataset?

https://www.ocr.org.uk/Images/400305-large-data-set-lds_1-h630-2018-h640-2018-2019-pre-release-data-mei.xlsx What's the best way to import such dataset? I have tried to use ...
7
votes
0answers
95 views

Substitute for Association inside Compile?

Associations are not compilable, so I’m looking for a workaround to this. That is, I need a mutable hashtable-like data structure with fast key value lookups ...
4
votes
1answer
98 views

Local Storage of Periodically Collected Data (without using DataDrop)

I would like to take periodic measurements (e.g. noise levels and temperature in my office from a Raspberry Pi, etc.), say, every minute and have a long-reaching record of this similar to Stephen's ...
9
votes
1answer
738 views

Tree-like data sets with efficient storage and retrieval

Most probably this is going to be a duplicate, sorry. I found too many questions/answers here about tree-like structures, and still could not locate what I want. It is a followup of my previous ...
14
votes
1answer
261 views

Data re-structuring by Thread

Thread can do this Thread[{a, {b, c, d}}] {{a, b}, {a, c}, {a, d}} But when above ...
5
votes
3answers
192 views

ByteCount on Function

I was comparing RAM and CPU efficiency for List, Rule, Association, Function. The following code ...
3
votes
1answer
116 views

Get the dimensions from the SparseArray properties

In the sparse matrix, we have a list of properties: specified elements, dimension, default, and density. I am interested in getting this data without calculating them again. For an example, the ...
2
votes
1answer
173 views

SparseArray: accesing nonzero row and column entries

I have an enormous $m\!\times\!n$ sparse matrix $d$ with $l$ nonzero entries, stored as d=SparseArray[{{i1,j1}->w1,...,{il,jl}->wl},{m,n}];. How do I access ...
0
votes
1answer
59 views

Given a data set, how to do the following

Please help in executing the following problem in Mathematica: I have the following set:$A=\{1, 2,3,4,5,6,7,8,9,10\}$ (my actual data has more than 10 points). I need to do the following three steps: ...
1
vote
1answer
160 views

Dynamically update of Association

I try dynamically to add new keys and update the values of existing keys in given dataset (Association). I implement this by the following code: ...
0
votes
1answer
63 views

Delete duplicates and sort a list of sets separately? [closed]

I have a set where it has three subsets. I want to have each element of each subsets appears only once, sorted, but the order of subsets does not change. For example: I want to get from $$ \{\{5,2,2,3\...
1
vote
2answers
141 views

Select several values in nested associations

I have nested associations like this: ...
2
votes
0answers
59 views

Create Association from Expression

I have a set of algebraic expressions of a certain form, and I would like to make them into Associations in a specified way. My expressions are formed of two heads, ...
1
vote
3answers
83 views

Simple implementation of a multi-part ratio data structure

A multi-part ratio would be an expression of the form: $e_1:e_2:e_3:\cdots:e_n$ It would have the following properties: When the expressions are natural nos, they can be evaluated to be $$\frac{...
3
votes
0answers
90 views

HDF5 does not support string?

I did a simulation for Baccarat. So some results are saved like this. ...
3
votes
0answers
49 views

Possible to add a “Heading” for the columns in HDF5 format?

A similar post was found here, but it's not using MMA. A small test to export HDF5 file, ...
0
votes
1answer
50 views

determine the structure of Data in sum of two subsets Modulus $n$

I wrote a code below to determine the cases when two subsets of a set $\mathbb{Z_n}=\{0,1,2,\ldots,n-1\}$ are added together element by element (without removing the multiplicity) in $\mathbb{Z_n}$ ...
5
votes
4answers
432 views

count the pairs in a set of Data

I have a list of Data, e.g., list1={0, 1, 1, 1, 1, 2, 2, 3, 3} list2={0, 1, 1, 1, 1, 2, 2, 3, 3, 0} and I want to get as an output ...
0
votes
0answers
76 views

How to organize code for simulating many ODEs?

I have a large model with many variables (about a hundred) and many differential equations (non-linear). What is the best way to handle a system this size in Mathematica? Note that I am not asking ...
5
votes
3answers
245 views

Multi-coloured tree plot

I am trying to create a multi-coloured tree plot (Mathematica 9) where each branch is coloured according to its parent node value. For example, for a tree plot with three nodes, n1, n2 and n3, coming ...
5
votes
2answers
166 views

How to Label only Certain Vertices in a Network Based on Eigenvector Centrality?

Using the Following Network: footballNetwork = ExampleData[{"NetworkGraph", "AmericanCollegeFootball"}]; Graph[footballNetwork, VertexLabels -> "Name"] I ...
12
votes
3answers
207 views

Support for low-complexity (compressible) lists

By "low-complexity list" I mean a list like the following: lcl = {17, 17, 17, 17, 17, 21, 21, 21, 21, 21, 21, 21, 21, 11, 11, 11, 11, 11, 11, 11} ...
2
votes
0answers
55 views

Data structure for finding pairs of matrices under constraint

PROBLEM DESCRIPTION Given three positive integers k, n1, n2, I have a list of matrices matrices = Tuples[Range[0,k], {n1,n2}] ...
3
votes
3answers
121 views

Building matrix from relational data

I'm new to Mathematica, coming from Python, and I'm having a hard time trying to build a matrix from relational data. The data looks like this: ...