C++ Class Serialization

Question: I quite recently learned about the C++ classes friend keyword and the uses in serialization and now I need some help in getting it to work.
I have no problem serializing my class to a file, it's working great, however i'm having a hard time trying to read this file into a vector container. I'm sure I need a loop in my code that reads line by line, but since the class has different types I guess I can't use std::getline() and also maybe that approach wouldn't use the istream method i implemented?
A sample output file would be:
Person 1
2009
1

Person 2
2001
0

My code:
class SalesPeople {
    friend ostream &operator<<(ostream &stream, SalesPeople salesppl);
    friend istream &operator>>(istream &stream, SalesPeople &salesppl);

    private:
        string fullname;
        int employeeID;
        int startYear;
        bool status;
};

ostream &operator<<(ostream &stream, SalesPeople salesppl)
{
    stream << salesppl.fullname << endl;
    stream << salesppl.startYear << endl;
    stream << salesppl.status << endl;
    stream << endl;
    return stream;
}

istream &operator>>(istream &stream, SalesPeople &salesppl)
{
    stream >> salesppl.fullname;
    stream >> salesppl.startYear;
    stream >> salesppl.status;
    // not sure how to read that empty extra line here ?
    return stream;
}

// need some help here trying to read the file into a vector<SalesPeople>
SalesPeople employee;
vector<SalesPeople> employees;

ifstream read("employees.dat", ios::in);
if (!read) {
   cerr << "Unable to open input file.\n";
   return 1;
}

// i am pretty sure i need a loop here and should go line by line
// to read all the records, however the class has different
// types and im not sure how to use the istream method here.

read >> employee;
employees.push_back(employee);

By the way, I know that the Boost library has a great serialization class, however I'm trying to learn how serialization would work using the STL library for now.
Thanks a lot in advance for any help that you can give me and for getting me in the right track!
Answer: It looks like you pretty much have all the code you need already!  I copied your code and compiled it with some changes to read the SalesPeople in from a file in a loop.  I will include the changes below, but since this is for your homework, you may just want to read and think about the following hints before looking at the code.

For reading the SalesPeople in a
loop, I would recommend that you take
a look at this FAQ.  It has an
example of almost exactly what you
need.  FAQ 15.4 will also help
you, I believe.
For your question on how to handle
the extra empty line when reading
from the file, check out this
link.  You can very simply
extract whitespace this way.
As jfclavette suggested, I would
recommend looking into
std::getline for reading in the
SalesPerson's full name, since you
need everything on that line into one
string.

I have one question for you, though: what about the employeeID?  I notice that it is being ignored in your sample code.  Is that on purpose?
And now, if you still need help, you can check out the code I wrote to get this to work:
istream &operator>>(istream &stream, SalesPeople &salesppl)
{
    //stream >> salesppl.fullname;
    getline(stream, salesppl.fullname);
    stream >> salesppl.startYear;
    stream >> salesppl.status;
    // not sure how to read that empty extra line here ?
    stream >> ws;
    return stream;
}

while(read >> employee)
{
    // cout << employee; // to verify the input, uncomment this line
    employees.push_back(employee);
}

Also, as jfclavette suggested, it may not be a bad idea to add some input validation (check the stream status after reading from it and verify that it is still good).  Although I would recommend using the while() loop for the reasons stated in FAQ 15.5.
Comment: Thank you so much!!!!
That helped a lot! Now I understand much better what I was doing wrong.
Also, I had no idea about ws, I have been wondering how to do that for a long time! Thank you so much!
Answer: Not sure what your problem is.  What exactly are you not understanding ?  The fact that your names are composed of multiple tokens ?  There's no magic way to do it, you might want to get the name trough getline().  Alternatively, you may want to specify the number of tokens when serializing and read the appropriate token count.  ie, your file might look like.
2 Person 1
I assumed that Person was the first name and 1 the last name here.  You might also enforce the notion that there's one first name, and one last name and just read each one separately.
You'll typically loop while (!ifstream.eof()) and read.  Of course, you should always validate the inputs.
Also, why are you adding an extra endl between each record ?  Serialized data need not be pretty. :)

C++ Class Serialization


Index clusters vs head search cluster in Splunk

Question: I am trying to learn Splunk and understand how to install Splunk Enterprise on AWS.
While reading through the documentation, I came across index clusters and head search clusters in Splunk, but there is no documentation (which I can find) showing how these 2 clusters interact with each other.
The quick start guide is setting up both indexer cluster and search head cluster in one environment, but even in this, there is no mention of how these 2 work together and relate with each other.
Any reference to relevant docs or explanation will be great.
Answer: I also posted the same question on splunk Q&A website and I got the answer there which was able to solve my doubt. Posting same here:-
<code>Search head clusters and indexer clusters are two entirely independent types of clusters used for entirely different purposes.

Indexer clusters connect together multiple indexers so they share data for redundancy or performance, spread out the "indexer side" of the search load (which can be most of it, depending on your searches) and so on. It supports data replication, inputs load balancing, all that sort of stuff.

Search Head clusters (SHC) are a way to build a cluster of search heads. So much like indexer clustering only it handles users, dispatching searches, displaying the data and so on.

The two interact mainly via a simple mechanism.

Search heads (and search head clusters) search the data held on Indexers (and indexer clusters). That's really about it. You can have a SHC search a single indexer, you can have a single SH search an Indexer cluster. Or a single SH search a single Indexer. Or a SHC search a Indexer cluster.

For those different scenarios, the only real difference is the setup of the indexer/SH side of thing with respect to the cluster. Once that cluster is set up, the interaction between the two is defined by Settings/Distributed Search.
</code>


Can a tenant build equity in property they are renting?

Question: A tenant rents commercial property and invests substantial capital to renovate and improve the space in order to run a business. Does the renter's investment entitle them to equity or a percentage of ownership in the property?
Comment: This is more a legal question and requires a jurisdiction (country and state if applicable). But in general I think the answer is going to be NO unless you have some sore or reimbursement agreement in writing ahead of time.
Answer: Normally a tenant doesn't build equity.
Normally when a tenant makes modifications to the rental property, the modifications if they can't be removed, are now owned by the landlord. It is possible to negotiate a credit of some sort so that if a tenant has to make modifications they don't end up paying for all the costs. I have seen this where company renting office space was given a budget to refresh the paint, and carpet, or two move some walls. Of course the owner calculated this budget when determining the amount of rent.
It is best to negotiate these deals long before committing to the modifications. It lets you know the costs, and what can be saved at the end of the rental period. It also lets you know if you will have to pay to put things back at the end of the lease.
Answer: No, there is no entitlement to equity or a percentage of ownership in the property unless explicitly agreed to between landlord and tenant.
That would be an extremely odd ask from a tenant. A tenant might be able negotiate a lower rent or other concessions if they are making capital investments that the landlord can benefit from beyond the lease term. But with commercial leases commonly being 5-10 years, it's perfectly normal for the tenant to expend their own capital with no concessions to customize a space to their liking. In fact, a tenant might have to spend money to return the space to how they found it if customized too much.
With that information, it's prudent for the tenant to shop around for a space that they don't have to customize as much upfront. If a business requires a highly customized space in order to operate regardless (like a manufacturing facility), then the business should consider owning the space since it's more of an inherent part of operating the business.


Recover photos that got deleted when device switched off?

Question: I have a Moto X Pure running Android 6.0. I have a lot of pictures saved on it. I was recently taking pictures and the device ran out of battery and switched off. When I got home and turned it back on, I couldn't locate the last 30 or so photos that I took when the battery was running low. The videos that I took during this same time show a file size of 0kB and are not openable. However, all the older photos - even the ones I took earlier on the same day - are completely unaffected. I am wondering what could have caused this? Is there a way to recover the photos without having to root the device (most file recovery software that Google searches showed up need the device to be rooted to access internal memory)? I have around 1 GB of free space and I've never received a low disk space notification, nor did I get any other error when taking these pictures. Any help is appreciated.
Answer: You can connect your device to PC/Laptop whatever you have and use one of the data recovery tool like recuva*, easeus, etc. So, download easeus on your PC and connect your phone then select your device to scan for picture or videos or whatever you like. Good thing is that you don't need the rooted device to do that.
*Recuva cannot act on an Android device's storage, if device has been set to MTP. But if your files were on MicroSD cards you can use recuva to scan them.(thanks to  Death Mask Salesman)


Don't apply sort criteria by default

Question: I added sort criteria by price to my catalog view, and in the sort criteria I have only to option to use by default one of them - Ascending or Descending. But I don't want to use any sorting by price by default in catalog, I would like to apply it (one of the option Ascending or Descending) only after user chose an option and pressed button 'Apply' on the sort form. Is there any opportunity to do that?
Answer: What would be removed from the directory by default sorting, you need to remove from Sort criteria. And leave the possibility of the sort only Filter criteria
Answer: You would need to remove the sort criteria that you have added. Once you remove that, that only the expose filter would work and you would be able to sort the content on the basis of what the user has selected in the Expose filter.
Hope that this help.

Don't apply sort criteria by default


CLRS Algorithms: Merge n/k sublists each of size k in O(n*lg(n/k))

Question: This is a problem 2-1.b from CLRS.
I don't understand how to merge n/k arrays of size k each in n*lg(n/k).
The best solution I can come up with is to fill each entry of a final array of size n by searching for the min element amongst min elements of each sublist. This leads to O(nk). What is the algorithm to do it in specified time?
Comment: Use a binary heap to perform a [n/k-way merging](http://xlinux.nist.gov/dads/HTML/kwayMergeSort.html)
Answer: I just did this question, and I think the answer is as follows:
Sublists are still merged two at a time.
1) Consider how long it takes to merge each 'level'.
2) Consider how many merge operations there are (number of 'levels' below the first list you start with).
How long to merge each level?
Each sublist has k elements, and there are therefore (n/k) sublists. The total number of elements is therefore k * (n/k) = n, and so the merge operation at each level is theta(n).
How many merge operations (levels) are there?
If there is 1 sorted sublist: 0
If there are 2 sorted sublists: 1
If there are 4 sorted sublists: 2
If there are 8 sorted sublists: 3
If there are 16 sorted sublists: 4

