Performance Optimization – Generate a coefficient array from the general formula of the linear equation system

This is a problem that occurs when implementing the finite difference method (FDM).

Here is a toy example. Suppose we want to solve the boundary value problem (BVP).

$$ y & # 39; & # 39; (x) = sin (x), y (0) = 0, y (1) = 0 $$

eq = y & # 39; & # 39;[x] == Sin[x];
bc = {y[0] == 0, y[1] == 0};

With FDM we can then program as follows. First write down the corresponding difference formula:

Clear @ dx;
generalformula = (y[x + dx] - 2 years[x] + y[x - dx]) / dx ^ 2 == sin[x];

Then define the grid size and generate difference equations at each grid point:

Points = 25; domain = {0, 1};
dx = @@ domain / subtract (1 - points);
var = table[y[y[y[y[x], {x, ##, dx}]& @@ domain;
differenceeq = table[Generalformula{xDomäne[[Generalformula{xdomain[[allgemeineFormel{xDomäne[[generalformula{xdomain[[1]]+ dx, domain[[-1]]- dx, dx}]~ Join ~ bc;

Finally, solve the difference equations with z. NSolve:

Solrule = NSolve[differenceeq, var][[[[[1]]; // Absolute timing
(* {0.00462427, zero} *)

Incidentally, a comparison with the analytical solution:

asol = DSolveValue[{eq, bc}, y, x]
plot[asol[asol[asol[asol[x], {x, ##}, PlotRange -> All]~ Show ~
ListPlot[solrule[[All, -1]], DataRange -> {##}]& @@ domain

Enter image description here

Alternatively, we can extract the coefficient array Differenzäq and solve it LinearSolveas in the document of CoefficientArrays, This approach is faster than the one used NSolve:

{barray, marray} = CoefficientArrays[differenceeq, var]; // Absolute timing
(* {0,000614324, zero} *)
sol = LinearSolve[marray // N, -barray]; // Absolute timing
(* {0,000488251, zero} *)

However, this is not the end. As already mentioned, we have generated a difference equation at every grid point and then extract the coefficient array from the symbol system in the code above. This procedure can be quite memory intensive and slow if Points is big. Is it possible to generate Barray and Marray directly from general formula and bc programmaticallyin a memorable and not so slow way?


If the above toy example is too simple to illustrate the underlying problem, the following is more complicated to solve the problem mentioned here:

r = 0.8; Glass = (1.45) 2; Air = 1; k = (2π) / 1.55;
n2 = (function[{x, y}, #] & @ (Simplify`PWToUnitStep @
PiecewiseExpand @ if[X^2+y^2[X^2+y^2[x^2+y^2[x^2+y^2<= r^2, glass, air]));
ClearAll[fw, bw, delta]
SetAttributes[#, HoldAll] & /@ {fw, bw};

fw@D[expr_, x_] := 
 With[{Δ = delta@ToString@x}, 
  Subtract @@ (expr /. {{x -> x + Δ}, {x -> x}}) / Δ]bw @ D[expr_, x_] : =
With[{Δ = delta@ToString@x}, 
  Subtract @@ (expr /. {{x -> x}, {x -> x - Δ}})/Δ]

delta[a_ + b_] : = Delta @ a + Delta @ b
delta[k_. delta[_]]: = 0
degree = function[expr, fw@D[expr, #] & / @ {x, y}];
div = function[expr, Total@MapThread[bw@D@## &, {expr, {x, y}}]];
elst = e[#][x, y]    & /@ Offer[2];
discretelhs =
With[{N2=n2[{N2=n2[{n2=n2[{n2=n2[x, y]},
div @ grad @ elst + (n2 k ^ 2) elst - grad[div@elst - 1/n2 div[n2 elst]]];
Points = 100; L = 2; domain = {-L, L}; grid = array[# &, points, domain];
del = #[[2 ;; -2]]&;
delta["x"] = Delta["y"] = -Subtract @@ domain / (points - 1);
vare = Outer[e[e[e[e[#][#2, #3]    &, Area @ 2, del @ grid, del @ grid, 1]// flattening;
discretelhslst =
Flattening when transposing[
     Block[{e}, e[i_][L | -L, _]    = e[i_][_, L | -L]    = 0;
table[discretelhs, {x, del@grid}, {y, del@grid}]], {2, 3, 1}]; // Absolute timing
{barray2, marray2} = CoefficientArrays[discretelhslst // N, vare // N]; // Absolute timing
{val, vec} =
Eigensystem[marray2, -6, 
    Method -> {"Arnoldi", "Shift" -> k^2 glass}]; // Absolute timing
mat = ArrayReshape[#, {2, points - 2, points - 2}] & / @ vec;
MapThread[ArrayPlot[#[[ArrayPlot[#[[ArrayPlot[#[[ArrayPlot[#[[1]], PlotLabel -> Sqrt @ # 2, PlotRange -> All,
ColorFunction -> "AvocadoColors"]&, {mat, val}]

Enter image description here

ByteCount[marray2]/ 1024 ^ 2. "MB"
(* 2.76122 "MB" *)

ByteCount[discretelhslst]/ 1024 ^ 2. "MB"
(* 180,695 "MB" *)

The corresponding problem is how to arrive marray2 from discreet and e[i_][L | -L, _] = e[i_][_, L | -L] = 0; without generating discreet efficient enough?

Algorithms – Find the nearest point in the coordinate system

There are so many points in the coordinate system. If a specific point is specified in the coordinate system, I would like to find the point closest to the distance of the straight line. For example, if you have 800 points, calculate the distance 800 times and find the smallest value. However, I want to develop a more efficient algorithm that does not run 800 times, as it may be sorted in a specific order before searching.
That is, if the points are put into a particular order, it might find it
Could you recommend some terms?

I do not understand the SharePoint permissions system

I have created a site in SharePoint 365. I am the owner. I have full control. However, if I take certain actions (such as changing the navigation settings), I'm told I need to request access. I do that and the request comes to me. I agree, but nothing changes. I still can not complete the action. SharePoint keeps asking me to request access.

Here are my permissions, as originally set up with the site by default.

Here are my permissions, as originally set up with the site by default.

Boot Loop – Error while installing the system update

How can I repair my phone so that it starts up again as usual?

When it tries to start, I see the Samsung Galaxy S9 from Knox Powered by Android screen. After this screen vibrates, it will restart and return to the same screen. Here is a picture of the screen.
Enter image description here

When I press the volume, power, and button below the volume, the same Samsung Galaxy S9 is displayed, protected by Knox Powered by Android screen. After that, a screen for installing the system update will be displayed. Then it will be continued to 28% and restarted. Here is a picture of the screen below.
Enter image description here

While trying to install the system update, I could simultaneously press the volume up and power button. It gave me the following screenshot.
Enter image description here

Samsung Galaxy Tab 3 – Twrp Recovery changes the system version

I have a Samsung Galaxy Tab 3 (sm-t311) that appears in Windows File Explorer as (sm-t311). The moment I flrp twrp (version 3.0.2-0), however, the version sm-t315 is displayed. This causes a problem because ROMs for t311 will not work for t315 and the version will be changed to t315. It is only possible for me to install ROMs for t315, causing a bootloop. What can be the reason for this version change? How to fix it?

How do I upgrade to Windows 10 1903 with users and operating system on different drives?

How do I upgrade to Windows 10 1903 with users and operating system on different drives?

I am currently on Windows 10 1803 and would like to update to 1903.

I have an Ausus FX503VD that has a 128GB M.2 SSD and 1TB HDD. I first installed Windows 10 on the SSD (C 🙂 and changed the path for programs and users to point to the hard drive (D :). I did this because I migrated from a single drive PC whose user directory was significantly larger than 128GB. So I was able to separate the operating system and other files and also use the SSD for a faster start while I was there.

I could easily upgrade to 1803, but now when I try to update to 1903, the following screen appears:

Enter image description here

The languages ​​are all the same: en-US.

It is obvious that this is due to this change, but I have been using this PC for a long time. If I change the user path back to the C: drive, some programs may be buggy and I do not know which one.

Incidentally, I have created symbolic links from C: to D: for the program directories. I could not do that for the user directory because installing Windows under C: created the default user folder there.

Is there a way to force the update without losing my settings and files instead of upgrading? And the moment I change the settings back, would I break access to the programs and users in D: due to incompatibility issues?

Convert a system of second order PDEs into a first order PDEs system

I try to convert like that

$$ H_t = D_H H_ {xx} – vH_x – alpha H Z $$

$$ Z_t = D_Z Z_ {xx} + beta H Z $$

into a system of first order equations. $ D_H $. $ D_Z $. $ alpha $ and $ v $ are constants and $ H $ and $ Z $ Describe the population of humans and zombies that interact like the equations above.

After Harry49's contribution to >> here << I first tried to rewrite the equations as a linear system of laws of equilibrium $ mathbf {q_t + A ~ q_x = S ~ q} $ from where $ mathbf {q} $ = $ (H, H_x, H_t, Z, Z_x, Z_t) ^ T $,

That gives me

$$ begin {bmatrix} H_t \ H_ {xt} \ H_ {tt} \ Z_t \ Z_ {xt} \ Z_ {tt} end {bmatrix} + mathbf {A} begin {bmatrix } H_x \ H_ {xx} \ H_ {tx} \ Z_x \ Z_ {xx} \ Z_ {tx} end {bmatrix} = mathbf {S} begin {bmatrix} H \ H_ { x} \ H_ {t} \ Z \ Z_ {x} \ Z_ {t} end {bmatrix} $$

My next step would be to determine the coefficients of the matrices $ mathbf {A} $ and $ mathbf {S} $where I get confused because of the coefficients that couple the equations. I'm not even sure if the approach I've chosen is legitimate for my type of problem and would be happy to receive any kind of help!

Many Thanks!

File system – Where can a server-like application store its persistent data?

/ srv: Data for services provided by this system

Reason

The primary purpose of this specification is to allow users to find the location of the data files for a particular service, and to make sense of placing services that require a single tree for read-only data, writeable data, and scripts (such as CGI scripts). Data that is only of interest to a particular user should be placed in the home directory of that user.

The method for naming the subdirectories of / srv is not defined because there is currently no consensus on how to do this. One method of structuring data in / srv is the protocol, e.g. ftp, rsync, www and cvs. On large systems, it may be useful to structure / srv by administrative context, e.g. For example, / srv / physics / www, / srv / compsci / cvs, etc. This configuration varies from host to host. Therefore, no program should rely on a particular subdirectory structure of / srv or data that must necessarily be stored in / srv. However, Srv should always be present on FHS-compatible systems and should be used as the default location for such data.

Personally, I would use a personal mount point for that. Facilitates the backup of this data.

linux – Simple buffer overflow attempts to lose the address of system ()

Code is:

                #include 

Void Vuln (char * arg) {
char buffer[10];
strcpy (buffer, arg);
}

int main (int argc, char ** argv) {
vuln (argv[1]);
return 0;
}

I've found that I can enter a 26-character buffer to override EIP. In gdb the address of

System (): 0xb7e41b40
"/ bin / bash" part of $ SHELL: 0xbffffdac 

when I run

Run $ (python -c "print (& # 39; a & # 39; * 22) + & # 39;  x40  x1b  xe4  xb7 & 39; + & # 39; FAKE & # 39; + & # 39;  xac  xfd  xff  xbf & # 39; "

in gdb it will drop me into a shell. Unfortunately, this does not work in the shell due to ASLR. GDB tells me that strcpy is at 0xb7e7c750, which has an offset of 0x3AC10 from system (). What I think is that if I can somehow store the strcpy address at runtime and use the offset (and the offset to the string), I can get it to execute the system ("/ bin / bash"), which is essentially the is what i & # 39; I'm doing in GDB without the ASLR.

Any tips … or notes on the applicable documentation would be very grateful. I try to exploit the error successfully without disabling security measures.

Currently there is ASLR, PIE, ASCII armor, NX (suppose) and SSP (this is also assumed). I'm on Debian 9-track. Many Thanks!