What I am looking for is a math function that constrains a primitive variable between a minimum and a maximum value in only one single function call, if it exists, in the standard math libraries for Objective-C.  I currently use:  float constrainedValue = fminf( maxValue, fmaxf( minValue, inValue ) );   Since I know that both fminf and fmaxf could potentially have instruction jumps or branches, it seems likely there could be a simple routine that could conjoin both of these operations into one, optimized function.
Is there a more efficient way to clamp real numbers than using if statements or ternary operators? I want to do this both for doubles and for a 32-bit fixpoint implementation (16.16). I'm not asking for code that can handle both cases; they will be handled in separate functions.  Obviously, I can do something like:  double clampedA; double a = calculate(); clampedA = a &gt; MY_MAX ? MY_MAX : a; clampedA = a &lt; MY_MIN ? MY_MIN : a;   or  double a = calculate(); double clampedA = a; if(clampedA &gt; MY_MAX)     clampedA = MY_MAX; else if(clampedA &lt; MY_MIN)     clampedA = MY_MIN;   The fixpoint version would use functions/macros for comparisons.  This is done in a performance-critical part of the code, so I'm looking for an as efficient way to do it as possible (which I suspect would involve bit-manipulation)   EDIT: It has to be standard/portable C, platform-specific functionality is not of any interest here. Also, MY_MIN and MY_MAX are the same type as the value I want clamped (doubles in the examples above).
I have an image with a woman, and I need to make an ad (size 260mmx125mm). I want to put the woman to the left side, but then right side becomes empty. So, how I should solve the problem? I have picked the color from image, but it is definitely different than in the actual picture.  Should I use the Clone Stamp Tool in Photoshop, or there is a better way to do this?  By the way, it will be used in print, so I need a good quality. Let $m \in \mathbb{Z^+} , n \in \mathbb{Z^+}$ and let $d=\gcd(m,n)$. Prove that $m\mathbb{Z}+n\mathbb{Z}=d\mathbb{Z}$ Android: Making Https Request I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different properties based on whether I am on a Windows or Unix platform). What is the safest way to do this with 100% reliability? I can't play Pokemon GO! What's wrong? Pokemon GO isn't working at all for me right now. I'm in one of the following circumstances and can't do anything:   My game is displaying a "Try Again" message I'm stuck on the Loading Screen When I sign in I get a message that the servers are experiencing problems. I see the map but nothing is loaded, and my team color is wrong The "loading" Pokeball just ends up spinning and I can't catch or interact with things When I try to catch a Pokemon, the Pokeball just sits on my screen doing nothing Gym opponents will drop to 1 HP and won't take any more damage or attack When I open a pokestop, the pokestop image and the name of the pokestop does not load.   What's causing this? Is there a way to fix it? I need to compile between two and four times before I see changes I make in the editor (TeXstudio) and each time I compile, a new .tex file is created with random letters and numbers at the end.   For example, If I create the file hello.tex and compile two to four times I'll get the file,   hello.tex.QU6664      then I make some small changes in the editor and compile two to four times I'll get the additional file,   hello.tex.Ak6664   After continuing to do this (each time compiling between two to four times before I see the changes I made), I now have many files that look like  hello.tex.QU6664, hello.tex.Ak6664, hello.tex.YX6664, hello.tex.sN6664, hello.tex.Ss6664, ...   A little bit of additional information (in case it's relevant): Everything was working fine up until a few days ago, i.e. only needed to compile once and only the file hello.tex was created. I still only get one .aux,  .synctex and .pdf files. I use TeXstudio to write and compile. I don't think it has anything to do with the bibliography (I tried removing bibliography altogether and still having the same problem).  How do I prevent these additional files from appearing and only compiling once like I used to? Has anyone had a similar problem? There are many times when I curse the autocorrection mechanism for changing what I typed, but overall, much of the corrections are welcome so I don't really want to disable it. I do want to have it do it's work but alert me when it makes each change so I don't have to proofread everything or focus with perfect attention to the screen to see the momentary red and/or blue underlining that alerts me to the machine override.  I would love a way to turn on an audible beep (customizable of course) so that I also get a warning each time my typing gets corrected (and only when autocorrection occurs). phpmyadmin not working due to missing extensions I am about to use phpmyadmin on Ubuntu 16.04. But it shows that the page is not working. the error log says error 500   PHP Fatal error:  require_once(): Failed opening required '/usr/share/php/php-gettext/gettext.inc' (include_path='.:/usr/share/php') in /usr/share/phpmyadmin/libraries/select_lang.lib.php on line 477   At first it says that the mysqli|mysql extension is missing. but after sleepless hours I forget what I've been done to it. I am using php7. I believe I have solved a famous open problem. How do I convince people in the field that I am not a crank? I am interested in the situation where you have a very interesting result. For instance, you have solved a very important open problem. However, you are not known in the field and do not have any remarkable publications. Your supervisor thinks the work is good and you submit the work to a high profile journal, but you get rejected.  The thing is that the contribution is very strong. It breaks what most people believe or what they have already proven: e.g., you solve the P vs. NP problem or any other well known open problem.   The reviewers strongly reject your work with no justification and they do not state why the result is wrong. Examples of reviewer comments include:   "The proof must be wrong."  "You cannot achieve such a result."  "You do not understand well the notion of ..."   My question is what to do in this situation? Where to go? If your advisor accepts the work, but the reviewers from the top journal reject the work without even explaining the mistakes,  what should you do? $k$ times's draw from $n$ numbers with replacement, each number at least appear once Sample $k$ times with order from $n$ distinct numbers with replacement where $k\ge n$. Here "with order" means the sample is treated like a sequence rather than a set, so results like "1,3,3" and "3,1,3" are different.  The question is what is the probability that every number is sampled at least once? My answer is $1-\frac{{\sum\limits_{i = 1}^n {C_n^i\times i! \times {{(n - i)}^k}} }}{{{n^k}}}$ where $C_n^i$ denotes $n$ chooses $i$.  ${C_n^i\times i! \times {{(n - i)}^k}}$ means first choose $i$ ($i=1,2,...,n-1$) of numbers not to appear in the sample, and then we sample from the remaining $n-i$ numbers for $k$ times.   My question is, is there more elegant solution where the numerator can be directly computed? i.e. can we directly calculate the number of possible sample sequences in which every number has at least one occurrence? Thank you!    PS: my attempt was $C_k^n\times n!\times n^{n-k}$, meaning that we first choose $n$ positions in the sequence of length $k$ to place $n$ numbers, and then permute the $n$ numbers. This is to ensure every number to appear once. The remaining $n-k$ are sampled from the $n$ numbers without restriction.   However, I later found this seems not correct, and it counts the same sequence multiple times.  PS2: as pointed out in the comments, my first answer "1- ..." is not correct either. I sold an investment in a standard brokerage account at a small loss because I needed the money for a down payment.  I still think it is a good investment, can I buy the same investment in a standard IRA without running into wash sale problems?  I will probably just wait the 30 days any way to avoid any headaches, but I want to know if there is a definitive answer on this.    Being as the cost basis in the traditional IRA doesn't matter, I wouldn't think there would be a problem. windows 7 desktop icons: new icon placement When moving/saving/etc a new file on the desktop, the icon appears second (just after "Computer"). I find it annoying, since I want my "special" icons to be first (such as the recycle bin, "Network", etc.).  Can this behavior be changed? Image a phone and browse on computer emulator? I have a galaxy nexus (stock OS). During its use I have used WeChat and WhatsApp, and would like to save my chat and voice histories within these programs.  Does a way exist to image my current phone as it is, so I can load it onto some PC emulator and browse these apps on my PC? This would allow me to save everything as it is, but also start fresh on my phone with a format. I do not want to format my phone then load back on WeChat for instance, yet I still want to be able to browse my old WeChat chats and voice clips (using a PC).  Thanks I have a problem with verb structure In this sentence:     Four items are responsible for three-fourths of the overall spending around the world, the most prominent share being that of food.   Why after the comma, the verb "being" is used? Why it does not use "is"? Evaluate $\lim \limits_{n\rightarrow\infty}\sin^2(\pi\sqrt{n^2 + n})$ I'm struggling to find the limit at infinity of : $$\lim \limits_{n\rightarrow\infty}\sin^2(\pi\sqrt{n^2 + n}), n\in\Bbb N$$ I know it is $1$ but I don't understand why this is wrong :  $\sin^2(\pi\sqrt{n^2 + n}) = \sin^2(\pi*n\sqrt{1 + \frac{1}{n}})$.  So $\lim \limits_{n\rightarrow\infty}\sin^2(\pi\sqrt{n^2 + n}) = \lim \limits_{n\rightarrow\infty}\sin^2(\pi*n\sqrt{1 + \frac{1}{n}}) =  \lim \limits_{n\rightarrow\infty} \sin^2(\pi*n) = 0$.  Thanks. "cron" processes spawning and piling up, but no crontab EDIT: I solved this, so see below for my own answer. While the bounty asks for a fix to the problem, I'd like to award it to someone who can explain why a cron process that ran for 6 years over multiple MacOS versions suddenly became a problem in Catalina.  First note, this is not a duplicate of  because I don't have active crontabs on my computer. Cron processes spawn, but they never finish, so they just keep piling up. I'm running MacOS Catalina 10.15.1  Cron jobs are spawning every couple of minutes and never dying. The oldest cron process always has a parent process "launchd", and I've searched for populated crontabs and can't find any. If I let this go on long enough, eventually I run into a scenario where I have hundreds of running cron processes and everything on my computer grinds to a halt, and I can't even open new apps (I get cryptic messages like ".app cannot be opened" when I try to open an app). My only solution at this point has been to keep activity monitor open and periodically killing off all active cron processes.  I've been able to create a new user account that seems to be immune from this issue. However, as soon as I logged into my apple ID on that account to set up iCloud drive, the problem started with that account, too. I logged out of my Apple ID and attempted uninstall iCloud drive, but the problem persisted. Clean installs of Catalina don't clear up the problem, I've reset SMC and PRAM multiple times, and repairing permissions (via this ). I've also ensured that cron has full disk access (via this ). I'm at a dead end with trying to troubleshoot this problem.  I'm not sure it's related, but my "system.log" file seems to get spammed the following few lines:  &lt;redacted&gt; AMPDeviceDiscoveryAgent[2132]: Entered:_AMMuxedDeviceDisconnected, mux-device:63 &lt;redacted&gt; AMPDeviceDiscoveryAgent[2132]: Entered:__thr_AMMuxedDeviceDisconnected, mux-device:63 &lt;redacted&gt; AMPDeviceDiscoveryAgent[2132]: tid:9a27 - Mux ID not found in mapping dictionary   ANY help is appreciated. Order of finite fields is $p^n$ The Medibuntu Project has come to an end - what do I do now? Does the review queue page show only reviews requiring your action? Does it differ, and when does it? This confusion came up in comments .  On the site I use most actively (RPG.SE), I've noticed that the counts for each review queue appear to only indicate the reviews available to me requiring my action. Just to be clear, I'm talking about this number here:        Since I'm a 10k user, that's pretty easy to tell: even after doing all my reviews, and the review page saying there's 0 items in each queue, I might still have that 10k notice in my top bar saying there's [5] reviews pending, or some other number. So they must still be there, just waiting on other users to finish them, and it just doesn't show them to me. This is fine, I like this behaviour.  However, on Meta SE about an hour ago, there was 1 item in the close vote review queue. I reviewed that item. The count stayed at 1 on the review page. When I clicked to re-enter the queue in case there were new items, I was presented with this:        Another user in that meta question I linked claims this is normal behaviour for them on their own site (Christianity.SE I think?).  What's going on here? Are the review queues supposed to be customised just to what I personally can actually review at the time? Is there a bug, are sites customised differently, or is there just some kind of caching thing leading to a time delay on the review count getting updated? (As they say, it is always caching, but is caching really the culprit here too?) Does separation of variables in PDEs give a general solution? When a partial differential equation is solved using the separation of variables method, is the produced solution the most general one that satisfies the equation or have we lost some forms of the solution because of the assumption that it is in the form of separated variables?