1 = 2^0
2 = 2^1
4 = 2^2
8 = 2^3
16 = 2^4

So we can make a general rule, in the same format as the specific ones listed above:
If there are 2^p sorted sublists: p

When we need ask the question "2 to the power 'what?' = m", then we need a logarithm.
So, if we ask "2 to the power 'what?' = 16?"
the answer is log to base 2 of 16 = lg 16 = 4
So asking how many levels of merge operations are there is the same as asking "2 to the power 'what?' = m".
We now know that the answer is log to base 2 of n = lg m.
So we now know there are lg m levels of merge operations, and each level of merge operations takes n time. The total time is therefore n * lg m = n lg m
Remember, m is the number elements we want to merge, in this case, the number of sorted sublists returned by the insertion-sort part of the algorithm. This is n/k. So, the Total time is n log (n/k).


Creating Record Page with Lightning App Builder

Question: I am trying to create a new record page using the lightning app builder for the Report object. I don't see Report in the dropdown of objects, but every other object is included. How can I make a record page for Reports?
Answer: There is no way you can create lightning record pages for reports in the Lightning app builder. reports are built-in report builder instead of lightning app builder. Reports represent a report, a set of data that meets certain criteria, displayed in an organized way. Access is read-only. This object is available in API version 20.0 and later.


Headphones don't work & music automaticaly starts

Question: I have a Samsung trend plus.
When I plug the earphones, the phone recognizes the connection and shows the earphone icon and gives the earphones connected massage. Then automaticaly starts music, which is not normal. But the sound comes from phone's speakers instead of earphones. I can barely hear the music coming from the speakers. And even in full volume setting, it has very low volume. I tried the earphones in my computer so it's not earphone problem. I tried restarting...
Comment: Did the earphone worked properly before on the mobie you are using? Is that a samsung earphone? if yes did that came inside the package or you bought it separately?
Comment: Yes earphones was working properly with my phone before. It still works properly with other devices.I also tried two different earphones.
Comment: then it should probably be a hardware(headphone jack) problem..you can replace it..
Answer: Try using another set of headphones for your phone. If the problem persists then it's the problem with your phone's hardware.
Answer: Its not hardware problem. But on software side. If you dont use any custom rom features and assuming you are on stock rom and havent flashed any such mods, then check your music player or any audio managers you may have in your phone. Its them that has option to auto start music upon plugging in headphones. So check your music app for such an option and disable it.
As for sound not coming through heaphones but heaphones being detected, thats again a software problem. I suggest you try changing music player app instead. Or atleast go through its settings for once. There has to be an option for something like audio priority. Would help if you be more specific and specify phone model you use, if you are rooted and on custom rom, the media player app you use.


GnuCash how to do laptop purchase payment plan

Question: I bought a laptop for $1000 online and paid by credit card. The payment plan is 10-month payment with 0% interest rate. So it charges $100 to my credit card each month. In this case, how do I do it on GnuCash? Split transaction has to be happen on the same day, where I need the $100 credit card bill split to 10 months.
Answer: The transaction is not split. You transferred $1000 from your credit card to your fixed asset in one go, nothing split there. Repayment of your credit card liability is a series of entirely separate and unrelated transactions between your checking account and your credit card account.
Answer: The initial purchase of the laptop represents a liability to make a series of repayments in the future.  You should therefore credit your Liabilities:Laptop Purchase account by $1000 and debit your Assets:Laptop account by $1000 when you take delivery of the laptop.
(Note: depending upon the accounting policies in place in your home or business, it may be legitimate to treat the laptop as a one-off expense instead of an asset with lasting value.)
Each month when the financing arrangement charges $100 to your credit card, you should show a credit of $100 to Liabilities:Credit Card and a debit of $100 to the Liabilities:Laptop Purchase account.  As a similar transaction will occur 10 months in a row, there's good reason to set that up as a Scheduled Transaction.
Your monthly credit card bill will include the $100 charge along with all of your other credit purchases.  You pay off some or all of this bill as normal.
Comment: That's the correct way to handle this situation, but don't forget to depreciate the laptop in 4 years or so if considering it as an asset. There are relatively few assets that should not be depreciated. A laptop certainly needs quick depreciation. Some people nowadays should think a house should not be depreciated. I disagree...


When did the pronunciation of 'hierarchy' change from /hie-/ to /hai(e)-/?

Question: I assume that 'hierarchy' was earlier pronounced
/hie-/ rather than /hai(e)-/.
Is this right?  If so, when did the change occur?
Comment: *OED* has etymology: Old French *ierarchie , jerarchie*; or Italian *gerarchia*
Answer: The sound change in hierarchy is consistent with the Great Vowel Shift (c. 1400 - 1700), which lifted /i/ to /aɪ/.
Before the Great Vowel Shift, a series of vowel changes in English that occurred gradually between 1400 and 1700, vowel spelling was relatively consistent with pronunciation. (See the Wikipedia article for a general overview.)
According to the Middle English Dictionary, spellings of hierarchy in Middle English ranged from jerarchi or gerarchi to herarchie, ierarchie, and iherarchie. The [g] and [j] are artifacts from Old French (Anglo-Norman Dictionary), whereas the [h] and [ie] preserve elements of the classical Latin spelling hierarchia (Wiktionary). Most of the example quotations preserve the [ier] spelling.
As spelling began to standardize in the 16th and 17th centuries, English writers preferred the more classical Latin version with [hier]. The OED places the hier- spelling as from the 15th century on, and Early English Books Online (a database of early printed texts) has results for hierarchie from the 16th century. By the 17th century, it appears consistently in early lexicons and dictionaries. Hierarchie appears in A Table Alphabetical (1604) by Robert Cawdrey; hierarchy appears in A Christian Dictionary (1612) by Thomas Wilson.
If the lone [e] vowel had persisted from Middle English spellings, it might have shifted from /e/ to /i/. However, [ier] and [hier] as a form show up early enough (15th century) that hierarchy likely went from /i/ to /ai/, possibly with an intermediary step /әi/. Conventional resources on GVS state that /ai/ is well-established by about 1700, and I see no reason to except hierarchy from that explanation.

When did the pronunciation of ‘hierarchy’ change from /hie-/ to /hai(e)-/?


Why does molecular potential energy increase with constant temperature?

Question: You heat up a liquid at its boiling point, and the temperature remains constant until all the liquid has turned into vapour. Since the temperature stays constant kinetic energy stays constant too, but why does the molecular potential energy increase?
Comment: Re: "since"... Temperature is not the same as kinetic energy.
Comment: Temperature is not average kinetic energy and mean kinetic energy doesn't have to stay constant during phase change. Temperature is defined in terms of the ratio of the rates of change of total entropy and total energy. That ratio must stay constant when temperature is constant, but any factor of that ratio is free to change provided the ratio stays constant.
Answer: The heat energy transferred to the substance undergoing a first order phase transition is used to break the molecular bonds of the substance characteristic of that phase.  For example, when water ice changes to liquid water, one must provide the latent heat to break the bonds of the crystalline structure to the less tightly held together bonds of liquid water.  Same story for liquid water to water vapor.  You can see https://en.wikipedia.org/wiki/Latent_heat for more information.


Select by raster colour in ArcMap

Question: Is it possible to select every pixel with a certain RGB combination in ArcMap 10.5? For example, from a .tif image I want to select and extract all the red pixels. In this case the RGB codes would be: 251, 118, 121. Is it possible to select these pixels and possibly also expand the range, so that pixels that are slightly darker or lighter would also be selected. Is this at all possible in ArcMap or do I have to use Photoshop (or something similar)?
Answer: There are several ways to do that in ArcMap. The first choice from the top of my head would be to use the raster calculator with three conditional Con statements. I think that this is the best choice to understand what happens under the hood of more automatic algorithms (including the ones in Photoshop).
For example, in the raster calculator tool you can create a binary raster with pixel values

1 for red = 251
0 for red <> 251 (unequal)
Con("red", 1, 0, "Value=251")

Then you can do the same for the green and blue channels.
Con("green", 1, 0, "Value=118")
Con("blue", 1, 0, "Value=121")

Multiplying all these three intermediate results returns a pixel with values

1 when all the conditions are satisfied
0 if any condition was not satisfied.

You can do that on the fly, like so:
Con("red", 1, 0, "Value=251") * Con("green", 1, 0, "Value=118") * Con("blue", 1, 0, "Value=121")

The above returns a raster with values

1 for the exact RGB values of 251, 118, 121
0 for all the rest

Similarly you can combine statements for a range of values in each color band by using greater and lower than operators.
For example, to get all red values above 251, the green values greater than 100 and lower than or equal to 125, the blue values greater than 120 and lower than or equal to 135, you would want to combine all these partial evaluations:
Con("red", 1, 0, "Value>251")
Con("green", 1, 0, "Value>100")
Con("green", 1, 0, "Value<=125")
Con("blue", 1, 0, "Value>120")
Con("blue", 1, 0, "Value<=135")

In the raster calculator you can multiply on the fly these partial rasters and directly get the result:
Con("red", 1, 0, "Value>251") * Con("green", 1, 0, "Value>100") * Con("green", 1, 0, "Value<=125") * Con("blue", 1, 0, "Value>120") * Con("blue", 1, 0, "Value<=135")

Comment: Is there a way to do this without the Spatial Analyst extension?

Select by raster colour in ArcMap


Can the test information function be used for a field test item bank?

Question: I am field testing a few forms of items (with embedded anchor items) and will be analyzing the items using IRT, a 2PL model. These items will likely be used to create an item bank that can then create forms as needed. Can I only find the test information for each field test form or does it make sense to also find the test information for the entire group of items?
Answer: You can find the test information function for each of your original forms if this is something you are interested in reviewing. You could also compute a test information function for the entire set of items and this could show you which ability levels are well covered by items in your item bank and which are not.
However, the test information functions of most interest (in my opinion) would be the ones for the forms that are constructed from the item bank. These will show you the range of ability levels the constructed forms are designed to evaluate. You can also include items to construct a test with a specific test information function.
Comment: Thank you! This is very helpful. I was thinking that I would only be able to look at test information for each form but had seen where some people also report the test information for a group of field tests. I appreciate your explanation of how and why that might be examined or reported. Thanks again.


