## matrix – Efficient construction of a SparseArray from LIL (list of lists of column entries)

In Python scipy.sparse, there are methods to convert between CSR, CSC, LIL, DOK, etc. implementations of a sparse matrix. What is the most efficient way in Mathematica to construct a `mxn` `SparseArray` from the LIL data? (inverse of this question)

More specifically, I have a list `ll={l1,...,ln}`, where each `lv` is of the form `{{u1,w1},...}`, which means the matrix has an entry `{u,v}->w`. Note that `lv` may be empty (zero column). Note that `lv` may have repeated entries, which should be summed (solution for this is here). For testing purposes, my cases are similar to the following example (e.g. millionXmillion matrix with 10 entries per column, all from the list R):

``````m=n=10^6; r=10; R={-1,1}; ll=Table(Transpose@{RandomInteger({1,m},r),RandomChoice(R,r)},n);
``````

My current solution is:

``````SetSystemOptions("SparseArrayOptions"->{"TreatRepeatedEntries"->1});
LIL(ll_,m_,n_) := Module({l,uu,vv,ww}, l=Length/@ll; If(Plus@@l==0,Return@SparseArray({},{m,n}));
vv=Flatten(Table(ConstantArray(v,l((v))),{v,n}),1); {uu,ww}=Transpose@Flatten(ll,1);
SparseArray(Transpose({uu,vv})->ww) );
AbsoluteTiming(LIL(ll,m,n);)
``````

{5.07803,Null}

Is there a better way? What about parallelization? How could I compile this code? (the matrix entries are integers or rationals)

P.S. Let me just mention that in Python, I haven’t yet found a library for sparse matrices that allows rational number entries (exact fractions). Also, when I set every second column and every second row in a matrix to 0, the scipy.sparse implementation is waaay slower than Mathematica’s SparseArray (by a factor of 100). So I’m incredibly happy we have this data structure implemented in Mathematica in such an efficient way.

Posted on Categories Articles

## Summarize least relevant entries of table into a "Others" row

I have a table with ~100 rows that can increase or decrease over time. I want to filter this table so that it shows the top N items and the sum of the rest in synthetic row called "Others". I don’t want to use Google Apps Script for this.

How should I approach this in Google Sheets?

Posted on Categories Articles

## nt.number theory – Non-singular matrix with restricted entries

Given a set $$S$$ of integers with $$1 notin S$$, let us consider the set $$mathcal{M}$$ of all the symmetric matrices $$M$$, such that:

(i) All the diagonal entries of $$M$$ are equal to $$1$$.

(ii) All the off-diagonal entries of $$M$$ are from $$S$$.

Obviously, if $$S$$ only consists of numbers divisible by a prime number $$p$$, then a $$M in mathcal{M}$$ is always non-singular. This can be seen by either analyzing its rank over $$mathbb{F}_p$$, or just expanding its determinant.

Now, the question is, is it true that every $$S$$ such that all satisfiable $$M$$ are non-singular must be a subset of $${cdots, -2p, -p, 0, p, 2p, cdots}$$ for some prime $$p$$? I feel that this must have been studied in the literature but was not able to find it after extensive search. A natural thing to try first is $$S={k, k+1}$$ for $$k ge 2$$, one can actually construct the following singular $$2k times 2k$$ (symmetric) matrix:
$$begin{bmatrix} (k+1)J_k-kI_k & kJ_k\ kJ_k & (k+1)J_k-kI_k\ end{bmatrix}$$
It is singular because the sum of the first $$k$$ rows is equal to the sum of the last $$k$$ rows.

Posted on Categories Articles

## How to change the legend entries in micrososft word chart?

I can’t change the legends in my micrososft word (Office 365) chart. I got the doc by mail from an other person so i don’ have the original excel table. When i click on edit data it says it could’t find the source file but nothing else.I want to change the labels in the red circle. Ignore the hungarian language.
How can i change it with only the word file?

Posted on Categories Articles

## how to fix malformed entries in a list

