What does set -e mean in a bash script?

From help set : But it’s considered bad practice by some (bash FAQ and irc freenode #bash FAQ authors). It’s recommended to use: to run do_something function when errors occur. See http://mywiki.wooledge.org/BashFAQ/105

Printf width specifier to maintain precision of floating-point value

I recommend @Jens Gustedt hexadecimal solution: use %a. OP wants “print with maximum precision (or at least to the most significant decimal)”. A simple example would be to print one seventh as in: But let’s dig deeper … Mathematically, the answer is “0.142857 142857 142857 …”, but we are using finite precision floating point numbers. … Read more

How do I make Emacs auto-indent my C code?

Have a look at emacswiki – autoindent As suggested there, put following code in your .emacs You can customize the variable C Default Styl. In your emacs go to Options->Customize Emacs->Specific Option, then type c-default-style and set to your choice. By doing this, you don’t need to hit TAB. Type from start of the line … Read more

“vector” was not declared in this scope

You’ve got the declaration in the cpp file and the definition in the header, it should really be the other way round. After you’ve swapped the files round remove using namespace std; from functia.h as it’s not good practice to pull in namespaces in header files. You’ll need to change the declaration to void fun(std::vector<double> … Read more

What is %0|%0 and how does it work?

This is the Windows version of a fork bomb. %0 is the name of the currently executing batch file. A batch file that contains just this line: Is going to recursively execute itself forever, quickly creating many processes and slowing the system down. This is not a bug in windows, it is just a very … Read more

matrix by matrix in R markdown

Three minor corrections should be sufficient to make this work for both, HTML and PDF output: remove the backslash before the closing bracket in \right\) delete the empty line in the middle specify the column alignment in each array environment, e.g., with \begin{array}{cc} –

Stable Cotangent

cot(x) = cos(x)/sin(x) should be more numerically stable close to π/2 than cot(x) = 1/tan(x). You can implement that efficiently using sincos on platforms that have it. Another possibility is cot(x) = tan(M_PI_2 – x). This should be faster than the above (even if sincos is available), but it may also be less accurate, because … Read more