Gradient in Spherical coordinates

Question: I'm trying to derive the gradient vector in spherical polar coordinates: $$\nabla = \left( \frac{\partial}{\partial x}, \frac{\partial}{\partial y},\frac{\partial}{\partial z} \right)$$The method I am trying to use is different from most papers/videos I found and I don't understand why it doesn't work. I am able to get expressions for the cartesian differentials: $dx, dy, dz$. First, I am just trying to find $\frac{\partial}{\partial x}$ in spherical coordinates. I have: $$dx= \cos \theta \sin \phi dr + r \cos \theta \cos \phi d \theta + r \sin \theta \sin \phi d \phi$$ This sounds strange but my first intuition was to say that: $$\frac{\partial}{\partial x} = \frac{ \partial }{ \cos \theta \sin \phi dr + r \cos \theta \cos \phi d \theta + r \sin \theta \sin \phi d \phi} $$ Which doesn't seem to make any sense now :(. If my logic is wrong, could someone explain to me why?
Comment: In any orthogonal coordinate system $\xi_1,...,\xi_n$ the gradient is
$$\nabla=\left(\frac{1}{h_1}\frac{\partial}{\partial \xi_1},...,\frac{1}{h_n}\frac{\partial}{\partial \xi_n}\right)$$
Proving this in general will produce the formula for spherical coordinates instantly.
Answer: This is a classic example of why treating something like $\frac{dy}{dx}$ as a literal fraction rather than as shorthand notation for a limit is bad. If you want to derive it from the differentials, you should compute the square of the line element $ds^2  .$ Start with $$ds^2 = dx^2 + dy^2 + dz^2$$ in Cartesian coordinates and then show
$$ds^2 =  dr^2 + r^2 d\theta^2 + r^2 \sin^2 (\theta) d\varphi^2 \; .$$ The coefficients on the components for the gradient in this spherical coordinate system will be 1 over the square root of the corresponding coefficients of the line element. In other words
$$\nabla f = \begin{bmatrix} \frac{1}{\sqrt{1}}\frac{\partial f}{\partial r} & \frac{1}{\sqrt{r^2}}\frac{\partial f}{\partial \theta} & \frac{1}{\sqrt{r^2\sin^2\theta}}\frac{\partial f}{\partial \varphi} \end{bmatrix} \; .$$ Keep in mind that this gradient has nomalized basis vectors.
For a general coordinate system (which doesn't necessarily have an orthonormal basis), we organize the line element into a symmetric "matrix" with two indices $g_{ij} .$ If the line element contains a term like $f(\mathbf x)dx_kdx_\ell\; \;$ then $g_{k\ell} = f(\mathbf x).\;$  The gradient is then expressed as
$$\nabla f = \sum_i \sum_j \frac{\partial f}{\partial x_i}g^{ij}\mathbf e_j$$ where $\mathbf e_j$ is not necessarily a normalized vector and $g^{ij}$ is the matrix inverse of $g_{ij}$.
Comment: Another great answer! It is for this precise reason I often advise people to use differential operator notation, e.g the derivative w.r.t $x$ as $\mathrm{D}_x$ instead of the older fraction notation to avoid costly errors.
Comment: Thank you for this detailed explanation. Could you elaborate as to why the components of the gradient are multiplied by the factor found in the square line element IE why is it $\frac 1{r^2} \frac \partial {\partial \theta} $
Comment: The squared line element defines a metric on the space. It is the rule by which distances (and thus the rule by which everything else) is measured. If we want the gradient vector to be the same physical object no matter what coordinate system we choose, we have to find a way to compute its projection (length) along each of our basis vectors. The factor of $\frac{1}{r}$ or $\frac{1}{r^2}$ (depending on whether or not $\mathbf{e}_\theta$ is normalized) exists to ensure we are measuring length in a consistent way.
Comment: does the square root give positive and negative values in $\frac{1}{\sqrt{r^2\sin^2\theta}}\frac{\partial f}{\partial \varphi}$?
Answer: I am not satisfied with vb628's answer. Even after patryan asked for clarification, and vb628 responded, I am still uncertain why the scaling factors are what they are. Therfore, I undertake my own answer here.

$$\boldsymbol{\nabla}{f} =   \mathbf{e}_r\, \frac{\partial{f}}{\partial{r}}
+
\mathbf{e}_\theta\,\frac{1}{r } \,\frac{\partial{f}}{\partial{\theta}}
 +
\mathbf{e}_\phi\,\frac{1}{r\,\sin{\theta}} \,\frac{\partial{f}}{\partial{\phi}}\qquad\text{in spherical coordinates}.$$

To undertake this derivation I need the result that
\begin{equation*}
d\mathbf{s}
=
\mathbf{e}_r\,dr
+
\mathbf{e}_\theta\,r\,d\theta
+
\mathbf{e}_\phi\,r\,  \sin{ \theta} \,d\phi .
\end{equation*}
Please note that $d\mathbf{s}
\cdot d\mathbf{s}
$ gives vb628's result for $ds^2$ found above.
I also need to consider the differential arc length in each of the three directions of the standard spherical basis:
\begin{align*}
ds =
\begin{cases}
d\mathbf{s} \cdot\mathbf{e}_r =dr,
&
\text{when  arc   constrained to   $\mathbf{ e }_r$ direction;}
\\
d\mathbf{s} \cdot\mathbf{e}_\theta =r \,d\theta,
&
\text{when arc constrained to   $\mathbf{ e }_\theta$ direction; and}
\\
d\mathbf{s} \cdot\mathbf{e}_\phi =r\,  \sin{ \theta} \,d\phi,
&
\text{when arc constrained to  $\mathbf{ e }_\phi$ direction.}
\end{cases}
\end{align*}
According to the definition in [1], $\boldsymbol{\nabla}{f}$ in a direction $\mathbf{u}$ is the directional derivative $df/ds$ in that direction. The element of the archlength $ds$ in the $\mathbf{ e }_r$ direction is $dr$, so
$$\boldsymbol{\nabla}{f}\cdot \mathbf{e}_r
= \frac{d{f}}{ds}
= \frac{\partial{f}}{\partial{r}}.$$
Note that I replace  the derivative with the partial derivative to re-enforce  that the arc is constrained to one of the standard basis directions.  Below, I will do the same thing twice more.
Similarly, the element of the archlength $ds$ in the $\mathbf{ e }_\theta$ direction is $r\,d\theta$, so
$$\boldsymbol{\nabla}{f}\cdot \mathbf{e}_\theta
= \frac{d{f}}{ds}
=
\frac{\partial{f}}{r\,\partial{\theta}}.$$
Finaly, the element of the archlength $ds$ in the $\mathbf{ e }_\phi$ direction is $r\,\sin{\theta}\,d\phi$, so
$$\boldsymbol{\nabla}{f}\cdot \mathbf{e}_\phi
=
 \frac{\partial{f}}{r\,\sin{\theta}\,\partial{\phi}}.$$
Thus, in spherical coordinates, we have
$$\boldsymbol{\nabla}{f} =   \mathbf{e}_r\, \frac{\partial{f}}{\partial{r}}
+
\mathbf{e}_\theta\,\frac{1}{r } \,\frac{\partial{f}}{\partial{\theta}}
 +
\mathbf{e}_\phi\,\frac{1}{r\,\sin{\theta}} \,\frac{\partial{f}}{\partial{\phi}}$$
Bibliography
[1] Wikipedia contributors. (2021, January 14). Gradient. In Wikipedia, The Free Encyclopedia. Retrieved 21:38, January 27, 2021, from https://en.wikipedia.org/w/index.php?title=Gradient&oldid=1000232587
Comment: are the unit vectors normalized, because I was multiplying by the inverse metric tensor components and somehow got wrong answers
Comment: The vectors $ \mathbf{e}_r $,
$\mathbf{e}_\theta$, and $\mathbf{e}_\phi$ form an orthonormal set in three dimensional space.
Comment: thanks, originally I did not normalize the basis, and when I asked unit, I meant basis.

Gradient in Spherical coordinates


Why don't I see any Buzzer vehicles on the map anymore?

Question: I've completed 9 campaign missions, and was loving the Buzzer ultra-light helicopter that I found after the 7th mission.  I saved and quit for the night, and now that I've come back to continue playing, I don't see any Buzzer vehicles anywhere on the map.  What happened to them?  Do they only exist during certain times during the gameplay?
Answer: There are always Buzzers around. For example you can find them where the supply drop missions for the golden path are or near bell towers. I'd suggest, in case you already reside at your family's home (after doing the first mission for Yogi), buying a Buzzer (the sherpa outside your home sells you upgrades to your home, like a helipad).
Comment: Yeah, I died in a surprise attack by a clouded leopard and when I respawned the map showed Buzzers again.  Game glitch.  Next time it happens, I'm going to go to a place where I know they are always located to see if I can still use it even though the map doesn't show it.
Comment: @Alan as I already mentioned in my answer you'll can always have one in your homestead or for sure at cleared fortresses.
Answer: Vehicles only display on the map when you are located close to them.
When you move out of their range, they become invisible on the map.
I have encountered many bugs but none like that.


Message after sudden shutdown

Question: After the computer shuts down suddenly unexpectedly without notification, is there a way to know the reason (read messages) the next time when I boot? My computer frequently shuts down, and I don't even know if it is a software problem, a hardware problem, or a firmware problem.
Comment: These issues are tough to solve. Make sure your hardware is in good condition; all fans running, no dust blocking the vents etc. I see you built the computer yourself, in that case you have sufficient knowledge to also check if all connectors are firmly in place.
Comment: Does it shutdown in a more or less controlled way or does it just power off? In the first case your filesystems do not need checking at boot, in the second your filesystems are automatically being checked.
Comment: @jippie The latter: it just powers off.
Comment: @jippie So, do you think it is likely a hardware problem?
Comment: Don't know, it might. I slightly updated my comment above.
Answer: That would generally depend on your operating system, the type of computer you're using, and how abrupt the reboot was.
Many Unix-like operating systems (including the popular Linux-based ones) keep their logs in /var/log. On some others, /var/adm is the standard location. The specific files stored there depend on the OS, distribution and configuration. Look for kernel or kernel.log, then try messages{,.log} or syslog{,.log}.
Some non-Linux Unices can produce a full report of a crash whenever this happens. Check the OS docs on where the crash dump is stored, and how to read it.
If your computer has server management board, IPMI board, or somesuch, the reason for the reboot may be recorded there. Check the logs via the web interface or ipmitool. If your mainboard has a dumber watchdog, the watchdog may be responsible for the reboot but this won't be logged.
If you still can't find any information, there are two cases: either the reboot is too sudden for the logs to be written (consider mounting your /var partition sync temporarily — it's a serious performance hog), or there are no logs to be written. In the latter case, the issue is either a very low-level hardware fault or a power supply issue (e.g. the POWEROK signal from the power supply de-asserting and causing a hardware reset, or a half-dead laptop battery behaving strangely — the laptop I'm on right now has been known to do this occasionally when running on battery power).
Comment: @saw Have a look at http://www.mcelog.org/ if it is a hardware problem and you have the right hw this may help
Comment: The computer was built my myself. The motherboard is Intel brand. The power is taken from AC, but I use a power unit called pico psu. I modified it a little bit with soldering, so I may have damaged it, or maybe the power capacity is not enough (the unit only allows about 60W). The OS is linux mint 13. Following your suggestion, I looked for the files, and there are files named `/var/log/kern.log.*`, `/var/log/syslog.*`. I will try to look into these. Thanks.
Comment: PS. The reboot does not happen automatically. It just shuts down. I have to manually do it, sometimes failing.
Comment: @UlrichDangel Thanks. I just installed it.

Message after sudden shutdown


Faster way to search for a string than the boyer moore algorithm?

Question: Is there any faster way to search for a string in a file?
Answer: Look at this site, where you can also see the matching time for each of the algorithms.
Answer: The Turbo Boyer-Moore algorithm is faster, but requires more space.
http://www-igm.univ-mlv.fr/~lecroq/string/node15.html
Answer: If you know anything specific about the file, there could be faster algorithms.
For example, if the file contains many repeating characters/patterns and you need to do a large number of searches, you could try using Suffix Trees: http://marknelson.us/1996/08/01/suffix-trees/
Depending on your file and the quantity of searches you need on that one file, the answer for the fastest search algorithm may change.


The best ways to practice Magento 2 when not in work

Question: Any recommendations for how to practice Magento 2 when not working? i.e. it's easier when working as you're presented with real life task, issues, clients etc. but when practicing at home, I'm just not sure of the best way to keep harnessing and improving Magento 2 skills etc.
Answer: Your question is a bit ambiguous, magento has a lot of aspects, frontend, backend, architecture and each section needs its own research.
You can start as a newbie with following:
There are a lot of articles available you can read online specially weblogs, I suggest you study the following links:
https://alanstorm.com/category/magento-2/
https://www.mageplaza.com/blog/
Also following this YouTube channel really helped me:
https://www.youtube.com/c/AlaaAlMaliki
after you got comfortable you can study the dev docs:
https://devdocs.magento.com
after again you spent some time and got comfortable, look at the most voted users here on magento and look at their question and answers it is a great resource to see what skills you are missing.
Comment: you can apply for contract jobs, you will be a great help to most of companies if you agree on part time contracts.
Comment: Thank you for your reply :) my bad, I should have mentioned, I am not a newbie, rather I have been a backend developer for over 5 years now. My question was relating to the scenario as a freelancer such as when you have the spare time, what is the best way to further enhance your Magento skills as in my case, a backend developer. I like to work on real tasks but when I'm at home just practicing, I can't seem to think of anything new to work on without having a specific task in mind. I find it easier if I'm working on real client tasks etc.


Given $m,n$ positive integers, count how many positive integer pairs $(a,b)$ are there such that $a(m-a) = b(n-b)$.

Question: Given positive integers $m,n$ is there a closed form formula for the number of pairs $(a,b)$ such that $1 \leq a \leq m, 1 \leq b \leq n$ and $a(m-a) = b(n-b)$? I wrote a R program to count these for various values of $m,n$ and apparently there is no pattern we can conjecture. For example, for $n=43$, for the values of $m \leq 12$, it is $0$ and for $13, 14, 15, \ldots$, the count is $4, 0, 0, 0, 4, 0, 0, 0, 0, \ldots$. Also for $m=41$ the count is 12, for $43$ it is 84 (when $m=n$, I have a good way to count), $m=47$, the count is 16. Since the equation is symmetric, when $m \neq n$, we can guess that the count is even.
Comment: For $m=n$ the count is infinite as $a=b$ is a solution. As you gave a finite answer for that case your R program may not be exhaustive in other cases as well.
Comment: Thanks. I need only those $a,b$ such that $1 \leq a < m$ and $1 \leq b < n$. Edited the problem statement.
Answer: Suppose $m>n$. Let $D$ be the set of pairs $(s,t)$ of integers satisfying the following conditions:

$st=m^2-n^2$
$|s|,|t|<m+n$.
$s\equiv m+n\pmod2$
$s+t\equiv2m\pmod4$

Then the number of such pairs $(a,b)$ is $|D|$. This is not a closed formula, but factorising $m-n$ and $m+n$ and enumerating the factors of $m^2-n^2$ should be faster than considering all pairs $(a,b)$ with $0<a<m$, $0<b<n$.
To see that $D$ is in bijection with the pairs $(a,b)$, note that
$$
  (2a+2b-m-n)(2a-2b-m+n)=4a(a-m)+m^2-4b(b-n)-n^2
$$
so the given equation is equivalent to
$$
  (2a+2b-m-n)(2a-2b-m+n)=m^2-n^2.
$$
The bijection is given by
$$
  s=2a-2b-m+n,\,t=2a+2b-m-n,
$$
$$
  a=(t+s+2m)/4,\,b=(t-s+2n)/4.
$$
Note that the parity conditions on $(s,t)$ ensure that $(a,b)$ are integers. The inequalities on $s,t$ are equivalent to $0<a<m$ and $0<b<n$. Indeed $|2a-m|<m$ and $|2b-n|<n$ implies $|s|,|t|<m+n$. Conversely suppose $|s|,|t|<m+n$. Note that we have two symmetries $(s,t)\mapsto(t,s)$ and $(s,t)\mapsto(-s,-t)$ of $D$ which correspond to $(a,b)\mapsto(a,n-b)$ and $(a,b)\mapsto(m-a,n-b)$. Therefore we may suppose $0\leq|s|\leq t$. But $st=m^2-n^2$ implies $s,t$ have the same sign, so $0\leq s\leq t$. Now $t<m+n$ and $st=m^2-n^2$ implies $s>m-n$, so
$$
  0<n/2\leq b<n.
$$
Finally $a(m-a)=b(n-b)>0$ implies $0<a<m$.


Are there more stars in the universe than grains of sand in the Earth?

Question: My ten year old daughter asked me this question at breakfast and I initially said yes, but on second thought I was also puzzled.
Comment: On Skeptics.SE: https://skeptics.stackexchange.com/questions/9059/more-stars-than-grains-of-sand
Comment: From @AndrewGrimm 's link, 10^20 to 10^24 grains of sand, 7x10^22 stars. You can shrug and tell her "dunno" ;)
Comment: @JollyJoker about a mole of each.
Comment: According to [Neil deGrasse Tyson](https://youtu.be/TLObjMmM6nA?t=1m46s), there are indeed. And if it's good enough for Neil deGrasse Tyson, it's good enough for me.
Comment: The estimates of each quantity are so plentiful as to vie with the answers themselves in magnitude.
Answer: A quick google gave me these (approximate) figures:

7.5 x 1018 grains of sand in all the beaches and deserts of the world
7 x 1022 stars in the observable universe

If these are reasonable estimates, then there are approximately nine thousand stars in the observable universe for each grain of sand on Earth. (By observable universe, I mean in all the galaxies that we can detect with our most powerful telescopes.)
Robert Krulwich: Which Is Greater, The Number Of Sand Grains On Earth Or Stars In The Sky?
Comment: Nitpick: the observable universe has nothing to do with telescopes. Merely whether EMR emitted from the source after the recombination epoch has had sufficient time to reach Earth. Whether or not we can detect it is irrelevant (ironically enough.)
Comment: The number you've quoted is all the grains of sand ***on beaches***. Presumably the number of grains of sand in all the world (including under the sea) would be *dramatically* larger given that beaches and deserts represent less than a tiny fraction of the area of the ocean.
Comment: @Valorum Beaches and *deserts*. And doing some Googling, it seems the ocean floor is mostly rocky, not sandy. Only coastlines are sandy, and they were hopefull included in the calculation.
Comment: Since the calculations only use *visible* beaches, I'd imagine that the number is out by at least 100% even if you only account for the sand a few miles offshore.
Comment: How much sand is there in all the other places? ;-)
Comment: Fortunately, if you want to give them all an ID number, there are enough GUIDs for all the stars, all the grains, and plenty spare :)
Comment: @Valorum does the "tiny fraction" mean 0,01% ? because anything bigger than this means the stars still win.
Comment: The area where I live (around Berlin, Germany) is mostly sand under a small soil cover. It doesn't look like a desert at all. I guess this was not included in the count?
Comment: The statement in question has an implicit "common-man" assumption of only counting beaches and deserts. In a TV program, the presenter will hold up a handful of sand on a beach, not dig a hole in Berlin or dive to the bottom of a river or the ocean, for example. Plus there's a desire to not run into niggling issues of what the technical definition of "sand" is.
Comment: @corsiKa Good point. I was a little unsure myself about that.
Comment: @Mindwin - I don't know what methodology they've used to represent the area of all the beaches in the world. I do know that more than 71% of the entire globe is covered in water. Assuming that they've represented the beaches and deserts as 5% of the Earth's surface and assuming each cubic meter of water has 0.01% as much sand as a cubic meter of beach, it could easily be *hundreds of thousands of percents* out. I am, however no expert on sand suspension in sea water
Comment: Even if you double the number of grains of sand because of a 100% error it will still be much less than the 4 orders of magnitude more observable stars.