I am getting this message
E : Malformed entry 53 in list file /etc/apt/sources.list

Line 53 and 54 in the list are :
line 53 : deb https://dl.winehq.org/wine-builds/ubuntu/bionic main
line 54 : # deb-src https://dl.winehq.org/wine-builds/ubuntu/bionic main

what is the correct entry for this line else how can i fix it?

## kubuntu – Remove System leave entries from Kickoff at Plasma

I have stared exploring kickoff source files but still haven’t not found the answer to remove K → Leave → System {Sleep,Reboot,Shutdown} entries ever possible?
I believe there should be something to enter to ~/.config/kickoffrc.

I was searching at:

``````/usr/share/kservices5/plasma-applet-org.kde.plasma.kickoff.desktop
/usr/share/metainfo/org.kde.plasma.kickoff.appdata.xml
/usr/share/plasma/plasmoids/org.kde.plasma.kickoff/ subfolders's files
``````

Setting permisions to /bin/systemctl is not an option for me.

Posted on Categories Articles

## Autofill Google sheets template based on new entries in column A of “master” sheet

I am a teacher and I keep my student data on a Google sheet. I have a “Student Data Report” template that will automatically copy as a new sheet with the student id as the sheet name as I enter new students to my roster on my master sheet. So, “sheet1” is the roster of students with their IDs in column A, “sheet2” is the report template, and sheets are automatically added as I enter new students to my roster (with the student ID as the sheet name).

I have added formulas to the cells in the template so that when I add the student ID# the rest of the report will automatically fill in the student’s information from sheet1 (for example column B is the student’s name, column C is the student’s date of birth, etc.). Is it possible when a new sheet is created for the student ID to automatically fill in which would then cause the rest of the cells in the report autopopulate based on the student ID?

I tried the script below and then put =sheetName() in the corresponding cell, but the cell just said “copy of template” even though the sheet was named with the student id #.

function sheetName() {
}

Thanks!

Posted on Categories Articles

## data structures – How should I design a database where each user can have ten lists with thousands of possible entries?

I am trying to design a database where each user can save up to ten lists of cards. Each list could theoretically have tens of thousands of items, but will likely only have hundreds.

Should I create a new table for each user? I feel like this would make the database really hard to manage.

Alternatively, if I just have one table, it could have 10*number of cards(tens of thousands)*number of users of entries, which could be millions. And if each user is adding to and querying the table very frequently, it seems like that could get very bloated.

Maybe it is obvious, but I am really new to database and relational design, and I need something that could scale to quite a lot of users (likely tens of thousands).

I have looked at several different posts, and the theme I am noticing seems to be to just have one table, but it is likely that this table would have millions of entries, and possibly close to a billion, and it would be queried very frequently.

If there is another way of designing this, besides one table for each user/one table for all users, I haven’t found that either, but I am open to suggestions.

Posted on Categories Articles

## Under 20.04.1 lts I have multiple entries for the same printer and some of those entries are flashing !? ???FIX?

I have 2 network printers. Ubuntu finds and installs both of them this way. This can’t be ‘right’.

Posted on Categories Articles

## unity – Should I send the entries using a tickrate? Netcode Authoritative Server

I am developing a 2D platform and shooting video game in Unity 2D with authoritative logic / physics on the server (The physics server is also developed in Unity to be able to use the box2D library on both the client and the server).

Currently I am working on the basic communication functionality between the client and the server using socket to send the client’s inputs to the server and executing the physics on it. And this is where I find myself with a question that I can’t solve after searching a lot on google and forums.
When should you send the client’s inputs to the server? Setting a delivery tickrate or each time the user clicks on the controls?

As I have analyzed on my own, what seems more efficient at first is to send the inputs to the server each time the client presses one of the game controls. And on the other hand that the server sends the clients the status of the game (player movements, changes in physics, etc.) using a tick rate.
This is a diagram of the communication and behavior that I am developing: As you see this operation. Should I also set a tickrate on the client?

Thank you very much.

Posted on Categories Articles