What is a standard procedure while parallelising a serial code

Question: I have a C++ serial code which simulates a physics algorithm. The C++ code is serially optimised. What is the standard procedure and documentation that is followed while parallelising the code or for GPU acceleration? I am accelerating the code on Nvdia Tesla K40 & Intel Knights Landing cluster.
Comment: The act of writing code doesn't follow "standard procedures."  There are well-known and well-understood tools, techniques and expertise, but no "standard procedures."  Sorry, but you'll have to learn this stuff the hard way, like all the rest of us.  It's not like screwing in a light bulb.
Comment: [Hint: Software Engineering Stack Exchange... expect research before asking](https://softwareengineering.meta.stackexchange.com/a/7826/31260)
Answer: There is, indeed, a standard first-step to this task.
Measure first.
List of performance analysis tools on Wikipedia
This will give you an overview of what are the most intensive computations, the most memory I/O and/or latency-intensive computations, whether these computations are integer-heavy or floating-point heavy. Also, try to find out whether the code uses SIMD.

When prioritizing what to parallelize, there will be conflicts between two preferences:

Optimize the heaviest things first, because of Pareto principle (or, 80-20 rule)
Optimize the easiest-to-optimize things first, because, it's easy and it's doable without costing too much time/effort.

It is hard to say how to choose the middle ground between these preferences.

Check if you're allowed to use OpenMP. It is probably the easiest way to enable multithread parallelization.

Check for, and eliminate, race conditions that will cause code to give wrong result or crash.
Comment: Lastly, it is entirely possible that the data dependencies are such that the algorithm simply *cannot* be parallelized, and the whole thing has to be redesigned from scratch with a *different*, parallel algorithm.
Comment: Best possible answer for an almost unanswerable question. Surely not what the OP expected.
Comment: I admit I jumped the gun. I did not realize the question is focused on GPU parallelization. That was certainly not something that CPU-based approaches could apply to. So, few or none of my advice would apply. I think OP could choose John Forkosh's answer.
Comment: @rwong this is what I exactly needed. I am doing this with no guidance, so I needed some form of validation, though I did mention GPU, I also mentioned Intel Knights Landing. So giving advice of measure first and that Wikipedia article, really helped.
Answer: I don't know about "standard", per se, but if you're building an nvidia-gpu-based box, look at the cuda libraries, https://developer.nvidia.com/gpu-accelerated-libraries In particular, you mention "physics algorithm", which often involves lots of matrix calculations, whereby https://developer.nvidia.com/arrayfire might be most helpful.
Rather than taking your existing codebase and parallelizing it piece-by-piece, you may need to high-level re-analyze your algorithm(s) in terms of the available gpu accelerated libraries, and then decompose your problem in such a way as to make the best possible use of these library components.


If we say the universe is expanding, shouldn't it be expanding relative to something?

Question: I don't understand, if everything in this world is relative to something else, then cannot we essentially say that nothing exists independently? We say that the universe is considered to be the ultimate 'background'. However, if we say the universe is expanding, shouldn't it be expanding relative to something?
Comment: note that instead of expanding space, there's a perfectly valid dual description that shrinks atoms - including rulers; you'll also have to do stuff like speed up clocks, make things more massive and weaken gravity to make it work, but on the plus side, you can get rid of the big bang singularity this way...
Comment: Related: http://physics.stackexchange.com/q/7359/2451 , http://physics.stackexchange.com/q/8115/2451 , http://physics.stackexchange.com/q/98027/2451 and links therein.
Answer: The universe is expanding, in the sense that things in it are getting farther apart. It is not expanding into anything because it already is everything. There simply is nowhere else to expand into.
Lets knock it down one dimension. Your universe is the surface of a balloon. The balloon is slowly being inflated. Your universe is getting bigger but nothing else is getting smaller (remember, you are unable to leave, look from, or perceive anything that is not on the surface). The only thing you can measure is points are further apart than they used to be.
Classical mechanics don't really work at the two extremes: the quantum level and the whole-universe level. If we ever fully understand the whole process I expect we will find that the complete equation applies across the board, but certain factors are negligible at human-perception levels. Motion is a good example here: we don't need relativity to calculate driving times, even though my watch does slow down when I drive to work.
Comment: why this inflation/expansions, not expand our measures as well? So the final measurements remain the same (as in a ballon since it was used as example). In the expanding ballon the measures **also expand** as such the relative measurements should remain the same, no?
Answer: This is the specific definition of expansion (which personally dont agree). That the universe is not expanding wrt to sth (e.g time or space), but it is in fact time and/or space (or more correctly space-time) which expands (according to the theory of Big Bang, et al.).
Comment: @Gummybears Yes the Big Crunch does **not** necesarily follow Big Bang, but if it does it is by the same token
Comment: But according to that definition, if the theory of Big Crunch is true, then time will run backward during that period? Surely there is something preventing that? (Law of Entropy, etc..)
Comment: @Gummybears, check also this related [question and answer](http://physics.stackexchange.com/a/119334/44176)
Answer: Expansion can be orthogonal to real space.  For example, if you blow up a balloon, the surface expands relative to a point not on the surface.  What could be happening here is that the ratio of length to arc of space could be getting bigger, so that a foot occupies less arc than before.
Eventually, we will end up eg 3 ft high, but the mile remains a mile.  Space would have expanded because we would judge ourself to be 6 ft, and the mile would then appear to be two miles.


Determine if car is moving forward or backward

Question: I would like to know if there is someway i can figure out if the car wheel is rotating in clockwise or anticlock wise direction.
Im working on a project which determines if car rolled back on a hill before the user accelerates forward.
I tried this using gps co=ordinates to determine if there is roll back. As this roll back could be in cms before user moves forward, im not getting reliable results.
The only way i can think of now is to depend on wheel rotation. if the wheel rotates backward on slope i would know that it did roll back a little. So is there a way for me to determine if wheel rotated in clock wise or anti-clock wise direction through CAN bus interface or something.
Any help here would be greatly appreciated.
Comment: Have reluctor rings with unequal spacing - then track the pulses...
Comment: Just need to track direction *changes*, rather than absolute direction...
Answer: A quick search for various terms based on "how to read wheel sensors for direction," and "how to read wheel sensors" and a few other variations resulted in a mish-mash of answers.
There are devices available that connect to wheel sensors and output a canbus data stream. The manual for the linked device references that the device can be connected parallel with an existing ABS on the vehicle. The manual also contains a link to free download software to read the device on a computer. I was unable to determine if direction is part of that stream, but I suspect that it is, based on the results of another search:

Magneto Resistive (Active Wheel Speed Sensors)
A magneto resistive sensor has a sensing element that contains an
  output module that is mounted on a substrate and magnetic material.
  These magnetic rings are often located on the seal of the bearing. The
  magneto resistive sensor's main advantage is the ability to sense
  direction and operate with a wide air gap. The sensor is more stable
  in high-vibration conditions and operates more efficiently than the
  reluctance sensor.
The wheel speed sensors can detect the direction of rotation of the
  reluctor ring and zero speed. The sensor's compact size allows it to
  be incorporated into a hub bearing utilizing an alternating magnetic
  pole reluctor ring that is built into the rubber seal. A magneto
  resistive wheel speed sensor power input can range from 12V-5V from
  the ABS controller.
The sensor produces a square wave signal with a high signal of 1.93
  volts, and a low signal of 0.64 volts. The high signal must cross
  1.29V and the low signal must cross 0.97V to low. The main advantage is that the amplitude of the signal does not change.

Additional information suggests that one can use an oscilloscope to read the signal from the wheel sensor, the result of which would be a square wave. I'd expect that the spacing of the square wave may determine the direction of rotation but that's barely-founded conjecture. It's also possible that a pair of square waves are generated by the sensor and the difference between the two determine direction.
Another link I pursued more or less confirms my conjecture, by stating that the newer devices contain two sensors offset from each other:

The sensor assembly consists of two sensing elements mounted
  side-by-side with an amplifier chip built into the sensor assembly.
  The output from each sensing element rises and falls the same way as
  with a magnetic pickup, and the amplifier converts that to digital
  high-low voltage signals. Also, as before, the high-low switching
  frequency is proportional to wheel speed, and because the signal is
  always present, zero wheel speed can be detected. But because the
  sensing elements are next to each other, the two voltage signals are
  always slightly out of phase: one rises or falls just a few degrees
  after the other. That's how the sensor detects the direction of
  rotation. If the signal from element A lags behind the signal from
  element B, the wheel is turning clockwise. If B lags behind A, the
  wheel is turning counterclockwise. The exact same out-of-phase
  dual-sensor technique is used in radio knobs.
Comment: Buying another sensor to achieve this myt not be feasible for my client. But we do have a tracker on that vehicle which has 3 axis accelerometer and 3 axis magnetometer. Can we use this to deduce this information somehow?


$Arg(z+1) = \frac{π}{6}$ and $Arg(z-1) = \frac{2π}{3}$

Question: I'm really stuck
I need to find z when $$Arg(z+1) = \frac{π}{6}$$ and $$Arg(z-1) = \frac{2π}{3}$$
Please help!!!!
Comment: What does it mean for the argument of a complex number to be $\frac\pi6$? $\frac{2\pi}3$?
Answer: Think of it geometrically.

(The angles are shown in degrees rather than radians.) You want point $B=Z+1$ on the ray with argument $\frac{\pi}6=30°$ and point $A=Z-1$ on the ray with argument $\frac{2\pi}3=120°$. In other words, you want to find the horizontal line such that the distance between the intersection points is $2$.
As you can see, the triangle $BAO$ is a right triangle, with hypotenuse $2$. You should be able to find the altitude of that triangle, which will be the imaginary part of $Z$. The real part of $Z$ should then be easy to find. Or, you could find the equations of rays $OB$ and $OA$ and find the value of $y$ where the $x$ values differ by $2$.
Doing this the geometric way, we see that triangle $BAO$ is a $30°$-$60°$-$90°$ triangle with hypotenuse $2$. Therefore the legs are $1$ and $\sqrt 3$, the area is $\frac{\sqrt 3}2$, and the altitude is also $\frac{\sqrt 3}2$. Thus the $y$-coordinate of point $B$ is $\frac{\sqrt 3}2$, the $x$-coordinate is $\frac 32$, and the $x$-coordinate of point $Z$ is $\frac 12$. Putting this together for point $Z$ we get

$$z=\frac 12+\frac{\sqrt 3}{2}i$$

Doing this my second way, the equation of line $OB$ is $y=\frac{\sqrt 3}{3}x$ (since $\tan\frac{\pi}{6}=\frac{\sqrt 3}{3}$), and the equation of line $OA$ is similarly $y=-\sqrt 3x$. Letting $u$ be the $x$-coordinate of point $B$,
$$\frac{\sqrt 3}{3}u=-\sqrt 3(u-2)$$
Solving this gives $u=\frac 32$, so point $B$ is $(\frac 32,\frac{\sqrt 3}{2})$. This means point $Z$ is $(\frac 12,\frac{\sqrt 3}{2})$.
Therefore,

$$z=\frac 12+\frac{\sqrt 3}{2}i$$

This answer checks. (The graphic was updated to place the points in the correct places, reflecting the final answer.)
Comment: Really well done.
Answer: $$
\arg(z+1)=\frac\pi6\implies z+1=r_1e^{i\pi/6}\tag{1}
$$
$$
\arg(z-1)=\frac{2\pi}3\implies z-1=r_2e^{i2\pi/3}\tag{2}
$$
for some $r_1,r_2\ge0$.
Putting $(1)$ and $(2)$ together yields
$$
z=-1+r_1\left(\frac{\sqrt3}2+\frac12i\right)=1+r_2\left(-\frac12+\frac{\sqrt3}2i\right)\tag{3}
$$
For $(3)$ to be true, the imaginary parts must be equal and therefore $\frac12r_1=\frac{\sqrt3}2r_2$. That is, $r_1=\sqrt3\,r_2$. Equating the real parts, we get
$$
\begin{align}
-1+r_1\frac{\sqrt3}2
&=1-r_2\frac12\\
&=1-r_1\frac1{2\sqrt3}\tag{4}
\end{align}
$$
which gives $r_1=\sqrt3$, and therefore,
$$
z=\frac12+\frac{\sqrt3}2i\tag{5}
$$
Comment: Very nice solution.


Moment generating function of a stochastic integral

Question: Let $(B_t)_{t\geq 0}$ be a Brownian motion and $f(t)$ a square integrable deterministic function. Then:
$$
\mathbb{E}\left[e^{\int_0^tf(s) \, dB_s}\right] = \mathbb{E}\left[e^{\frac{1}{2}\int_0^t f^2(s) \, ds}\right]
$$
Now assume $(X_t)_{t\geq 0}$ is such that $\left(\int_0^tX_sdB_s\right)_{t\geq 0}$ is well defined. Does
$$
\mathbb{E}\left[e^{\int_0^tX_s \, dB_s}\right] = \mathbb{E}\left[e^{\frac{1}{2}\int_0^tX_s^2 \, ds}\right]
$$
still hold?
Answer: No, in general this is not correct.
Applying Itô's formula, one can actually show that $$(t,w) \mapsto M(t,w) := \exp \left( \int_0^t X_s \, dB_s - \frac{1}{2} \int_0^t X_s^2 \, ds \right)$$ is a local martingale. There are several sufficient conditions (on the process $(X_t)_t$) implying that $(M_t)_{t \geq 0}$ is indeed a martingale. In this case, one obtains
$$1=\mathbb{E}M_0 = \mathbb{E}M_t = \mathbb{E}  \exp \left( \int_0^t X_s \, dB_s - \frac{1}{2} \int_0^t X_s^2 \, ds \right)$$
Note that this is not equivalent to $$\mathbb{E} \exp \left( \frac{1}{2} \int_0^t X_s^2 \, ds \right) = \mathbb{E}\exp \left( \int_0^t X_s \, dB_s  \right)$$
(It works fine for deterministic functions, since in this case the left-hand side of the last equation does not depend on $\omega$.)
Answer: If $X$ and $B$ are independent, yes (use the first result to compute the expectation conditional on $X$, then take the expectation).
Otherwise, no. For a counterexample, consider $X=B$ and use Itô's formula $\mathrm d (B^2)=2B\mathrm dB+\mathrm dt$.


Where and when did "reach out to" for "contact" or "talk to" become widespread?

Question: I have a feeling that this usage - which I personally find highly irritating, because it suggests either that the initiator of a conversation is helping a person who is in dire straits or that they themselves are in trouble and seeking help from a lifeguard figure - became popular in California, but is that correct?
Comment: It's not clear what you're asking.  The idiom goes back into the 1800s at least, and appears to be used in a wide variety of contexts (though still with the meaning of "contact" or "talk to").
Comment: I'll agree that it is usually irritating. For most uses I've heard, the connotation is too heavy or melodramatic or something. Maybe the question is, "was the expression always this annoying?"
Comment: This is one of the most overused and obnoxious phrasal verbs that there is.
Comment: HotLick - It is very clear. EL_DON - No, that's not the question.
Answer: Reach out and touch someone -- AT&T Commercial 1987
It's supposed to be warm and fuzzy.  I don't know where AT&T got it, or if they made it up.
A little more searching suggests that it comes from a Diana Ross song; Wikipedia:

Reach Out and Touch (Somebody's Hand)" was the debut solo single of
  Motown singer Diana Ross, released in April 1970.

As for the psychological and social significance of the phrase, see the  Psychology Today article When AT&T asked us to 'Reach out and touch someone', did they mean that literally?
The article points out that today, with cell phones ubiquitous, the phrase might mean the opposite of what it did in the 80s. Today, it might mean get off your phone and pay attention to the person you are eating dinner with.
See Meaning of "reach out to somebody" for many interesting answers on what "Reach out" means; the consensus is that it is twaddle.  (Note, the older question does not ask about the origin of the phrase, thus the current question is not a duplicate.)
Comment: Right.  I was trying to find that song but Google claims it can't find "reach out and touch".
Comment: *Reach out and touch someone* is not the same usage as *reach out to*. I don't know if there's any connection between the two.
Comment: @AlanCarmack - Actually, they *are* quite closely related.  "Reach out" is the same basic metaphor in both cases.
Answer: To "reach out" is simply a reversal of the word "outreach" to make it a verb.
According to Merriam Webster, the word means : the activity or process of bringing information or services to people and has been in use since the 1870's.
In modern usage, it can have a submissive context; as in extending an olive branch, or approaching someone with an offering of peace or goodwill. It's meant to be polite, not necessarily a suggestion of helplessness.
Comment: The noun *outreach*, like *throughput* and a number of similar nominalisations, is modern coinage; the earliest usage recorded in the OED was in 1870. *Reach out* was used as early as 1653.
Answer: I don't know about where and when it originated but it seems to me like "reached out" indicates "talk to" because typically when one wants to have a serious conversation with someone they will reach out and touch them.
Comment: *Reach out* connotes initiating contact rather than passively waiting for someone to contact you.


Will any SATA hard drive work with any SATA motherboard?

Question: This is the motherboard I have:
http://www.newegg.com/Product/Product.aspx?Item=N82E16813188024
My question is can I use any SATA hdd/ssd with this? ( as In SATA I, II, or III?)
will a 6 Gb/s hdd work with 3 Gb/s motherboard?
Comment: How about specifics? Do you have this motherboard?  If you do is your question, specifically, will a SATA III device work with it?  If so update your question.
Comment: That is the motherboard I have. My question is can I use a SATA III with SATA I MotherBoard and vice versa?
Comment: I don't believe the SATA interface spec is motherboard specific.  The SATA interface is backwards compatible.
Comment: You don't have a SATA I motherboard though.
Comment: possible duplicate of [6Gb/s SATA hard drive with 3Gb/s SATA port?](http://superuser.com/questions/242423/6gb-s-sata-hard-drive-with-3gb-s-sata-port), [If I my motherboard is SATAI, can it use SATAII hard drives?](http://superuser.com/questions/202022/if-i-my-motherboard-is-satai-can-it-use-sataii-hard-drives)
Answer: Yes. By design, all newer SATA standards are backwards compatible with older SATA standards and will fall back to the slower speed such that they will work.
So it doesn't matter whether it is a SATA 1 controller with a SATA 3 drive or a SATA 3 controller with a SATA 1 drive, or any combination with SATA 2 as well, they should all work together just fine.
The only exception in my experience is that some older SATA drives require a 3.3 volt supply, while most drives work fine without it. This is a power supply issue not a SATA version issue.
To clarify, a 6 Gb/s hdd will work with a 3 Gb/s motherboard, but it will only work at the slower speed.
This is great if you want to go ahead and get some faster drives now and upgrade to a faster mainboard later.
I have had no problems moving SATA drives between different computers.
Comment: There were some early sata II drives that had a jumper on them to make them backward compatible to sata I for some first gen sata motherboards, which required you to know that you had to move the jumper before it would work.


How can I beat an Eagle Artillery in clash of clans?

Question: I am trying to beat an eagle artillery and every time I lose, I never get even one star. I need a suggestion how to beat an eagle artillery so that I can be in the legends league. Is there a spell to stop an Eagle Artillery? Maybe a unit that can take lots of damage? I need some suggestions, can you tell me how to beat that defense?
Answer: Rushing that defense fast!
Golems will be swiftly destroyed so try to destroy the Eagle Artillery as fast as you can or use a hybrid attack (an attack that consists of multiple waves) as that defense will recalculate its targets after every volley. If necessary, bring Freeze Spells or take a chance and Lightning Spell and Earthquake Spell the Eagle Artillery to destruction.
As there is no recommended attack strategy yet, bring armies that target defenses, like Lavaloonion. Bring hastes and rage to help speed up the process. Lots of other tips can be seen here such as:

Spreading out your troops to prevent splash damage
Using heroes as distractions
Using Grand Warden's Ability of temporary invincibility
Using strategies like BARCH, Giants + Goblins, GoWiWi, etc.
Answer: Sorry I'm 1 month late :|
My personal best strategy
Don't deploy more than 50% of your army, deploying more that half activates the eagle artillery.

BUT WAIT
If the artillery is upgrading, Outside or near Outside of the village, then you have a good chance of destroying it.
Answer: Simple, just attack the base that has the Eagle exposed near the outer walls... use a queen walk (queen and 4 healers) and king and warden for distraction.  It's only 75 hs for the heros and the total hs is less than 150 so the eagle won't even be activated.  Its easy to take out eagles when bases have them exposed.


Are power plants legitimate military targets under international law?

Question: I've seen clips and articles stating that recent Russian attacks on Ukrainian power plants amount to "War Crimes". This seems right to me but I couldn't find any resource explicitly prohibiting it. Are these valid/invalid military targets in both practice and theory?
Comment: Before answers go fast and hard with "of course not", pls remember that post-2003 the Iraqi power grid had been somewhat/severely degraded by US bombing.  Now, I don't know what the differences were, what protests were made to the UN, extenuating circumstances, etc... Nor am I wanting to give much whataboutism cover to Putin's gang of thugs.  Just saying that we've at least partially been here before.  Here's some reading of something written at the time:  https://www.washingtoninstitute.org/policy-analysis/infrastructure-targeting-and-postwar-iraq  At a guess, the answer will be "it depends".
Comment: That depends on who wins the war ;-).
Comment: Maybe as a more generalized question one could ask how infrastructure in general can or cannot be targeted and also how accurate one must be in doing that. In the end it comes down to hope much civilian casualties or suffering is "acceptable". Of course non really, but that's war.
Comment: Broadly, this depends on why the power plants are attacked. Look back at the Dambusters raid in World War II. That did cause huge numbers of civilian casualties but which commentators don't see those as collateral damage?

In complete contrast, does anyone doubt that Putin's strikes against Ukraine's power plants are specifically designed to hurt civilians?
Comment: Is this a political question or a [Law.SE] question?
Comment: You just wait. When everything becomes electric, including tanks and guns, electric infrastructure will be completely kosher.
Comment: @Trilarion bombing bridges: bad.
bombing bridges in the Netherlands, throwing an entire country into famine towards the end of WWII? okayish.
Comment: Do those power plants run the railroads which the Ukrainian Army uses to move around the country?  If so, then the plants are technically military targets.  You *know*, though, that Russia's purpose is to cause civilian pain.
Comment: Are you asking about attacking *nuclear* power plants? Or just other power infrastructure?
Comment: In addition to the question of whether power plants constitute "military targets", I think we should also be interested in the dangers of civilian harm caused by attacks against nuclear power plants.
Comment: @RobbieGoodwin you are right about the Dambusters. The Allied had the firebombing of Dresden (and Tokyo) to hurt civilians, no need to mix up the two.
But still, if collateral damage are so irrelevant to be considered collateral damage, why not accept the use of tactical nukes, then?
Comment: @benjimin according to the Red Cross definition of military targets (formalized by the New Delhi Draft Rules https://ihl-databases.icrc.org/customary-ihl/eng/docs/v2_rul_rule8 ), atomic energy power plants are power plants like the others. I do not know if the Red Cross list has been updated recently.
Comment: There is a difference in attacking a coal fired power plant and a nuclear power plant in that there is nuclear fallout from the latter. Perhaps the nuclear proliferation treaties also cover the latter.
Answer: There's nothing that I'm aware of in international law prohibiting the targeting of power plants in general - except for the blanket protection given to civilian objects defined in Article 52 of Additional Protocol I to the Geneva Convention. This defines a military objective as objects "which by their nature, location, purpose or use make an effective contribution to military action and whose total or partial destruction, capture or neutralization, in the circumstances ruling at the time, offers a definite military advantage".
Russia's position is presumably that power plants can be defined as legitimate military objectives under this article. However, Amnesty International's Director for Eastern Europe and Central Asia has accused the country of a war crime by carrying out the attacks "with the sole purpose of terrorizing civilians". This would be contrary to the general protections of Article 51 of the same protocol, which prohibits "acts or threats of violence the primary purpose of which is to spread terror among the civilian population".
Power plants are not explicitly mentioned in Article 54 - which states:

It is prohibited to attack, destroy, remove or render useless objects indispensable to the survival of the civilian population, such as foodstuffs, agricultural areas for the production of foodstuffs, crops, livestock, drinking water installations and supplies and irrigation works, for the specific purpose of denying them for their sustenance value to the civilian population or to the adverse Party, whatever the motive, whether in order to starve out civilians, to cause them to
move away, or for any other motive.

It could be argued that energy infrastructure might fall under this definition, however.
The accusations of war crimes that I've seen most recently regarding Russia's latest attacks on power infrastructure relate to the reported mining of the Kakhovka Hydroelectric Power Plant. President Zelenskyy mentioned this in his speech on October 20th:

According to our information, the aggregates and dam of the Kakhovka HPP were mined by Russian terrorists.
Now everyone in the world must act powerfully and quickly to prevent a new Russian terrorist attack. Destroying the dam would mean a large-scale disaster.

Attacks on dams and other infrastructure which contains 'dangerous forces' such as nuclear power stations are prohibited by Article 56 of the same protocol:

Works or installations containing dangerous forces, namely dams, dykes and nuclear electrical generating stations, shall not be made the object of attack, even where these objects are military objectives, if such attack may cause the release of dangerous forces and consequent severe losses among the civilian population. Other military objectives located at or in the vicinity of these works or installations shall not be made the object of attack if such attack may cause the release of dangerous forces from the works or installations and consequent severe losses among the civilian population.

There are, however, exceptions and caveats to these protections - in all of the articles quoted above. For example, Article 56 allows military attacks on a dam "if it is used for other than its normal function and in regular, significant and direct support of military operations and if such attack is the only feasible way to terminate such support". There doesn't seem to be any blanket protection in international law for energy installations, even for nuclear power plants.
Comment: @JasonTan When you refer to the dam busters bombs in World War II: That was **before** the Geneva Conventions. WWII saw various atrocities which were the reason why the Geneva conventions were written in the first place. Like carpet-bombing civilian population centers and two nuclear bombs.
Comment: Of course if Russia were to blow the damn and then be charged with a war crime for doing so, then we probably need to restart the narrative about "The Dambusters".

I'd argue that power stations are, unfortunately military targets. Destroying them reduces the ability of the target nation to manufacture, communicate and co-ordinate (run computers and the like).

I'm pro Ukraine and think NATO SHOULD decapitate Russia and destroy Russian forces, but I'm also intellectually honest enough to say "it was OK when we did it, so it's OK for the Russians to do it" - to the extent that any war is OK
Comment: @Philipp, ultimately the purpose of the Geneva conventions (and its predecessors) was to avoid conduct that *both* sides could accept had no real benefit to themselves as perpetrators (given both the direct consequences, and the capability of the other side to retaliate in kind). Given the circumstances in Ukraine, demoralisation and if necessary dislocation of the entire Western-allied population, is the only remaining military objective for Russia.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/140150/discussion-on-answer-by-cdjb-are-power-plants-legitimate-military-targets-under).
Answer: I would argue that the wording "such as" of the Article 54:

It is prohibited to attack, destroy, remove or render useless objects indispensable to the survival of the civilian population, such as foodstuffs, agricultural areas for the production of foodstuffs, crops, livestock, drinking water installations and supplies and irrigation works, for the specific purpose of denying them for their sustenance value to the civilian population or to the adverse Party, whatever the motive, whether in order to starve out civilians, to cause them to move away, or for any other motive.

means that objects in the list are just examples and other critical objects of civil infrastructure are similarly protected as well, if they are attacked with the mentioned specific purpose.
The main argumentation behind claiming it is a war crime is that these stations do not contribute to the military success (the army on the field has they own mobile power generators) and is directly aimed to cause the mass suffering of the civilian population, as the primary goal. About 50 % of civilian power grid has been destroyed when the winter is coming.
Bringing intentionally humanitarian disasters like

There are currently no prospects for starting heating. The city is in danger of not starting the heating season at all (source)

should be a war crime by this chapter. Without heating, water supply and sewerage must also be shut down as well as it would freeze. Civil deaths are very likely to follow. At the same time, the army at the front will only get very minor and indirect impact or may even benefit from Russian missiles being depleted.
It is, of course, possible to say that any piece of civilian infrastructure indirectly supports the army by just contributing to the economy, and further extend this logic that each working civilian does this as well by ones direct work regardless of the profession so all of them are the valid military target. Everything can be linked with everything by weakly bridging over multiple steps. This cannot be the way the Article 54 has been expected to be interpreted as it would be self-contradicting and essentially void (food and water it talks about can be consumed by factory workers that produce spoons that soldiers use for eating, or much longer "logical chains" are possible to imagine).
But we need to think the actual meaning of the chapter within the context it was proposed: to prevent the artificial creation of humanitarian catastrophes, even if they are useful in winning the war.
Update: The Guardian writes that when retreating from Kherson, Russian army simply destroyed all critical infrastructure: water, heating, electricity, I assume clearly on purpose and being at place, not with rockets. While four destroyed bridges are the military targets, water and heat is likely not.
Look into this space photo of Ukraine to see the scale of the damage done:

This really does not look like something just focused on the front lines.
Update: International Criminal Court has issued arrest warrants for Russian commanders accused of planning strikes on Ukraine energy grid (The Guardian):

alleged campaign of strikes qualifies as a course of conduct involving the multiple commission of acts against a civilian population
Comment: @Steve by that logic, targeting specifically civilians to force the military to deploy resources to their protection, would be legitimate too, so I think this line of reasoning can't be sound.
Comment: @Steve that would be blatantly a war crime. Civilians are not/cannot be "military objectives" as the conventions define them, no matter what reaction the attack causes (civilians/non-civilians, civilian objects, military objectives are all defined in the treaty, I would suggest you look at it) . The words are "The civilian population ... shall not be the object of attack", it doesn't make exceptions.
Comment: *"the army on the field has they own mobile power generators"* - you could just as easily argue that the purpose of the attack on the power plant, then, is not to cause suffering to civilians, but to require the military to redeploy it's resources to the protection of the civilian population (and forfeit it's own strength in the process).
Comment: @Steve No, that's not how it works. Civilians and civilian objects *cannot* be the intended target of an attack. Sure, if a "reasonable" number of civilians die in the course of attacking enemy soldiers or a military objective (which includes industrial facilities), this is acceptable as collateral damage. But the purposeful targeting of civilians, as opposed to incidental killing, is a war crime. Your interpretation of a military objective is inconsistent with both the [text and and general interpretation of the rule](https://ihl-databases.icrc.org/customary-ihl/eng/docs/v1_rul_rule8)
Comment: @WolfgangGroiss, they aren't targeting civilians (in the case at hand), they're targeting industrial infrastructure. But I don't see any fault with the logic you express - there is no general protection for civilians during war. If the civilians do not surrender, or scatter, and if their own military do not defend them, then they risk being destroyed. Whether wanton destruction of life promotes pacification is another question, but here we are generally dealing with incidental deaths when infrastructure is blown up, and fear of the same, not systematic roundups and exterminations.
Comment: @Acccumulation Not if those supplies are unable to reach the front because all the infrastructure that would allow for that coordination has been destroyed...
Comment: @Steve what? There absolutely *are* general protections for civilians, its a pretty major point of the Geneva conventions. E.g. exact quote from [Art 51.2](https://ihl-databases.icrc.org/applic/ihl/ihl.nsf/7c4d08d9b287a42141256739003e636b/f6c8b9fee14a77fdc125641e0052b079) "The civilian population as such, as well as individual civilians, shall not be the object of attack". If you start bombing the suburbs or a sports stadium (presuming it hasn't been repurposed for military use), that is absolutely a war crime, even if they "do not surrender, or scatter".
Comment: "It is, of course, possible to say that any piece of civilian infrastructure indirectly supports the army by just contributing to the economy" And, to be realistic, the Ukrainian army isn't going to win the war with equipment from Ukrainian factories. If they win the war, it will be from other countries donating equipment, and bombing civilian targets is simply going to increase that.
Comment: @mbrig, they aren't the "object of attack", they are (to use the infamous phrase) "collateral damage" of attacks on industry. It's very unlikely that any infrastructure has not been repurposed for military use, or will not be in due course by a losing side that declines to accept defeat when their "standard" military capabilities are overwhelmed, and are therefore targets for destruction.
Comment: @Steve that's *not* the scenario that WolfgangGroiss hypothesized, that you said you "don't see any fault" with. They specifically said targeting civilians.
Comment: @mbrig, the logic WolfgangGross expressed was about targeting civilians in order to cause their military to redeploy to protect them. Since such an attack has a military purpose (to cause alteration in the configuration of enemy military) I said I don't see a problem with his logic.
Comment: @mbrig, the civilians aren't the military objective, in WolfgangGross's logic. The military objective is to bog down the enemy's military resources in self-defence. It seems to me that a lot of commentators on this subject are determined to interpret the Geneva convention as if it said "civilians cannot be targeted for attack for any purpose, nor caused death or injury in the course of any attack", and that isn't what it says.
Comment: @mbrig, I see nothing in your link that says large numbers of civilians cannot be killed, if doing so had a military advantage (and the purpose of whatever caused the deaths, was to acquire that military advantage). WolfgangGross proposed a situation in which attacking civilians would cause the enemy military to somehow vacate their current positions and redeploy or desist to protect their civilian population. Aside from whether the assumptions of such a situation are realistic - perhaps the example of nuking Japan in WW2 is an example - then I don't see that such an attack is prohibited.
Comment: But what about the army not in the field? The Ukrainian power grid presumably supplies power to the Ministry of Defence and the various military headquarters, so disrupting that grid disrupts the very significant military activities at those locations.
Answer: The 1977 amendment to the Geneva Convention writes:

Art 48. Basic rule
In order to ensure respect for and protection of the civilian population and civilian objects, the Parties to the conflict shall at all times distinguish between the civilian population and combatants and between civilian objects and military objectives and accordingly shall direct their operations only against military objectives.

Art 51. - Protection of the civilian population
[...]

Indiscriminate attacks are prohibited. Indiscriminate attacks are:
(a) those which are not directed at a specific military objective;
(b) those which employ a method or means of combat which cannot be directed at a specific military objective; or
(c) those which employ a method or means of combat the effects of which cannot be limited as required by this Protocol;
and consequently, in each such case, are of a nature to strike military objectives and civilians or civilian objects without distinction.

Among others, the following types of attacks are to be considered as indiscriminate:
(a) ...
and
(b) an attack which may be expected to cause incidental loss of civilian life, injury to civilians, damage to civilian objects, or a combination thereof, which would be excessive in relation to the concrete and direct military advantage anticipated.

A similar definition is given by the Rome Statute (the treaty establishing the International Criminal Court), in article 8.2.b.iv:

Intentionally launching an attack in the knowledge that such attack will cause incidental loss of life or injury to civilians or damage to civilian objects or widespread, long-term and severe damage to the natural environment which would be clearly excessive in relation to the concrete and direct overall military advantage anticipated;

The "concrete and direct military advantage" obtained by destroying the power grid is likely quite minor compared to the impact on the civilian population. After all, military units that need power likely have their own means of generating it, while civilians don't usually have a diesel generator on standby.
That is, creating a power outage in a wide area (particularly if that area contains few military assets currently in need of power) would be judged excessive. On the other hand, destroying the power lines supplying a military installation, and their dedicated backup power supply, would be fine.
So, what has happened in Ukraine? Bloomberg summarizes:

Ukraine's critical energy infrastructure was extensively damaged on Saturday as Russian troops delivered another large-scale wave of missile strikes, leaving 1.5 million or more people temporarily without power.

NPR goes into greater detail:

The mayor of the western city of Lutsk, Ihor Polishchuk, says the damage inflicted by three Russian rockets "is not compatible with repair." He asked for patience as engineers rebuild electrical infrastructure and restore water pressure.
Police also said most air raid sirens don't have the electricity to warn of other potential airstrikes. They encouraged citizens to keep the mobile phones charged to receive emergency alerts, and said they would turn on their vehicle sirens in case of an incoming attack.
"When you don't have electricity in a city, it means you have no water, you have no supply of gas, you have nothing," Oleksandr Kharchenko, a leading Ukrainian energy expert, told NPR. "It's really huge trouble."
Seven out of Ukraine's 25 regions experienced similar damage, mostly in the country's west, south and center.

I wonder which "concrete and direct" military advantage Russia is pursuing in Lutsk, approximately 700 km from the front?
If this isn't excessive, I don't know what is. In fact, this is so beyond the pale that it may even meet this definition:

Art 51. - Protection of the civilian population

...

The civilian population as such, as well as individual civilians, shall not be the object of attack. Acts or threats of violence the primary purpose of which is to spread terror among the civilian population are prohibited.

(emphasis mine)
even if it doesn't, it is likely to meet this one:

Art 54. Protection of objects indispensable to the survival of the civilian population

Starvation of civilians as a method of warfare is prohibited.

It is prohibited to attack, destroy, remove or render useless objects indispensable to the survival of the civilian population, such as food-stuffs, agricultural areas for the production of food-stuffs, crops, livestock, drinking water installations and supplies and irrigation works, for the specific purpose of denying them for their sustenance value to the civilian population or to the adverse Party, whatever the motive, whether in order to starve out civilians, to cause them to move away, or for any other motive.

(emphasis mine)
Generally speaking, attacks on power plants may also run afoul of

Art 56. Protection of works and installations containing dangerous forces

Works or installations containing dangerous forces, namely dams, dykes and nuclear electrical generating stations, shall not be made the object of attack, even where these objects are military objectives, if such attack may cause the release of dangerous forces and consequent severe losses among the civilian population. Other military objectives located at or in the vicinity of these works or installations shall not be made the object of attack if such attack may cause the release of dangerous forces from the works or installations and consequent severe losses among the civilian population.

While the current attacks have (to my knowledge) not targeted such installations, nuclear power plants have come under fire in this conflict, and the International Atomic Energy Agency remains deeply concerned about the situation in the Zaporizhzhya nuclear power plant.
Conclusion
The Geneva Convention requires distinction, proportionality and precaution when attacking the enemy. It forbids terrorizing the civilian population, and forbids depriving it of vital resources. It also forbids attacking installations containing dangerous forces.
Update: ICC issues arrest warrants
In March 2024, the International Criminal Court has issued arrest warrants against the Russian Generals (Air Force and Navy) in charge of these attacks, who

are each allegedly responsible for the war crime of directing attacks at civilian objects (article 8(2)(b)(ii) of the Rome Statute) and the war crime of causing excessive incidental harm to civilians or damage to civilian objects (article 8(2)(b)(iv) of the Rome Statute), and the crime against humanity of inhumane acts under article 7(1)(k) of the Rome Statute.

Pre-Trial Chamber II considered that there are reasonable grounds to believe that the two suspects bear responsibility for missile strikes carried out by the forces under their command against the Ukrainian electric infrastructure from at least 10 October 2022 until at least 9 March 2023. During this time-frame, there was an alleged campaign of strikes against numerous electric power plants and sub-stations, which were carried out by the Russian armed forces in multiple locations in Ukraine.
Pre-Trial Chamber II found that there are reasonable grounds to believe that the alleged strikes were directed against civilian objects, and for those installations that may have qualified as military objectives at the relevant time, the expected incidental civilian harm and damage would have been clearly excessive to the anticipated military advantage.
Pre-Trial Chamber II also considered that the alleged campaign of strikes qualifies as a course of conduct involving the multiple commission of acts against a civilian population, pursuant to a State policy, in the meaning of Article 7 of the Statute. As such, there are reasonable grounds to believe that the suspects also bear responsibility for the crime against humanity of 'other inhumane acts […] intentionally causing great suffering, or serious injury to body or to mental or physical health', as per article 7(1)(k) of the Rome Statute.
Comment: "I  wonder which "concrete and direct" military advantage Russia is pursuing in Lutsk, approximately 700 km from the front?" Hampering enemy logistics, especially with regards to the import of weapons from countries hostile to Russia..
Comment: @Steve: The Geneva Convention is way ahead of you there. That's why it writes: "whatever the motive, whether in order to starve out civilians, to cause them to move away, or for any other motive." A conqueror offering to accept "refugees" is causing them to "move away", is it not?
Comment: It may seem "bizarre" to you that nuking a city full of civilians may be a war crime, but that doesn't change the fact that it is a crime. And you may love Russia for offering alms to those it has forced to leave their home, but that doesn't change the fact that forcing people to relocate is a crime. As for your specious arguments: Hiroshima and Nagasaki predate the relevant part of the Geneva convention by over 30 years. And the Marshall Islands were not at war with the US, so rules for the wartime treatment of civilians don't apply.
Comment: It is important to point out proportionality. If *some* attacks on *some* power plants are legitimate, that does not make *any* attack on *any* power plant legitimate.
Comment: @Steve According to that logic, it would not be a war crime for the US to nuke Moscow, as long as they first set up refugee camps and allowed Muscovites access to them. There's also the little issue of civilians who end up under the control of Russia having a tendency to end up dead.
Comment: @meriton How do you communicate where the weapons are supposed to go and when they're supposed to get there without computers and communications equipment, which are powered by electricity? How are the trains carrying them supposed to go anywhere when their tracks have no power?
Comment: *"It forbids terrorizing the civilian population"* - actually it prohibits only attacks whose *primary* purpose is to "terrorise" (an undefined term). This is a very interesting answer but I also find it incredible that attacks on industry - such as power plants in general - are prohibited. I wonder whether Russia would answer starvation concerns by asserting that it will itself accept all civilian refugees who seek help, so there is never a risk of starvation except by those who choose not to avail themselves of the facility. (1/2)
Comment: That is, there is no right for the civilian population to have means of survival *independent* of the conquering side - only that the conqueror must preserve some means of survival for civilians. (2/2)
Comment: @meriton, that clearly depends on the definition of "move away". It may be away from the existing locality of settlement, but it is motion towards the conqueror's forces (rather than into the wilderness or into the laps of neighbouring states). Typically in siege warfare, the point is to force the civilian population to stay co-located with the corresponding military forces, and starve them all until surrender (with the civilians acting as weight upon any stored supplies). Here, the purpose is actually to filter the civilians out, and offer alms to those who come.
Comment: @Acccumulation, if Russia kills unarmed civilians or surrendered soldiers, then that is criminal. I can't see why it would promote their interests to do so though. As for nuking whilst offering refuge, didn't the US do that with the Marshall Islands when nuclear testing? And of course, they did it in Hiroshima and Nagasaki without offering refuge first. If the US and Russia were in direct warfare, it would seem bizarre to suggest that each attacking the other's capital city was a crime.
Comment: @Nick: That sounds like a rather vague and indirect advantage to me. In particular, it seems unclear how *disrupting the power grid* will prevent *weapon imports*. (I am not an expert in military logistics, but I would expect most of these to be transported by road, because that makes it harder for the russians to predict the route?)
Comment: Through StarLink terminals, for which Musk [graciously provided](https://www.space.com/elon-musk-spacex-more-starlink-terminals-ukraine) "power adapters for car cigarette lighters, solar/battery packs and generators for places where electricity is not available"?
Answer: The question about what constitutes a legitimate target is a difficult, technical, and ultimately unimportant one. But there are some interesting tidbits to look at anyways.
Geneva Conventions Protocol I, Article 52 defines civilian and military objects, and that in doubt you should assume an object is civilian, which you definitely can't attack. Commentary #2023 and #2024 on Article 52 highlights that dual purpose (military and civilian) objects can be attacked if you minimise civilian casualties, and that such an attack must be made to gain a definite (as opposed to potential or indeterminate) military advantage.
Article 54 forbids attacks that threaten the survival of the civilian population, but exempt in paragraph 3 some objects used "in direct support of military action" on some conditions. Article 54 only mention food and water as a necessity, not power and shelter, so it's unclear whether that  article applies at all here.
Article 56 provides protection to dams, dykes, and nuclear plants, unless "in regular, significant and direct support of military operations and if such attack is the only feasible way to terminate such support". If you're thinking the ability to cut power lines would disqualify any attack, commentary #2166 agrees. Commentary #2165 also add
"it would not be reasonable to claim that merely supplying electricity constitutes direct support of military operations", and commentary #2163 does say such an attack would be forbidden if it would "cause severe losses among the civilian population because of the release of dangerous forces"
If that comment applies to all power plant beyond dams or nuclear plants, and I can't see a reason it wouldn't, then in the light of Article 52 you'd have a strong case that a power plant wouldn't be a legitimate military objective when it also provides power to civilians.

But whether it's a legitimate target or not wouldn't matter too much because while the Rome Statute, Article 8 lists targeting of civilian objects as a war crime

b. ii. Intentionally directing attacks against civilian objects, that is, objects which are not military objectives;

It also lists this as a war crime:

b. iv. Intentionally launching an attack in the knowledge that such attack will cause incidental loss of life or injury to civilians or damage to civilian objects or widespread, long-term and severe damage to the natural environment which would be clearly excessive in relation to the concrete and direct overall military advantage anticipated;

And importantly here is that this is independent of whether the target is otherwise legitimate or not.
Losing power in or near winter can certainly cause loss of life and injuries. A plant that powers a small village and a big military base might pass muster, but I don't think it would take much for it to be considered "clearly excessive" in relation to any military objective, especially considering how tanks don't particularly run on electrons, nor jets, nor soldiers themselves.
I will also certainly argue that attacking a nuclear plant such as Zaporizhzhia is bound to cause "widespread, long-term and severe damage to the natural environment", that it's an undisputable truth, and that you can't argue that you don't know that in a country where Chernobyl happened. And I'll say that a nuclear disaster is clearly excessive in relation to anything.
So with all these elements so far, you can certainly make a case that targeting power plants that supply large civilian populations is a war crime.

That was the theory, but what about the practice?
Remember that war crimes are crimes. They require intent. You have to accuse specific people of specific crimes, and demonstrate that they acted wilfully and unlawfully. You can't really subpoena Russia for confidential military communications to prove your case about the intent, nor can you count on Russian officers showing up to court voluntarily to stand trial.
So is this going to lead to anything? Doubftul.
The accusation has more value as a matter of politics right now. Throwing accusations is free, and painting the other side as a bunch of heartless war criminals certainly help shore up popular support for your side. The will to fight and the conviction that you're on the right side are powerful things in a war, and that's more practically useful to Ukraine right now.
As for the military usefulness of such tactic, it's rather dubious. It's a valid target in the sense that it's a thing you can throw bombs at and it'll cause some chaos for the enemy. But IIRC, during WWII, of all the totally legitimate bombing campaigns done by the Allies, bombing roads and railroads proved more effective than bombing factories and such.
And although I suppose today we're more reliant on electrons than in 1945, we still have a lot of military equipment, and particularly some of the older equipment used by Ukraine, that can be operated and serviced without being plugged into the grid. And it makes sense, in case of a war, you can't rely on a steady supply of electricity.


AppPrincipals in SharePoint Online with Powershell

Question: An app that installs without issues manually via UI needs to be installed automatically.
It's a provider-hosted app with Azure website.
The solution here: Office 365: Publish and deploy .app through PowerShell gives me ALMOST what I need - the app is installed on the site, but throws an error about permissions to the remote site:

The remote event receiver callout failed. Details: Access denied. You
  do not have permission to perform this action or access this resource.

The difference between successful manual sites and unsuccessful Powershell-deployed ones, seems to be within App Principals:

On the failed sites, the app principal for MyApp is missing.
How can I add it in SharePoint Online site using Powershell ?
Answer: There is a similar question with a (disappointing) answer here.
So, in short, it is not possible at the moment.


Are states of matter distinguishable clearly?

Question: Can we say a state of a matter is exactly only one of solid, liquid or gas? Can't we say something is more "liquid-like" or less "solid-like?" What is a state of slime?
Comment: My answer would be "yes". "State of matter" does not refer to only liquid, gas and solid. OTOH this question could be interpreted in other ways, for instance it is unclear whether it is meant "are states of matter *always* distinguishable". This is somewhat different from the Q which was deemed a duplicate, because the focus could be placed on the word **clearly**. It is highly unclear whether this is meant as a universal question (about theoretical definitions) or particular cases (experimental determination of the state of matter).
Answer: Every man-made classification is problematic because there are no sharp boundaries among various classes. For elementary-level discussion solid-liquid-gas classifaction is fine, but things are more complex in real life.
Slime is a famous non-Newtonian fluid, which is just a fancy way of saying that this "stuff" can flow; hence it is a fluid, but its viscosity changes with flow rate, hence the fancy term "non-Newtonian." For example, if you have ever made a soup thickener with corn starch, the spoon gets jammed in the cup if you quickly move the spoon. You feel much resistance, but if you slow down, it is liquid dispersion again. Notice we have carefully avoided liquid, or solid here, because slime is colloid (a dispersion of a solid in liquid) if you are talking about corn-starch dispersed in water.
One may ask what is the state of smoke? It is neither solid, liquid or gas. It is a colloidal dispersion of solid particulates in gas.
Answer: Definitely not. Not only do liquids and gases merge above the critical temperature and pressure, we also cannot distinguish solids from either liquids or gases by simply stating that solids do not flow. Because, under the right conditions, ultimately they do. As with many things in science, the apparent distinctions we usually see are in fact idealizations.


Reincarnation manhwa in which the female lead goes back in time for revenge on her uncle

Question: It's a historical fiction with magic. The female lead was a mercenary in her past life. In it, her mom dies of an illness and she thinks her grandfather didn't care so she kills him. But she finds out that her great uncle set her up and then her uncle kills her. She is sent back to when she was a child and her mom was still alive. She leaves and gets her grandfather to help her and she wants revenge on her uncle. She meets a small white dragon/snake at one point.
Comment: Do you recall the hair colour of the female lead?
Comment: I think her hair color was light brown. Could have been red. The theorized male lead has white hair.
Answer: This is The Grand Duke's Beloved Granddaughter.

Mirabel is a famed mercenary whose mother, Cornelia, had long suffered from the guilt of leaving her family, the Grand Dukedom of Citron behind. After Cornelia's failed attempts to contact her family left her distressed and led to her death, Mirable seeked revenge, tracking down her grandfather, the Grand Duke Criton and the assumed cause of all her mother's misery. After finding out that he too was betrayed, Mirabel meets an untimely death at the hands of the true culprit, only to wake up back when she was nine years old, with her mother still alive. Determined to stop her mother's death, and seek revenge against the true villain, Maribel sets out to make things right. But her choice to meeti her grandfather makes her cross traces of her past, while she experiences a life she never knew before.

The protagonist, Mirabel, is a mercenary whose mother, Cornelia, left her family for love. After Mirabel was born, her father, Gyle, died protecting the village she grew up in, leaving Cornelia to raise her alone. Cornelia wrote letters to her father, Grand Duke Criton, seeking forgiveness, but received no response and ultimately died of illness.
Some time later, the Duke summons Mirabel to his estate and asks her to find Cornelia for him. (He doesn't know about Cornelia's death or that Mirabel is his granddaughter.) Angered by his request, Mirabel asks him why he ignored the letters Cornelia sent him and tells him that she died in resentment of her father who never responded.
Then the Duke's brother and Mirabel's great uncle, Lord Daniel Criton, enters the room and reveals that he intercepted the letters sent by Cornelia to ensure that the Duke didn't forgive her and welcome her back into the fold.

Daniel is revealing this now because he intends to kill both the Duke and Mirabel tonight and has brought a bunch of armed men with him to assassinate them. The Duke tells Mirabel to run away, but she stays and fights and dies with him.
She then wakes up as her much younger self, when her mother was still alive, and vows to cure her mother's illness and enact justice on Daniel.
In chapter 3, she visits the Duke to arrange a reunion between him and her mother.
In chapter 12, she visits the temple of the goddess, Duana, hoping to learn whether she has enough divine power to save her mother. There, a saint named Pleon gives her a pendant with a white snake on it, which turns out to be alive, and is the goddess' guardian dragon, Vivre.
You can read the full manhwa at Pocket Comics.
Comment: @Marcy - If this answer is correct, please consider marking it as [accepted](https://scifi.stackexchange.com/help/accepted-answer) by clicking on the grey check mark near the top-left corner of the answer. It's this site's way of formally indicating that a query has been solved to the querent's satisfaction.


c style casts or c++ style casts

Question: So, what do you use?
int anInt = (int)aFloat;

or
int anInt = static_cast<int>(aFloat);
// and its brethren

And, more importantly, why?
Answer: First, understand that those lines are not equivalent.
int* anInt = (int*)aFloat; // is equivalent to

int* anInt = reinterpret_cast<int*>(aFloat);

What is happening here is that the programmer is asking the compiler to do whatever it can to make the cast.
The difference is important because using static_cast will only ask for a base type that is "safe" to convert to, where reinterpret_cast will convert to anything, possibly by just mapping the wanted memory layout over the memory of the given object.
So, as the "filter" is not the same, using a specific cast is more clear and safe than using the C cast.  If you rely on the compiler (or runtime implementation if you use dynamic_cast) to tell you where you did something wrong, by avoid using C cast and reinterepret_cast.
Now that this is more clear, there is another thing: static_cast, reinterpret_cast, const_cast and dynamic_cast are easier to search for.
And the ultimate point: they are ugly. That's wanted. Potentially buggy code, code smells, obvious "tricks" that might generate bugs, are easier to track when it's associated with ugly look. Bad code should be ugly.
That's "by design". And that allows the developer to know where he could have done things better (by totally avoiding casts, if not really needed) and where it's fine but it's "documented" in the code by "marking" it as ugly.

A secondary reason for introducing the
new-style cast was that C-style casts
are very hard to spot in a program.
For example, you can't conveniently
search for casts using an ordinary
editor or word processor. This
near-invisibility of C-style casts is
especially unfortunate because they
are so potentially damaging. An ugly
operation should have an ugly
syntactic form. That observation was
part of the reason for choosing the
syntax for the new-style casts. A
further reason was for the new-style
casts to match the template notation,
so that programmers can write their
own casts, especially run-time checked
casts.
Maybe, because static_cast is so ugly
and so relatively hard to type, you're
more likely to think twice before
using one? That would be good, because
casts really are mostly avoidable in
modern C++.

Source: Bjarne Stroustrup (C++ creator)
Comment: I would downvote this if I had a few more points, but unfortunately I cannot. c-style casts are NOT equivalent to reinterpret_cast. Consider `reinterpret_cast(double);`. It is entirely possible to cast a double to an int with a c-style cast, but it is not possible to do it with reinterpret_cast. I see Timbo already pointed this out to you, and you said you would fix it, but four years later it remains incorrect. I would still downvote you if that were fixed though, as there are perfectly valid reasons to need to use a cast. Here's a better answer: http://stackoverflow.com/a/332086/3878168
Comment: `casts really are mostly avoidable in modern C++` While strictly true, it's often not achievable in practice, where you have to mix C and C++ (for example, even in 2021, lots of libraries for microcontroller and embeddded are written in C, like Arduino, FreeRTOS, ESP-IDF and many peripheral drivers for e.g. displays)
Comment: Additinally, in cases like https://stackoverflow.com/a/35936719/1052284 ugly-casting is the 'cleanest' solution even in pure C++.
Answer: C++ casts are more restrictive (so express your intent better and make code review easier, etc.). They're also much easier to search for, if you ever need to.
Comment: ... and they are more likely to do what you intend. ;-)
Comment: And they are ugly as a feature, making obvious where in the code there might be points of improvement or special cases that might require documentation. - edit: wow I just discovered I answered this question too! XD
Comment: And they are a lot more to type, giving you one more reason to just get your types correct without casts needed.
Comment: Now why would I want to search for them?
Comment: @Deduplicator There are a lot of reasons you might want to know where casts are happening in a code-base. For example when hunting bugs which could be associated with casting (in particular when doing cross-platform development).
Comment: @Klaim: In that case, I will have to judge all the code, not only the casts.
Comment: @Deduplicator Depends on your situation, but checking millions of lines of code can be problematic. Also, you might be hunting a specific kind of bug, which would require a specific search. With parenthesis, this search is just not possible.
Answer: Option C: a "C++-style" cast, because it is indistinguishable from a construction:
int anInt = int(aFloat);

or even:
int anInt(aFloat);

That aside, other than these trivial cases with primitives, which are well understood, I prefer to use x_cast<>s over C-style casts.  There are three reasons why:

They more narrowly define the operation the programmer was trying to perform.
They can perform actions that C-style casts cannot (especially in the case of dynamic_cast<>, which can cross-cast across branches of a multiple-inheritance chain).
They are ugly.  They loudly declare that the programmer is working against the type system.  In this case, it's a good thing.
Comment: It's really sad to see that the first correct and reasoned answer comes third, and has less than a third the votes of the accepted and wrong answer.
Comment: I appreciate the vote of confidence. ;)
Answer: I have a few rules about C/C++-style casts:

Dis-applying a const must always use a const_cast. For obvious reasons. Sadly, my rule about dis-applying a const causing the keyboard to reach up and break the programmer's finger was not approved.
Any of the bit-manipulation-style shenanigans that programmers get up to when getting down to the metal should use reinterpret_cast. It's really the kind of cast that C doesn't have: pretend this integer's bits are actually a float's bits. This avoids unpleasantness like (int)(*(int*)(&floatVar)).
If you type the words "dynamic_cast", stop and re-evaluate your polymorphic class hierarchy and design. Continue re-evaluating your class hierarchy's design until you can delete those words.
Don't bother with static_cast.

The reasoning behind #4 is simply that it doesn't matter. The circumstances that don't fit into the other rules are either obvious or really low-level. A well-understood conversion of simple types like int-to-float should not need special syntax. And if you're down in the deep, ugly guts of something, well, you're down in the deep, ugly guts of something. There's no need to draw attention to the fact that "here there be dragons," since the teeth, claws, and fire pretty much gave it away already.
Comment: `dynamic_cast` is a perfectly valid tool. Rarely useful, I'll admit, but it's far from the Satan of things like global variables. However, primarily, I downvoted you because you didn't answer the *question*, which was about the use or not of C-style casts.
Comment: @DeadMG: I did talk about C-style casts. The whole last paragraph justifies C-style casts in favor of static_cast.
Comment: "Sadly, my rule about dis-applying a const causing the keyboard to reach up and break the programmer's finger was not approved." Technically it's actually legal for the compiler to make that happen. As is it legal for the compiler to [make demons fly out of your nose](http://catb.org/jargon/html/N/nasal-demons.html).
Comment: @Pharap If it was constant to begin with, instead of only that view. And then only on execution of the code.
Answer: If writing code in C use a C cast.
If writing in C++ use a C++ cast.
Whilst most casting breaks proper type-safety, the C++ ones are more restrictive, and therefore you are slightly less type-unsafe than you would be with a C cast.
I can tolerate someone using (T*)NULL though to force an overload...
Answer: As the above posts note the C++ (static) cast is a bit safer in practice.
It might be smart to look up some more information about the different kinds of casting and their pro's and cons.
Just to have more of a background on why. .
http://en.wikipedia.org/wiki/Static_cast
http://en.wikipedia.org/wiki/Dynamic_cast
http://en.wikipedia.org/wiki/Reinterpret_cast
Answer: It really depends on which language I'm working with, since you know what they say: In Rome speak Roman.
So if I'm programming in C, I try to use the C features to the max, but if I'm programming at C++ I go ahead and use C++ features to the max, even if some people don't like that approach because they say it makes the code "less portable", I say that I don't care, I'm in C++ and programming in C++, and I need a fully C++ compatible compiler to compile code, otherwise I would be working with something different in the first place.
Comment: It doesn't really work trying to use C++-style casts in C ;-)
Answer: static_cast etc were invented because of problems with the C style casts when used in templates. If you're writing a template, or if you're code may later be converted to a template, it's a good idea to use C++-style casts. The reason is because the C++-style casts better express intent, so they will give the expected results in cases where C-style casts will do the wrong thing (given particular types as template parameters).
Other than that, I say use C++-style casts if you have a specific issue that needs them - dynamic_cast is the most common, but even that's probably not an every day thing.
Anything else, and a C style cast may be a bit less clutter and help readability, or maybe not depending on how familiar the reader is with that cast style these days. It's not really important in my view, mostly a personal preference thing, though don't be surprised if some people don't like the C style.
Final note - if you need so many casts that this is a big deal, you're probably doing something else wrong. There are exceptions to that in some cases, but most high level code shouldn't need many (if any) casts.
Answer: This is an old question, but nobody had said this yet:
C-style casts are only unsafe only when casting to pointers or references, especially when classes are involved.
In all other cases, C-style casts are fine, and (I believe) improve readability compared to static_cast.
(In this answer I use "C-style cast" as an umbrella term for both (T)x, T(x), and T{x}, even though they have slightly different behavior.).

When classes are involved, a C-style cast to a pointer or reference can do one of the three things: (which are tried in this order)

Cast between a base class to a derived class (or back), which potentially changes the numerical value of the pointer when multiple inheritance is involved. (Like a static_cast.)

Invoke a user-defined conversion operator. (Like a static_cast.)

Perform a reinterpret_cast.

You really don't want 1 or 2 to accidentally turn into 3 (or vice versa), either because the class interface changed and you forgot to update the usage, or just because you made a mistake.
Even if we ignore 1 and 2, reinterpret_cast is inherently unsafe, so it's useful to make it more visible (by spelling it as a C++ cast).
Additionally, a C-style cast can implicitly add the treacherous const_cast to the conversions listed above, which is yet another reason to avoid it for pointers and references.

When casting to something that's not a pointer or a reference, a C-style cast behaves exactly like static_cast.
I see no reason to spell a / float(b) as a / static_cast<float>(b), since it doesn't add any extra safety.
The only argument in favor of using static_cast in this case is that it's easier to find in the code, but I never had a need to do that, not a single time.
But if you do need to find all casts for some reason, we now have tools like libclang, which let you do this relatively easily, regardless of the syntax you used.
Comment: `float(b)` is not the same as `(float)b`. `float{b}` is even more distinct
Comment: @Caleth `float{...}` is distinct, yes. But I'm not aware of any significant differences between `float(...)` and `(float)...`. The only one I remember is that CTAD doesn't work with the latter.
Comment: @HolyBlackCat That difference seems pretty accidental.

c style casts or c++ style casts


Is any way to create different root categories for different store

Question: I have two store one is English and  another is France.I have multiple category in English store.But I want to create these all category in France Language for France store.
Manually this is possible for me to change store and change the category name English to  France. This is working perfect. Can I create different root category for a different store.
Answer: If I understand it right you want a new root category, then please follow this:
To create a new root category
Step 1: Build a New Root Category
On the Admin Panel, Product > Inventory > Categories.
Click on Add Root Category button. Then choose Yes in the Is Active field to activate the root. Make the new root category visible if choosing Yes in the Include in Navigation Menu field.
After finishing General Information, move to Display Settings tab and choose Yes for the Is Anchor.
Click Save Category to use the new root category.
Step 2: Create Subcategories for the New Root Category
Look at the left of the setting page, choose the new root category you created appears there to start this step.
Click on Add Subcategory.
Name for the subcategory in the Name field.
Choose Yes in the Is Active field.
Click Save Category to complete.
Do all again if you need to create other new subcategory.
Step 3: Activate the New Root Category on Your Store
On the Admin Panel, Stores > Settings > All Stores.
Under Stores, hit the Main Website Store link.
In the Root Category, choose the new root category.
Click on Save Store on the top right corner to apply the category.
For each store view you can set the root category differently.
Comment: Well when you have two store for main website then how can you chose  different root category for  different store, when i select different root category  for french then  English is also override the same category
Comment: You want the 2 stores to have different categories/catalogs? Then you need a 2nd website
Comment: but when i create second website then , my store swticher is disable
Comment: If you have 2 stores under 1 website then the root category will be the same. You can find more here https://www.sherodesigns.com/magento-tutorial-creating-multiple-store-views-in-magento/


How is CIDR used in ranges?

Question: There are times where CIDR notation isn't used to subnetting or for routing/summarization but rather just for ranging IP addresses, IPv4 mostly. It seems very non-standard and it seems to be like a makeshift solution around Docker because the only examples that I can remember right now are related to Docker: Portainer and vSphere Integrated Containers. Whatever might be, it's always been a little confusing of where does it starts and ends and if normal subnet edges are respected. However, the ambiguous instructions given, for what it's worth, usually almost verbatim one another. It's consistently ambiguous.
For example, I want to tell X app/system that I want to use 30 addresses starting from 10.2.44.21 to 10.2.44.50. In subnetting, that'd fit nicely in a /27, only the range edges (start/end) wouldn't work. However, it's usually pointed out that when used in this way the address given is not the network ID but the initial address in a given /{CIDR}.
So, that could potentially be 10.2.44.21/27 (+2). Yet, back again in subnetting rules there'd be another problem with that; when a range is overshoot, the extra is usually just ignored.
In subnetting, 10.2.44.21/27 subnet would be:
NetworkID 10.2.44.0
AddrRange 10.2.44.1-10.2.44.30
BcastAddr 10.2.44.31

So, would the range be broken off at address .31 (where the subnetting range ends) or would it go all the way to .50? And, is the range  is fully usable? i.e; not .50 but .52.

I just remembered another use for it: in pfSense/OPNsense, it can be used for firewall rules but I do believe subnet ranges are respected since these are downloaded in DNSBL/Pi-hole/pfBlockerNG-type lists, which are ranged in the subnets as they were assigned — I think ranges would be broken off on edges. In the captive portal rules are different thought.
Answer: You cannot represent arbitrary ranges in a single CIDR notation.
You seem to be asking for a standard way to modify CIDR notation so that becomes possible, but that doesn't exist. The simple answer is use a range to represent a range.
Also, whether the addresses with all-zero or all-one host parts are usable or not depends on the use case. As an actual subnet address with IPv4 they're not, but with IPv6 or if you e.g. use them just for routing or for ACL rules, then they are. (ACLs generally support non-contiguous wildcard patterns as well.)

How is CIDR used in ranges?


Magento 1.9.1 not saving the Card Verification Number in the "Credit Card (saved)" payment option

Question: We need to save the 3 digit code from the back of the card. I enabled the credit card (saved) payment option but Magento 1.9.1 (although it shows it during the order process) is not saving the Card Verification Number after customer fills that in during the order process. It does not show on the order in the Admin...Any ideas?
Answer: That's a really, really, really bad idea. PCI compliance regulations absolutely prohibit the CCV from being stored in any form. More info
Really, you shouldn't be storing credit card information locally in any form. Saved cards are nice, but do it with a tokenization solution like Paypal Credit Card Tokenization or Authorize.Net CIM. If you use some other payment processor already, there might be an extension for them too. This gives you the benefits of stored cards, without the major risk and liability of trying to do it locally.
If you have some business process that requires the card details, you should seriously consider changing that process.
Full disclosure: I wrote the CIM extension. These kinds of security concerns are what I deal with.
Comment: Thank you Ryan for your ideas - it is very much appreciated! :-) The problem is that we are processing transactions using Paypal but had to remove the Paypal setup from our Magento shopping cart because we have a few items that we sell that contain alcohol and apparently - this does not fly well with Paypal...So - I disabled the Paypal automatic processing, we do the saved credit card payment option now and process through Paypal manually...Would the Paypal Credit Card Tokenization help with that? Thanks again for any ideas! :-*
Comment: You get a credit card processor that will accept payments for the products you sell. You should never store credit card information on your web server, makes for future bad customer relations when your web server gets hacked. Having all their payment credentials stolen does not fly well with customers. Tokenization is a good step forward, a lot of credit card processors are starting to support this method of handling credit card data.
Comment: @Allysin, Fiasco Labs is correct. If PayPal isn't working out for you, then find another processor that will. Shop around, there are many options. You can start by narrowing it down to ones that will actually work with you, then look at transaction fees, available Magento integrations, etc. FWIW, Authorize.Net does not appear to have any policy against alcohol, and reseller Capital Merchant Services specifically advertises as working with high-risk accounts. I've never worked with them before though.
Comment: I found an extension that deletes the CODE after it is used. Please - we need this as a temporary kind of a thing - does anyone have any ideas on why the CVV code shows up during the checkout process, you fill it in but the CVV code does NOT show up on the order in Admin? Thanks for any suggestions! :-*
Comment: I think this is a bug - I have 2 seperate Magento instalations - Magento ver. 22.214.171.124 and ver. 22.214.171.124 I did test orders on both and it DOES NOT save the CVV code in either!


No Sound in Windows 10 via Bootcamp

Question: I recently installed Windows 10 using Bootcamp. When I try to turn up the audio nothing happens. I went into device manager and the High Definition Audio Controller has a triangle with an exclamation mark over it. I tried to update the drivers but it said they were already up to date.
Answer: Sounds like you're missing the Boot Camp software needed for your Mac or it didn't install the audio driver properly.
Try downloading and running Tim Sutton's excellent Brigadier while in Windows.
It should download the latest compatible boot camp software for your model Mac.
Once downloaded run the Boot Camp setup file from /Users/(your username)/BootCamp-****/ and reboot when asked.
Should be fixed.
Brigadier is here https://github.com/timsutton/brigadier

No Sound in Windows 10 via Bootcamp


Two different ultrasonic range finders to minimize interference

Question: Basically, I am building a robot that needs to be able to detect the distance from multiple sides. My plan is to use multiple ultrasonic range finders on each side, but I'm worried about interference between the sensors. Do there exist sensors that output and receive different frequencies to ensure that they don't interfere with each other?
Comment: @DKNguyen yeah, that's exactly what it's for. What would a better solution be?
Comment: @Zanolon Physical contact which could be switches, mechanical whiskers, or fiber optic whiskers. Or, infrared proximity detection. The thing is, you usually do not need to know the exact range of something for obstacle avoidance. Knowing something has gotten to close too you is usually enough. Note I am making a distinction here between obstacle AVOIDANCE/DETECTION and NAVIGATION (mapping out obstacles at a distance to decide the path you are going to take. You would use an ultrasonic sensor for this due to longer range and rangefinding requirements, but you would only need one.).
Comment: Is this short-range, like a wall-follower? What's the maximum range you *need* to detect distance?
Comment: Why do you need to detect distance from multiple sides? And at what distance? Normally for navigation you would use a panning head for this, but the way you worded it implies you need it to be done rapidly or near simultaneously. Without a more specific reason, this raises a red flag since the most common thing that requires this is close-range obstacle avoidance for which ultrasonic is not the best solution.
Answer: The usual approach is to trigger only one sensor at a time. In other words, time-division multiplexing, rather than frequency-division multiplexing.
Otherwise, even if the sensors aren't pointing in the same general direction, coupling through the structure of the robot itself can create unnecessary interference.

Just to put some numbers with that: Ultrasound requires about 6 ms per meter of sensed distance. If you're interested in distances up to 2 meters from your robot, then each sensor needs 12 ms. If you have 8 sensors, that's a total of about 100 ms, which means that each one can take 10 measurements a second. This should be plenty for a robot that can move at up to several meters/second, depending on how quickly it can stop, of course.
Comment: ...except that you have to to wait for more distant echoes to die out, even if you aren't interested in things at greater range, otherwise they can occasionaly be mistaken for near reflections of subsequent pings.
Answer: The transducers exist, but the ranging modules do not (for the hobbiest range at least). Selection amongst ranging modules is very low. The selection is pretty much limited to ~40kHz for broad-beam long range detection and ~235kHz for narrow beam short range detection. That's it.
Frequency determines range and cone angle so you will end up at similar frequencies if you are looking in the "same way" in multiple directions you will end up with similar frequencies which a normal simple ranging sensor won't be able to differentiate.
Your most practical approach would be to do what the others suggest which is to stagger your transmit-receives between your sensors.
But if you have lots of time and patience then it is possible to go all out and build your own ranging module. If you go this far then you might as well go all the way and get wideband transducers (probably electro-static transducers) that are reasonably effective from 20kHz to 100kHz. I would list the only manufacturer I know of that makes these available to hobbiests but that would be off-topic.
Using these ranging modules you can adjust the frequencies you transmit on the fly at for long range, wide beams or short-range, narrow beams. If you get into more complex processing you can also do things like transmitting a swept frequency (chirping) to make the transmissions more unique so you can pick them out, or use phased arrays for beam forming. Basically a lot of the fancy radar can do but with sound. Big project though. More complicated than whatever project you have going on right now.
But I'm getting some red flags because you imply that you need to be able to measure the distance between two sides almost simultaneously. The most common reason for that is close-range obstacle avoidance which ultrasonics is not the best solution for. But you never said why you needed to detect distance from multiple sides or what ranges you need so I cannot be more helpful.
Comment: "but that would be off-topic" I've seen this a in a number of answers on electronics.SE, but my understanding was always that while *asking* for specific recommendations would make a question off-topic, it was fine to include examples of products in an answer. Is that not the case here?
Comment: (don't mean to pick on you specifically DKNyguyen, just thought it seemed relevant and the link would have been a nice inclusion if allowed)
Comment: @mbrig Is it? I don't know. I never thought about it that way. The company is Senscomp.
Answer: Dave's answer is certainly one way to go. Using the same part which operates at the same frequency, but then multiplexed within time, you can achieve data acquisition from both sides. However, considering you have to wait a certain amount of time between pings, it may limit your overall sampling rate more than you would like. In which case, there do exist sensors that operate at different frequencies so that you can achieve simultaneous operation and double your potential sampling rate. How much this matters depends on various factors like the environment and how fast your bot is moving.


What is the drawback of using a non-parametric test when parametric alternative could have been used?

Question: I want to analyze the difference between two paired samples. My initial plan was to compare them using the Wilcoxon test because I didn't want to bother checking whether the data is properly distributed for (e.g) paired t-test, and selecting a non-parametric test sounds like a safer mode of action. What is the drawback of my laziness? What am I risking?
Comment: Lower power... less likely to detect an effect, if an effect is present.
Comment: @user2974951 Not necessarily. If the parametric test is not appropriate the power could be lower for that test. Boris, if you have enough data, e.g., 40 entries, plot a histogram and look at it, also, tests for which distribution it is are very easy to perform, if there is enough data. Also, if you don't have enough data and if you know something about the underlying physics that give rise to the data, you may already know what type of distribution it has to be.
Comment: @StephanKolassa Yes, thank you!
Comment: The link is informative and comprehensive. You should read it, but your question is just about paired tests and my answer focuses on them.
Answer: The first difficulty with your question is the implication that it is
always appropriate to use the nonparametric test without checking anything, while it takes considerable effort to discover whether it is OK to use a t test. It is true that
a nonparametric test does not require normal data, but nonparametric
tests have their own requirements. For example, a Wilcoxon signed
rank test works best when data are symmetrical, and does not work well
if there are ties--especially in small samples.
Whether you use a Wilcoxon signed rank test or a t test, a paired test is essentially a one sample test on differences, so it is easy to compare
the power of the two tests in case data are normal. It is a good idea to look at a stripchart, boxplot, and normal probability plot of the data before deciding which test to use.
The issue of power has been discussed briefly in comments. If data
are normal and not rounded to give ties, both tests may OK, but the t test will have the better power.
Suppose you have a sample of size $n = 12$ pairs with differences
distributed $\mathsf{Norm}(\mu=2,\sigma= 2)$ then what is the probability I will detect that the mean is not $0,$ using a t test with significance level $\alpha = 0.05 = 5\%?$ The answer by simulation is about $0.88 = 88\%.$
set.seed(422)
pv = replicate(10^5, t.test(rnorm(12,2,2))$p.value)
mean(pv <= .05)
[1] 0.88211

If the normal data are rounded to integers, then the t test gives almost
the same power, about $87.5\%.$
set.seed(422)
pv = replicate(10^5, t.test(round(rnorm(12,2,2)))$p.value)
mean(pv <= .05)
[1] 0.8745

If I use a Wilcoxon signed-rank test on the same data, what is the probability I will detect that the data are not centered at $0?$
With the nonparametric Wilcoxon test the power is only about $0.78 = 78\%.$
set.seed(422)
pv = replicate(10^5, wilcox.test(rnorm(10,2,2))$p.value)
mean(pv <= .05)
[1] 0.78466

In this case, if the data are rounded to integers, than there will be
warnings about the ties induced by rounding, P-values may not be accurate
and the power will be below $75\%.$
set.seed(422)
pv = replicate(10^5, wilcox.test(round(rnorm(10,2,2)))$p.value)
mean(pv <= .05)
[1] 0.74398

On average, there are more than four ties out of 12 differences distributed
$\mathsf{Norm}(2,2).$
set.seed(422)
nr.tie = replicate(10^5, 10-lengh(unique(round(rnorm(10,2,2)))) )
mean(nr.tie)
[1] 4.23821

Comment: Thank you very much. Very helpful


Live Agent Case creation from Pre Chat

Question: I try to create a case as soon as I accept the chat. The case record type should be picked from the guest user profile which I mentioned only one, but in console the case gets created with the default type. I have mentioned the case record type tag as well, but still it is not working.
Answer: Method One : PreChat API Only (Record Type by ID)
Create a hidden input field that will host the Record Type by Id, because RecordType Name is not supported in live agent:
<input type="hidden" name="liveagent.prechat.caseRecordType" value="RECORDTYPEID" />

Then in your findorcreate.map, make sure you are mapping caseRecordType to RecordTypeId in Salesforce, like this (you will likely have other items in your map too, but I removed mine for simplicity in this answer and only left RecordType:
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="RecordTypeId,caseRecordType" />

Then, lastly, in your findorcreate.map:DoCreate, make sure you include RecordTypeId,true:
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="RecordTypeId,true;Origin,true;Subject,true;Status,true;" />

As noted by another answerer, the downside to this implementation is that you will need to change the hard coded RecordTypeId in the preChat VF page when deploying it to a production org, since the RecordTypeId will be different.
Method Two : PreChat API and Workflow Rule (Record Type by Name)
Using the PreChat API, we have the ability to set any field on the case object, similarly to the way that we are setting record type in Method One. StackExchange user PepeFloyd suggests that if you are setting any of your values to a unique value that is only used during a live agent chat, then you can also add a workflow rule that fires off of meeting that criteria that sets the record type for you.
First we set our unique value on the case object. In this example, we set the case origin to "Chat" and assume that "Chat" is never used as the origin in any other scenario. We then add it to the map, and the doCreate:
<input type="hidden" name="liveagent.prechat.caseOrigin" value="Chat" />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;" />

Then our Workflow Rule would look something like this:

And our Field Update:

You would of course set it to your appropriate Record Type.
Comment: It's easier to do and maintain this  with a workflow rule.
Comment: @sfdcrowdy For example, if you were populating the new case via pre-chat api with the value "Chat" for the field "Origin" you could have a workflow rule that would update the record type via field update based on the origin value.
Comment: @PepeFloyd - Just be curious to do that, Can you please tell me??
Comment: Great idea Pepe! I'll update my answer to include it.
Comment: Why don't  you just query for your recordtypeid and set it as a variable so you don't have to statically type it? `String recordTypeId = [SELECT id from RecordType WHERE SobjectType = 'Case' AND Name = 'myCustomRecordTypeName'].get(0).id;`
Answer: I doubt there is some internal mechanism to query recordtypeId here ,one of the following ways to address this problem is use hardcoded recordtype Id as below
<input type="hidden" name="liveagent.prechat:caseRecordType" value="573a00000000001" />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;RecordtypeId,caseRecordType;" />

Only drawback i see is in production you may need to change the recordtypeId copied using developer console or set up menu
Answer: I have also found that if part of your case creation has a need to link to an existing contact, and you want to find the contact by email address and with a specific record type (like 'Customer') then we have a similar problem. You need to hard code a record id for the contact.
Because 'liveagent.prechat.findorcreate.map.doFind:Contact' can't be filtered with a record type name. But it can with a RecordTypeId

Live Agent Case creation from Pre Chat