Is it possible to extract nitrogen from the air via a centrifuge

Question: I was thinking about how they have cans of compressed nitrogen for filling paint cans, and also that they sometimes will blow nitrogen in to food containers before sealing them, and that got me interested in extracting nitrogen for a nitrogen filled refrigerator. I read up on it and it appears the main way that nitrogen is extracted from the air now is via liquidification of the air and then relying on the different boiling points. I was curious why they didn't use something like a centrifuge to separate the nitrogen out. I'm guessing from what little I know of centrifuges use in nuclear refinement is that it's not energy efficient since the weights are not different enough to cause easy separation. But I was curious if that was the real reason, or if there were other forces that prevented a centrifuge from being used in this kind of gas separation.
Comment: Ultra-centrifuges are technologically hard and it would be a batch process. Fractional condensation is (relatively) easy and it is a continuous process. Money, money, money.
Answer: I am not sure it would be wise to use centrifuges to separate oxygen from nitrogen - my impression this is a method of last resort - you need something like that to separate isotopes, which have virtually identical properties. You can use the difference in properties of oxygen and nitrogen to separate them, for example, in the pressure swing adsorption method (http://en.wikipedia.org/wiki/Pressure_swing_adsorption ).
Answer: To answer Your question: yes, it is possible to extract nitrogen from the air via a centrifuge, or rather - it is possible to increase the concentration of nitrogen in a gas mixture, there are always going to be some impurities. Whether anybody does it? Probably not, since it's not the most efficient way, as it was noted. In nuclear applications it is used because the requirement is to separate two isotopes of the same chemical element, and since they have exactly the same chemical properties, the only way to separate them is to make use of the mass difference between them. Nitrogen and other air components differ in chemical properties, so probably it's cheaper to use chemical methods here.


Fragrant plants for nice smelling room?

Question: I want some nice smelling plants to improve the smell in my room. They should be functional year-round and low maintenance.
Comment: Plastic plant, bottle of clove oil.
Comment: Why does your room smell in the first place?
Answer: Lacking information on lighting, seasons, temperature, room size, and scents required, I'd suggest you just buy some Potpourri with a scent you like, and just renew it when the fragrance has gone.  Since the leaves are already dead, you won't need to maintain them apart from replacing them if they start to decompose.
Answer: Most plants that grow well indoors aren't especially fragrant, and there aren't any that would be fragrant year round. One option you might consider, though, are forced hyacinth bulbs. They are incredibly fragrant for a week or two, very pretty, and easy to care for once you've done the work of forcing them. If you can but forced hyacinth bulbs, they are no work at all.
To force the bulbs yourself, you basically need to refrigerate the bulbs for 12-14 weeks. After that time is passed, you can take them out and pot them up or put them in a forcing vase. If you put new bulbs in the fridge every 2 weeks and potted a new set up bulbs up every 2 weeks, you could hypothetically have a constant supply of hyacinth bulbs.
I'm not sure this would help much if you have an actual odor problem, but if you want to add a sweet smell to a room it would work.
Answer: Oat grass is easy to grow, and has a lovely grassy smell if you run your hands through it a few times.
Answer: What you've asked for is planting that scents the air year round, and that isn't possible, regardless of the growing environment in your room. For one thing, 'scented plants' can mean more than one thing - many have fragrant leaves, but the fragrance is only detectable if the leaves are bruised, brushed against or crushed. Then there are fragrant flowering plants, and although, for instance, indoor hyacinths, freesias, jasmine, stephanotis and some lily varieties may well scent the air whilst the flowers are present, the maximum amount of flowering time will be between 2-8 weeks, and only if the conditions are right.
I'm afraid you will have to find another way to deal with the problem.

Fragrant plants for nice smelling room?


Voltage dropping capacitor and small voltage transformer

Question: I want to make a mains voltage sensor for a power meter project. Since space is an issue, I looked for an alternative to a full size mains transformer. Is possible to use a voltage dropping capacitor to lower the mains voltage to about 12v and then feed it in a 1:1 small transformer for separation ?
Comment: You revealed no details of how your power meter project is powered. There is frequently a way to tap off a representative value of the mains voltage. But that depends on the design of your power supply. If you are using a switchmode power supply, it may be an advantage to use a vintage technology linear power supply with a transformer. Your question is difficult to answer as a generic question absent the context.
Comment: I am only asking about the measuring sensor circuit. The measuring is done with an Arduino chip that has a dedicated power supply. Normally I would have to use a mains transformer, a voltage divider and a shifter. I want to reduce the size of the mains transformer by using a voltage dropping capacitor in series with the primary coil of a 1:1 small separation transformer (2 coils of 1200turns, 24v in, 24v out). I never saw this done and I want to know if is possible or I just have to squeeze in a mains transformer.
Comment: A capacitor is NOT recommended if your goal is any kind of accuracy.  I would use a small power transformer from a discarded "wall wart" power supply.  Using anything not already rated for direct mains connection is too dangerous unless you had significantly more experience.  Blowing off the question about the Arduino power only limits your possible solutions.
Comment: I see. I will use then a mains transformer. Saw some very nice PCB mount ones that are a good compromise in size. One more question, if you can help me. Can I put 2 mains transformers close each other (let's say at about 5mm apart) ? I have 2 sensors inside the enclosure measuring 2 lines of 230v AC.
Comment: It is common to rotate one of the transformers 90 degrees to minimize magnetic coupling between them.
Answer: Not a legal or safe way to do that. Reason why is at 60HZ a .22uF capacitor will allow 10mA to flow into a short circuit, plus the capacitor needs to have a voltage rating 3 times the line voltage, and be a high quality Mylar film or polypropylene to be safe, but the voltage tracking will be very non-linear. So how do you know what load your smaller transformer is as a reactive circuit? (the capacitor in series with the transformer primary). The best and safest and legal way to do this is to buy a transformer rated for the line voltage with an output 1/10th to 1/20th the line voltage (if using 1/20th line value you can use a tiny thread of software to multiply the results x 2.).The transformer output is converted to DC peak value with a rectifier and capacitor. 70.7% of that value is your RMS value. Add a 10K 1 watt resistor across this capacitor to act as a minimal load, and to bleed off the charge if not in use. Use a 1 or 2 watt potentiometer to adjust the output so your AC volt-meter is tracking the line voltage fairly close. It will work ok over a 50% change in voltage, but at low line voltages both designs would start to become non-linear, with a reading lower then is actually on the AC line.NOTE: Seriously consider adding a properly rated fuse to the transformer primary, regardless of the design. If anything goes wrong, as in a short circuit or severe over current the fuse will pop and stop any chance of a fire.
Comment: I have proper capacitors and this circuit is intended only for measuring the mains (reduce the voltage to a lower value, shifted to have all values positive and fed in an Arduino analog pin). Thing is I never saw this before being done at small level. Only in HV transformers, using capacitive dividers. So, I better squeeze in a mains transformer ?
Comment: I re-wrote the first 4 paragraphs of my answer. Please read them.
Comment: @Mihai: Did you notice that the capacitive divider uses two capacitors so there is no phase shift. Capacitor - resistor or capacitor - transformer will cause phase shift. If you are trying to measure instantaneous voltage and current to calculate instantaneous power you need to avoid phase shift. In any case, pay attention to Sparky's comments about capacitor failure modes.
Answer: I have done this to convert a small 110 volt transformers to 240 volt. I selected the capasitor by trial and error. 0.1uf to 0.2 uf depending on the manufacturer of the transformer, there were two, same physical size. I checked the voltages, mains = 240 transformer = 110 capasitor = 300. Are we getting close to a resonant circuit? I measured the transformer inductance and plugged values into an online resonance calculator. 200Hz. This is a cheap and cheerful fix. I have never seen it used for a transformer.
Comment: Welcome to  EE.SE. Since the  question is about voltage  monitoring for a power .meter the phase shift introduced by the capacitor would be unacceptable.


Scheduling Calendar?

Question: I am trying to create a form that has pay-pal integration as well as a scheduling calendar. The calendar is what is really tripping me up. I want the user to select the date, and then a time, - but I only want certain days/times to be available, somewhat like a airline reservation calendar. Any ideas?
Answer: http://jsbin.com/imike/edit to block certain dates in jQuery datepicker. For more information I think more details are needed (as what server side scripting you want to use and how is the data stored)

Scheduling Calendar?


i have a question about a amplifier im working on

Question: the amp is a radioshack mpa250. I hooked it up, and took the top cover off to see how big the transformer and caps were. theres two 80v, 10000uf caps in there, with a 40.5v transformer... i checked the output of the transformer before the bridge rectifier, its reads 40v after the bridge rectifier it goes up to 110v... im not sure if im reading that, or even testing it right...
The main problem im having is that it seems the transformer and capacitors arnt big enough for the amp, im seeing voltage drops around 20 - 25v, and the lights dim, i guess you have to cut back somewhere (the amp was 180$) i was thinking about putting a bigger transformer inside http://www.antekinc.com/an-10440-1000va-40v-transformer/ (outputs around 10a rms) its 100$, i really think its worth it to do these simple upgrades, the amp has a good design and sounds nice. The transformer hum's loudly (yes its grounded the right way) i think its not strong enough... the caps are rated for 80v, and their pushing 110v dc into them... thats a big problem... i think this amp is starving for power, once these upgrades happen i think its gonna really shine. that is some backround info, but my question is how big of a cap can i put inside there, i mean the peak current draw from that transformer is probably 20a...and the new bridge rectifier i have is good for 25a or so... i just want to know if i could fit a farad cap in there, or something alittle smaller... please get backk to meh, i wanna see this amp work at its ability!! thx in advance.
Comment: Do you have a comprehensive circuit diagram of this module? Precisely what are you powering it from? What load do you have connected? Do you know that starting a sentence with a capital letter is nice? What measurement tools are you using? Why are you trying to fix this device?
Answer: I'm not sure if there's a question in there anywhere, but here are a few points of explanation:

The voltage rating on the transformer is an RMS value. 40 VRMS corresponds to a rectified peak value of about 55 VDC.
The two filter caps are in series, with 55 V across each one, or a total of 110 V across the pair. This is fine.
The amplifier is rated at 125 W (per channel) into 8Ω and 175 W into 4Ω. This implies that the output voltage is at most 31.6 VRMS and the maximum current is 6.61 ARMS.
That means that the power supply must be able to deliver at least ±50 V (peak) to the output stage, at an average current of 13.2 A, 18.7 A peak.

If you're seeing the DC bus voltage drop from 110 V to 85-90 V, then yes, the power supply may be a bit undersized. But if you beef it up, the output devices may not actually be able to handle the extra power, and they'll overheat and fail. Keep an eye on the heatsink temperature!


Energy and its physical significance

Question:
What does it exactly mean when we say that energy has moved from one body to another, what has physically been transferred? The concept of energy is very confusing, please help.
And if gravitational potential energy is stored in a body, does the body's mass increase according to $E=mc^2$?
Comment: Related: [How can energy be useful when it is 'abstract'?](http://physics.stackexchange.com/q/138972/50583)
Answer: Energy is not a physical property. It is an abstract mathematical quantity that turns out to be very useful to calculate because it tells you important information about the state of the system. There are many kinds of energies associated with motion (kinetic energy), position (potential energy), mass ($E=mc^2$), and others. When physicists speak of transferring energy from one system to another, it is shorthand for talking about some physical processes changing the state of two systems. In many interacting systems, Newton's Third Law states that interactions have opposite effects on the two systems: one speeds up, the other slows down. The overall effect is to keep the total energy associated with motion constant. In fact, physicist often choose a definition for energy so that it stays constant to make calculations easier. Different kinds of energy can be converted into others as well.
As an analogy, think of profit in business. I buy a car for \$5,000 and sell it for \$7,000. My profit is \$2,000. But, where was the amount of \$2,000 ever involved in the transactions? It wasn't. Profit is an abstract quantity of money that is useful to calculate since it tells you important information about the state of your business.
As for mass changing with energy, this is a subtle question. A moving object does not gain mass from kinetic energy. Heating an object does. You can think of mass as the total energy of a system as measured by an observer that is not moving with respect to that object. If the object is moving, the energy due to motion has to be subtracted away to get the mass.
Comment: if "energy is not a physical property", could you juxtapose that with *quantities* that **are** physical properties?  is mass a physical property?  is speed a physical property?  or momentum?  or the fundamentals like time, length/position, mass, charge?
Comment: I like the analogy with monetary transactions, kind of solidifies it in a concrete matter
Comment: The questions says `if gravitational potential energy is stored in a body` but GPE is **not** stored in a body. Hopefully you answer can point out that GPE is a property of a system and how far apart the masses are **from each other** and that it isn't stored in any particular body.
Comment: basically the concept of energy is confusing because in all other cases like velocity or mass i can see and clearly imagine whatever changes happen but when somebody says energy got transferred from one body to another what do i imagine is being transferred ?
Answer: What is energy?
I'm going to start by using a very basic understanding of energy (one suitable for a first year course):

Energy is any property of an object or system that allows it to do work.

Here "work" is used in the sense of force applied over a distance: $\mathrm{d}W = \vec{F} \cdot \mathrm{d}\vec{s}$.
What kinds of properties would qualify this way?
Well, a moving object could (it things were arranged right) ram into a nail and drive it into a wall. As that requires force applied over a distance work is done and the moving object loses speed as it drive the nail---the energy of motion (kinetic energy) gets turned into work, and the slower object now has less ability to do work.
A heavy mass at the top of a funicular can lift what every is placed on the other side, work done by virtue of position in a gravitational field. Gravitational potential energy is traded from one object to another. Note that the counter weight of the funicular doesn't "contain" the energy on it's own, rather the combination of the weight and the planet has the ability to do work (if you take the funicular into deep space it won't lift anymore, because the Earth was an necessary part of the system) so it is the system that "has" the energy.
A stretched or compressed spring contains energy (elastic potential energy), as does a confined sample of hot gas (thermal energy), or a gallon of kerosene (chemical energy), or a ton of uranium ore (nuclear energy).
Caveats
Some of the other posters have offered more sophisticated definitions of energy, but they agree with the one I have given here when put into a simple mechanical context. On the other hand you can't get to a Noetherian conception of energy from the definition I have given here without a leap of intuition.
Also thermodynamics tells us that energy can exist in forms where it's "ability to do work" is effectively neutralized by existing in a high entropy arrangement.
Energy and Mass

"if gravitational potential energy is stored in a body, does the body's mass increase according to $E=mc^2$?"

Again, it's not in a singular object but in the arrangement of objects in a system, but yes if you act on the system as a whole it's mass is different from the sum of the masses of the parts by the potential energy. (But there is a twist here, for gravitation that energy difference is negative because you test the mass of each of the parts at infinite remove.)
But do compute the energy difference between you and the planet at infinite remove and and with you on the surface, then convert that to a mass difference. It is surprisingly small. On the other hand, nuclear fission and fusion convert measurable fraction of the starting mass to forms of energy we can (in principle) use, and the very protons and neutrons of your atoms are more binding energy than mass of their parts.
Answer: Energy is a usefull quantity that can be measured.It is conserved in a closed system to.
There are equations of motion which are given in terms of energy, called Euler-Lagrange equations. It is simply an observation that interacting systems effect each other in such a way as to transfer energy from one to another, and we can observe that exact amount lost in one system equals amount gained in other. Two basic forms of energy are kinetic and potential and every other energy, like electric or thermal, are basicly these two basic ones.So, it is the energy in motion, kinetic, and the energy of a body at rest in some potential/force field. It is simply a kinetic energy that the body will certainly aquire if we let it move, like water falling down the clif. Formula for kinetic energy is:
E=0.5mxv^2
This quantity has all of these nice properties I just described. So to really know the energy, you have to observe it in its natural environment, equations of motion in physics. Then it gets clearer and clearer.
Answer: For most everyday purposes, E = mc² is largely irrelevant.
Consider 1 litre of water at 0°C.  This weighs approximately 1Kg.
If we heat it to 100°C, then we have added 418600J of energy (the specific heat capacity of water is 4186J/Kg°C).  Applying m = E/c², we find that we have made the water 418600/(300000000²) = 0.0000000000047Kg heavier.
Comment: @RomanOdaisky, $mv^2/2$ is just the classical kinetic energy. When you made the mathematical approximation, you basically neglected the relativistic effects so I wouldn't consider your example as a low-speed relativist effect.
Comment: Not quite irrelevant, surprisingly many low-speed relativistic effects occur in real life. For example, you kick a ball of mass $m$ to speed $v$, now due to it being in another frame of reference you see its mass as having relativistically increased to $\gamma m = \left(1-v^2/c^2\right)^{(-1/2)}m$, and the difference in energy is $(\gamma-1)mc^2 \approx ((1-(-1/2)(v/c)^2)-1)mc^2=mv^2/2$ for small $v$. Or https://www.youtube.com/watch?v=1TKSfAkWWN0.
Answer: energy can be seen as something that may change the state of a system. you can use energy to move a stone from point A to point B. to do that you need to apply a force (some forces can be related to the gradient of a potential). in the case of the gravitational potential, the related force is the gravitational force. therefore the gravitational potential energy is the energy that can change the state of a stone. if it's a a point A, say at a hight $h$, it will have a potential energy $mgh$. This energy may be "released" to change the state of the stone from being static to being in a free fall state.
when we say that energy is transfered or exchanged, we mean that the energy doesn't disappear. in the case of the free falling stone, the potential energy is transformed into a kinetic energy. the stone still has the same energy but its "nature" has changed (the kinetic energy isn't related to the gradient of some force).
when the stone hits the ground, the energy is transferred to the surrounding (meaning the earth) by making some noise, heating or deforming the impact area... if the stone falls on a trampoline, the kinetic energy of the stone goes into the potential energy of the trampoline (by elastically deforming it).
this is not to be confused with $E=mc^2$. very roughly, what this formula says is that mass is energy.
Answer:
I) What does it exactly mean when we say that energy has moved from
  one body to another, what has physically been transferred?

Contrary to the view expressed above by Mark H < https://physics.stackexchange.com/a/217505/76263 >, I think energy is a fundamental physical property and not just "an abstract [useful] mathematical quantity".
In fact, the energy of a system and how it varies, yields the physical behaviour of the system in terms of a set of states. Of course, physicists make the concept of energy and its change quantitative by an abstract mathematical formulation. Usually, having a quantitative form of the energy plus some evolution equation ('equation of motion') will provide a complete physical description of a system in terms of a set of physical states which are appropriate for the system in consideration.
The "transfer of energy" from a body/system to another is the most fundamental way we can describe a physical process. This leads to the change of the state of the body/system. As an example, the process of heating of water can be described as transfer of "thermal energy" from the heater to the water.
You can find a very nice intuitive picture in "The Feynman Lectures on Physics", volume I, section 4-1. I cannot do better.

II) If gravitational potential energy is stored in a body, does the
  body's mass increase according to E=mc2?

This question is rather vague, if not ill-posed.
First, let's assume that we confine ourselves to the special relativity  (where the famous formula, $E = m c^2$, comes from), and treat the gravitational energy as any other energy – the gravitational force is in fact very subtle.
Having this in mind, one has to distinguish properly between two types of mass (at least):
Firstly, a massive body has a 'rest mass' $m_0$ defined as the body's mass as seen by a stationary observer in the reference frame of the body. This is an invariant property of the object.
Secondly, there is a 'relativistic mass' defined as
$$ m_{relativistic} = \frac{m_{rest}}{\sqrt{1 - v^2/c^2}} $$
that is higher compared to the rest mass, from the viewpoint of an stationary observer which is moving relative to the frame of reference of the body. This concept of 'relativistic mass' is rather obsolete, since usually one prefers to ascribe an invariant mass to a physical body.
For a more detailed explanation, see this post: < What's the difference between the five masses: inertial mass, gravitational mass, rest mass, invariant mass and relativistic mass? >.
Within the limits of the discussion above (special relativity + Newtonian gravity), the gravitational energy of a body would be a contribution to the rest mass only.

Energy and its physical significance


how to get tax amount of a product in success page?

Question: I want to get tax amount of a product in success page. I'm getting price of a product but not tax amount from order object. can anyone please help me on this. Thanks
Answer: Try this:
<code>echo Mage::helper('checkout')->getQuote()->getShippingAddress()->getData('tax_amount')
</code>
in your checkout success page.
Hope this helps.
update
<code>$orderId = $this->getOrderId();

$items = Mage::getResourceModel('sales/order_item_collection')->load($orderId);
foreach($items as $item){
   echo '<pre>'.$item->getName() . ' ' . $item->getTaxAmount().'<pre>';
}
</code>
Note: I haven't tested it but should work.
Comment: I don't want total amount of the order. I want the individual product tax amount. Thanks
Comment: Check my updated answer.
Comment: why does magento make you go through shipping address in order to get the tax amount. isn't this terrible api design and violation of all kinds of code design principles?


launch database mirroring monitor grayed out in SQL server 2014

Question: I have 2 servers configured with mirroring each other. Both the servers are principal & Mirror servers each other. From the 2nd Server launch database mirroring monitor is working fine but from 1st server launch database mirroring monitor is showing grayed out. Both server services are running with the same administrator account. The below screenshot is for 1st server. Can you please help me how to enable this launch database mirroring option in SQL server 2014 ?

Comment: No. Currently we have SQL server 2014 SSMS version is 12.0.6024.0 was there. I have not updated to latest version.
Comment: Might try to get 18.3 and see if your problem is resolved. You can both versions side by side.
Comment: But in one server it was working fine from another server we are facing this issue. Both servers have same configurations and same versions of SSMS. So can you please explain me why it was happening for 1 server only ?
Answer: Had the same problem - turns out if the first DB in the list is in restoring (mirroring) state that server will have this issue.  Solved it by adding an empty DB "aaa" as the first DB in the list.


"certains / des / quelque / quelques-uns / pas mal de" What does it all mean and in what situations it is used?

Question: I looked up the word "some" from the translation and I saw these. Des (à+l) the only thing I know, des (de+les) which is indefinite version of les. But what about others? I've never heard of these.
Answer: Certains means some people or a few: "Certains anglais parlent Français" may translates to "Some english people speak French". Without the s, it indicates when someone is sure about something "J'en suis certain qu'il est fort" translates to " I am sure that he is strong".
Quelque is similar to certains but is generally more vague like Je possède quelques livres translates I own a few books.
Quelques-uns which is the plural form of quelqu'un meaning someone.
Pas mal de means a fair amount like Je suis allé au match et il y avait pas mal de gens translated to I went to see the game and there was a fair amount of people.
Answer: All can translate to "some" but often with nuances:

Certains means "some" as a subset of a group.
Certains ne sont pas venus. → Some didn't show up.

Des is the plural of un, some as "more than one".
Des garçons jouent. → Some boys are playing

Quelque is a singular "some", often like "any". It is literary except in some fixed expressions like quelque chose (something/anything), quelque part (somewhere), quelqu'un (someone/anyone).

C'est une chose admirable, que tous les grands hommes ont toujours du caprice, quelque petit grain de folie mêlé à leur science, Molière, Le médecin malgré lui.

It is an admirable thing, that all great men always have whims, some small touch of madness mixed with their wisdom.

Quelques means some like "a few", "a couple", "a handful".
Je reviens dans quelques jours. → I'll be back in a few days.

Quelques-uns means some like "some of them", it is close to certains. Note that quelques-uns can refer to people, things or whatever and has a regular feminine form (quelques-unes) while quelqu'un is necessarily a person and is very rarely used at the feminine (quelqu'une).
Il y en a quelques-unes de cachées → Some of them are hidden.

