Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

4
votes
1answer
47 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 ...
2
votes
1answer
139 views

How to generate a $ 9 \times 9 $ matrix like Sudoku ?

i want to generate a matrix that the number in each row, colum contains 1-9,and not repeated. my code always fall into no solution. here is my code. ...
4
votes
1answer
259 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 ...
13
votes
1answer
250 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
156 views

ByteCount on Function

I was comparing RAM and CPU efficiency for List, Rule, Association, Function. The following code ...
3
votes
1answer
69 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 ...
4
votes
3answers
253 views

Can I use ListDeconvolve or any other functions to get the original kernel?

I have seen an example in the help document: data1 = {0., 0., 1., 2., 1., 2., 1., 0., 0., 0.}; ker = {1/3, 1/3, 1/3}; conv = ListConvolve[ker, data1, 2] my question ...
1
vote
1answer
85 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
54 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
79 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
39 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
97 views

Select several values in nested associations

I have nested associations like this: ...
1
vote
0answers
40 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
75 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
58 views

HDF5 does not support string?

I did a simulation for Baccarat. So some results are saved like this. ...
3
votes
0answers
35 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
48 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
410 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
65 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
175 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
107 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 ...
11
votes
3answers
195 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
50 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
109 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: ...
7
votes
3answers
175 views

How to disallow the application of functions outside a white list?

In an earlier post I described a special kind of list (actually, a special kind of multiset) that can be represented more efficiently with a structure like this: ...
20
votes
3answers
741 views

How to implement a discrete data representation?

I'm currently working with large datasets of "discrete data". Each of these is a multiset of real numbers of the form $kS + B$, where $k$ is an integer, and $S$ (the "scale") and $B$ (the "bias") are ...
14
votes
1answer
681 views

How to use classical data structure in Mathematica

As a C programmer, I have used Mathematica for a month. In this process, I discovered that some problems cannot be solved via the built-ins, owing to lacking of data structure like ...
25
votes
1answer
660 views

How to use the iterator in Mathematica

I find the Mathematica has the iterator data structure. We can build some iterators like this: Constant iterator GeneralUtilities`ConstantIterator[5] Key ...
3
votes
2answers
295 views

Convert between list of 3D coordinates and 2D array

I have a dataset that I import from a csv file. It's a rectangular array of values, with the first row and first column specifying the x and y coordinates. I want fit this data to a 2D function using <...
6
votes
6answers
158 views

List structure transformation

How to transform a list as {{x,y},{a,b,c,d,e}} into the form of {{x,y,a},{x,y,b},{x,y,c},{x,y,d},{x,y,e}} elegantly, ...
0
votes
1answer
56 views

How does one create getter methods that depend on a variable (besides its argument)?

In the (as always) insigthful answer by Leonard Shifrin to this MMA SE post https://mathematica.stackexchange.com/questions/52393/how-to-make-use-of-associations ...
2
votes
0answers
91 views

List, Association, and Dataset, according to what principles to choose which one to use?

List, Association and Dataset are three 'objects' that can be used to store data in MMA. So ...
1
vote
3answers
79 views

Clustering with a certain number of members

Is it possible to find exact number of clusters with exact numbers of members in each cluster? Something like this: ...
5
votes
2answers
365 views

How to efficiently implement Disjoint Set/Union Find data structure?

The data is a list of lists (sets), where all the elements are distinct. There are basically two operations. Find the position that contains a certain element. (And fast accessing the set with this ...
5
votes
4answers
729 views

Is *.dat file suitable for storing high (>2) dimensional matrix?

The typical process goes as first one exports a numerical matrix mat Export["test.dat",mat,"Table"] and then imports it back ...
4
votes
1answer
139 views

Create tree association using table

Suppose I have a table like the following (This example is simplified, actual table is much larger), it is read from external files: ...
1
vote
0answers
37 views

Looking for a package for data on (sparse) uniform grids

I have large amounts of sparse 2d and 3d "volumetric" data, i.e. fixed data associated with positions in a uniform (integer coordinate) grid. I think of it as partial function $$f: \mathbb Z^n \to D.$...
0
votes
0answers
47 views

Data structures in mathematica for choosing permutations

I am trying to classify permutations of n, in this case n=6, elements depending on the cycles that contian the points 1 and 2, since these are considered to be special points. So for example, I will ...
3
votes
1answer
87 views

Dealing with a large number of optimizations performed with parameters read in from a CSV file

I have a large CSV file (1.5M rows), with each row containing a set of parameters that I need for an optimization routine in Mathematica. I'm hoping to import the data, run the computation, and then ...
0
votes
1answer
73 views

Manipulation of imported Datafile

Since I am solving a differential equation in a for loop with NDSolve ...
2
votes
0answers
69 views

How to implement shared data structures?

If I have a shared data structure like you would find in nested C structs, how would I best implement that in Mathematica? I have some "object-oriented" code I would like to port to Mathematica. It's ...
7
votes
1answer
59 views

KaryTree of Text .csv and Correlation

How can I make a KaryTree of this raw-data (raw-data at the end of the question): This is is data from a political survey in which I ask 5 questions with the following possible answers: Q1: 'Y'= Yes,...
2
votes
0answers
54 views

How to use a picture to store some data [duplicate]

As we know.The values of the types is "Real" defaultly in Mathematica.In the Image documentation's detail we can see Image[...
4
votes
1answer
245 views

Immutability, Association and typing

I have read the article by Leonid on the question. I am still struggling. I am trying to use Association to inject some pseudo-typing in my code. Here is my ...
0
votes
0answers
27 views

Mapping Functions to Associations [duplicate]

If I have the association matrix listed bellow and I want to apply: ...
1
vote
2answers
177 views

Creating Association [duplicate]

I have provided a dataset bellow and I would like to store the data as an Association that I can query. Such that e.g. ...
2
votes
2answers
103 views

Merge two trees into a rectangular matrix in Mathematica

How can I merge two trees, t and s, so as to form a square matrix below, where both trees starts from top-left (as shown), and ...
10
votes
7answers
787 views

Extract left-upper triangular data from a square matrix-form list

Hopefully, this question is not too basic or obscure. I'd like an idea on how to extract this {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}} from ...
4
votes
0answers
173 views

How to transform a tree-form list to matrix-form list in Mathematica? [closed]

Excuse my naive question. Is there a quick/efficient way to transform {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}} to a lower-triangular matrix-form ...
1
vote
1answer
1k views

How to fit multiple Gaussian peaks to data [duplicate]

How would I fit this data with Gaussian Peaks? I have tried various codes but none have even worked. Note: If I do Log[data], the peaks are more visible (I have tried the method from here but it got ...