Pas mal de is a "bigger some" like "quite a bit", "quite a lot".
J'ai raté pas mal de choses. → I missed quite a lot of things.


Why VS2010 don't save toolbar

Question: I'm using VS2010 every day, and haven't noticed it before. There is too many toolbars added with third party addons and ms apps.
 Once I revome them by right click - customize everything seems pretty, but every time VS is restarted everything goes back.
 Why VS doesn't save this setting?
Answer: Again, self answer.
First step - check if you ran VS as administrator.
Second step - reset you local setting and try to repeat procedure(again under Administrator rights).
Answer: I had the same problem. I'm running VS2010 as administrator and close the toolbars and exit VS. The next time I start VS (as Administrator) it shows all the toolbars again.
I resolved this by closing one toolbar then exiting VS. Then opening VS again and closing one more and closing VS again. Repeat until all the toollbars you want closed are gone. There seems to be a bug in VS2010 SP1 where toolbar changes get lost if more than one change is made.

Why VS2010 don't save toolbar


Are there any good dictionaries for Ancient Greek?

Question: I do realize this question might be difficult to answer as most words in Ancient Greek are hard to translate, and some have whole studies around them. But as there isn't a stack exchange for Ancient Greek, I figured this would be the best place to ask. I wonder if anyone have made an entire work around it, even if not a dictionary. Just some sort of guide to Greek vocabulary somehow.
Comment: There is Greek/Ancient Greek stack exchange being prepared here: http://area51.stackexchange.com/proposals/101509/greek-language You can upvote questions you like.
Comment: What makes a dictionary "good" for you? Do you want a Greek/English dictionary? Or a Greek-only dictionary? Online? In print? Does it need to be exhaustive? How complex or technical should it be?  Please narrow this down a bit, so we can get this question re-opened ASAP.
Answer: There are quite a few - and they're not really hard to come by.
This answer cannot be an exhaustive survey of the Greek dictionary landscape, however it can get you started and past your first learning assignments.
First and foremost, consider the Liddell Scott Jones, which is GRE-ENG and a major authority. It's available in most Classics Libraries and has been digitalised by Tufts University, now going by the name of "Greek Word Study Tool".
There are also smaller Paperback dictionaries by OUP, and some by Collins.
Pupils and Undergrads in Germany often use the "Gemoll" GRE-GER dictionary, while there are a host of other offers, including specialist publications for theologians reading biblical texts in ancient Greek. Again, try the departmental library, they can help.

EDIT 27 Mar 2017:

Digitised copy of A Greek-English Lexicon by H. G. Liddell and R. Scott to view on-screen and download at archive.org.
Online searchable Greek Dictionary in the Perseus Digital Library.
Gemoll: ISBN 978-3-637-00234-0, price tag now around 50 Euros, get one at your local library until you're really sure that Greek is for you (and there are good reasons that you might come to like it). Or have a look at antiquarian books instead.

Online: Griechisches-deutsches Schul- und Handwörterbuch - Dr. Wilhelm Gemoll (1908).

Again, try searching your university OPAC or talking to faculty/library staff.
Comment: Can you please expand the answer with more specific references (hyperlinks, ISBN, etc.)? And welcome to Language Learning.SE! :)


can not hear playback sounds ( asterisk )

Question: I'm running asterisk 14.2.1 on ubuntu 16.04 in a VirtualBox with 1g ram, 1.7 ghz and bridged adapter for networking.
when I use a softphone installed the host machine to call an extension which playback a gsm sound file everything works and I see an msg indication that the sound is playing but I don't hear it on the phone (it work once from time to time).
if you may help thanks.
Answer: You don't provide quite enough info - what do you mean you see a 'msg indication' that a sound is playing?  Can you play other sounds (eg: speaker-test) succesfully and hear the audio?
If no this is an audio in VM question.  If yes, then this is likely softphone related.  If the user agent (softphone) is on the PBX then likely not a connectivity issue.  Have you disabled the firewall on the PBX for testing?
Comment: I meant a msg in the asterisk CLI ...anyway I appreciate your help but it was a problem in the softphone after all :)


Can anyone help me to get the current category in my view.phtml?

Question: I'm using Magento 1.9. I would like to get the current category of products in app/design/frontend/xxxx/xxxx/template/catalog/layer/view.phtml file.
I've already tried Mage::registry('current_category') and Mage::getSingleton('catalog/layer')->getCurrentCategory() for getting current category. I'm not getting any results from that. thanks in advance
Answer: Current Category's ID
<?php echo Mage::registry('current_category')->getId();?>

Current Category's Name
<?php echo Mage::registry('current_category')->getName();?>

Current Category's Parent's Id
<?php echo Mage::registry('current_category')->getParentId();?>

Comment: Glad to be of service. You could accept and upvote if you please
Answer: <?php
     $currentCat = Mage::registry('current_category');
     if (isset($currentCat) ) {
         $exp = explode("/", $currentCat->getPath());
     } else {
         $exp = explode("/", '/1/0/10');
     }
 ?>

then example if you want to use it in body class for css modifications design:
<body class="cat-<?php echo $exp[2];?>

Comment: thank you..I tried your code, but i'm always getting the value "0" from $exp[2] for all categories
Comment: did you try modifying the number, example [1] ? im sharing you a code Im using. in this case, exp[2] displays the subcategory 2, eg: root_catalog/computers
Comment: and if you echo   only?
Comment: yes i tried all those. its only executing the else part and giving results like 1 or 0. Also tried echoing $currentCat = Mage::registry('current_category'); and nothing come up
Answer: you can get the category id from product name or id by loading model of product.

    $catCollection = $_product->getCategoryCollection();
    foreach($catCollection as $cat){
      print_r($cat->getData());
      //echo $cat->getName();
      //echo $cat->getUrl();
    }
Another Way,$_product= Mage::getModel('catalog/product');
$catIds = $_product->getCategoryIds();After that you can get the categories by accessing $catIds array such as $catIds[0], $catIds[1] etc.


AC slow leak - accumulator 1 year old replace or keep using to find leak?

Question: Hello everyone newbie here very helpful info listed thank you.  Last year disassembled and flushed AC system, new compressor, orifice tube, accumulator. Vacuum could not hold very slow leak.  Couldn't find leak with sniffer or UV dye.  Recharged AC had great air and took to mechanic and they vacuumed and recharged did not find leak. Had good AC all summer.   Stored winter. This spring no air.  Should I refill AC using old accumulator and drive to get UV dye to leak out - how long? Will it harm system with old accumulator running? Don't want to kill compressor. Trying to be a DIY and save cash. New mechanic?  These guys are honest and very fair. Trying to understand AC but leak is driving me nuts! Great car. Please help.
Answer: You'd have to weigh the cost(s) and make your own decision.
New compressor rules out shaft seal, which was my first guess.  But technically, a new compressor always commands a new receiver-dryer.  There are some specially treated PAG oils that can help small leaks, but require at least a partial charge to inject.  If it's a new "accumulator" as you call it, it should be fine to continue running it.  but I would certainly double check every connection you had to loosen in order to replace those components.
Also, did you sniff of examine the valve cores on both high and low fittings?  Another notorious spot for the "impossible-to-find" small leak.
And no matter how silly it sounds, try your UV search at night.  (One neighbor is still quite suspicious of me, albiet this practice admittedly not the only reason...)
Comment: You lost the entire charge - probably 1500 to 3000 grams over the winter, so a mere 7g/year leak rate is two magnitudes more sensitive than you would need in theory.  Leave the old UV dye in there; it's hurting nothing.  Both UV and sniffer have their value.  I prefer the UV because it's beyond denial, and simple even when operating.  Sniffers sometimes are difficult to get in a zone of detection, and the air needs to be very still as well - no wind or overhead fans.  Good luck; patience and diligence will be your weapons.
Comment: "Brake clean" (the illegal in CA/NJ) CRC red can.  Ever-nifty Tetrachloroethylene, which also kills bugs, rodents, and most humans.  Instantly flashes to toxic vapor; added benefit of creating phosgene style chemical weapon if exposed to UV welding radiation. Four decades using chlorinated brake cleaner explains some, but not all, of my strange behavior.  Seriously, anything that surfacts a PAG oil (which transports dye) like a simple detergent should work.  Besides, you can just leave it.  I thought the issue is you aren't seeing any UV dye traces, and now you worry about how to wash it off??
Comment: Thank you Steve.  I am learning to use the CPS Refrigerant Leak Detector - LS790B and will recheck the system again. They claim this leak detector is calibrated to detect a leak rate of better than 0.25 oz/yr (7g/yr) of HFC.  Is that sensitive enough to detect very slow leaks?     What do you use to clean old UV dye from system to recheck for leaks? Should I charge AC to max and drive to force UV dye to show?  What do consider the most effective for leak detection, UV dye or Sniffer?  I will do a UV search at night, great idea.  Sorry for all the questions but I **AM** going to find this leak!
Comment: Sorry, didn't word correctly about UV dye. I meant to say how do you clean residue UV dye traces on outside fittings and parts from previous leaks so that you can start fresh for inspection?  What removes and dissolves it best to wipe it off everything?
Comment: Hi Steve.   Cleaned up previous UV dye from old rebuilt compressor that leaked using detergent.  Used new UV light that is more powerful. I found the leak at the new compressor. One of the transducer pressure switches (correct name for switch?) is leaking around the port.  Going to try replacing O ring with compressor on car.   I have strange behavior too like crawling around under a car trying to fix something that probably should have gone to a professional in the first place. I played in lead gasoline as a kid cleaning bikes and later cars plus everything else.  Talk about toxic.
Comment: Hello Steve   Just wanted to thank you for your greatest advice "patience and diligence will be your weapon" and will use it for everything.  I found two leaks on the compressor: pressure switch and relief valve -  easily fixed - awful to take off to do it.  Anyways, vacuumed and charged a small amount of refrigerant and it has held for two days.  Hard to learn AC online without instructor in person.  Almost lost the patience!  Take it to someone don't learn nothing.   LOL!    Thanks again and have a great summer with Cold Air Steve.    Yahoo!!!!!!!!!!!!!!


(C++) Getting error "Illegal instruction (core dumped)" upon bitwise OR operation

Question: So, I'm still learning about bitwise operations and can't figure out why this error is happening. I've googled it and it appears that this error can happen when messing with the stack, or, in some cases, it has to do with CPU architecture. I've tried compiling with different flags that were supposed to help but I can't get it to work.
Here's the the code quickly:
int corners = 0;
for (int i = 0; i < 8; i++)
{
    const ivec3 cornerPos = leaf->min + CHILD_MIN_OFFSETS[i];
    const float density = Density_Func(vec3(cornerPos));
    const int material = density < 0.f ? MATERIAL_SOLID : MATERIAL_AIR;
    corners |= (material << i);
}

And the error "Illegal instruction (core dumped)" is happening at the line
corners |= (material << i);
Here's the output from the debugger:
Signal received: SIGILL (Illegal instruction) For program, pid 26,118

I'm going to give the output of this loop (it never makes it past the first loop).
Here's the code for the couts:
int corners = 0;
    std::cout<<"corners(outside loop): "<<corners<<std::endl;

for (int i = 0; i < 8; i++)
{
    const ivec3 cornerPos = leaf->min + CHILD_MIN_OFFSETS[i];
            std::cout<<"cornerPos.x: "<<cornerPos.x<<std::endl;
            std::cout<<"cornerPos.y: "<<cornerPos.y<<std::endl;
            std::cout<<"cornerPos.z: "<<cornerPos.z<<std::endl;

    const float density = Density_Func(vec3(cornerPos));
            std::cout<<"density: "<<density<<std::endl;

    const int material = density < 0.f ? MATERIAL_SOLID : MATERIAL_AIR;
            std::cout<<"material: "<<material<<std::endl;

            std::cout<<"MATERIAL_SOLID: "<<MATERIAL_SOLID<<std::endl;
            std::cout<<"MATERIAL_AIR: "<<MATERIAL_AIR<<std::endl;
            std::cout<<"i: "<<i<<std::endl;

    corners |= (material << i);
            std::cout<<"corners(inside loop): "<<corners<<std::endl;
}

and here's the output:
[corners(outside loop): 0] [cornerPos.x: -32] [cornerPos.y: -32] [cornerPos.z: -32] [density: -30] [material: 1] [MATERIAL_SOLID: 1] [MATERIAL_AIR: 0] [i: 0]

I would greatly appreciate any insight someone can give me about why this is happening, and if there is a clear reason, how to go about fixing the problem.
Thank you!
Comment: What is your platform (compiler versikon, OS, IDE)? Could you provide a [MCVE]?
Comment: It's unusual for a run time to have problems in a bitwise OR operation. Try to reduce the problem down to a [mcve] and post it.
Comment: Also try to replace the call to `Density_Func(vec3(cornerPos));` by somme dummy constant, just to see if the crashe still happens if `Density_Func` is not called.
Comment: Have you ever tried to use a debugger? Is it really an illegal instruction emmited by the compiler or simply a illegal pointer access or stack problem? Your code contains so much functions which can do things we do not see. So lease provide a short example! I believe by doing this exercise your problem can be found by yourself...
Comment: sometimes this could happen if you have a function that is supposed to return a value like (bool func()), but doesn't. It may crash at the beginning of the function and tell you Sigill. This seems to be seen only with clang+llvm, gcc doesn't seem to show this.
Answer: "Illegal instruction" means that CPU was trying to execute instruction which does not understand. This may happen if you compile your program with instruction set which is not supported by your CPU. Crash in this place may suggest that BMI2 bit shift instruction was used (it is supported on CPUs which supports also AVX2). Please check your compilation options.
Another possibility is that your program has overwritten some of its code. It is located at different memory area than stack, so things would be really messed up. I suspect this is not the case here.
This potentially can be also caused by overheating or some CPU bug, but these causes most probably can be excluded here too. The same for possible bug in compiler.


Can I move a directory with open files?

Question: Imagine a bunch of processes using a <code>/home/user/logs</code> directory. They have some logs open for a longer time.
Answer: Yes, under certain conditions. The inodes of the files won't change if you move their parent directory, so the open file handles will still be valid. The conditions are:

You don't move the directory across filesystems. That'd change the inode numbers of the files, of course.
The processes actually do keep the files open, and don't close them on occasion (if so, you'll have to reconfigure the applications to make them aware of the new parent directory)
You're using ext2/3/4 or one of the various versions of ufs out there. I can't honestly speak about other fileystems because I'm not sure how they're organised internally.
Comment: This is true for any filesystem and for any unix variant (except for executables on some unix variants). The open file is tied to an inode, not to the name of the file, and it doesn't matter if the file is renamed or even deleted.
Comment: That's true in-core, but out-of-core, the filesystem's structures and operations reign supreme. And Linux can talk to a whole sleuth of weird filesystems. I just don't like making generalisations — I've seen too many weird things for that. There *could*, conceivably, exist an exotic filesystem which (for reasons unknown) creates new inodes when a file is moved across directories. Perhaps because the inode paradigm doesn't map cleanly to that filesystem. There are always degrees of freedom, so I have to talk about what I'm sure about.
Answer: Processes usually do not keep files open in logs for long.
Yes, you can move / delete any directory or file which is in use by any process at any time. Heck, you can delete the process' executable while it is running and it will continue to run.
However, prepare for some possible scenarios:

when processes will reopen for writing log files they will recreate them.
processes will continue to write to the old location not the new one
if you delete the executable of a process, you will not be able to start it again

Files will be physically cleared on delete when no process will use their descriptors. You will see the files moved / deleted immediately.

Can I move a directory with open files?


What is the fundamental difference between a cavity and plasmonic cavity?

Question: In the process of exploring plasmonic systems I have quite often come across the description of cavities as Plasmonic cavities. What is  the exact difference between a normal cavity and a plasmonic cavity? Are they both the same? Or is the physics of these two systems quite different?
Comment: Can you provide more context?  On the surface, I would say that a plasmonic cavity is a resonant structure containing a plasma.   By "normal" I presume is meant a resonant structure containing a vacuum.
Answer: As pointed out by @garyp, there is not enough context. I will take a guess. I think you are talking about light-matter interactions in the presence of certain metals such as gold/silver/aluminium. The point being that small, sub-wavelength, particles out of these metals can display resonant response. Hence the 'cavity'.
If I am correct, then the answer is no, there is nothing special. Plasmonic cavity is like any other resonant system. What is sometimes important is that in case of plasmonic systems, the electromagnetic field 'sits outside', i.e. it is mostly in air not in metal, which makes these cavitities good for sensing and altering the local density of states (Purcell effect)