text
stringlengths
49
10.4k
source
dict
c#, memory-management, wpf, mvvm public string Show() { if (isPlatformSupported) { return SelectWinVistaOrLaterFolder(); } else { return SelectWinXPFolder(); } } private string SelectWinXPFolder() { WinForms.DialogResult result = xpFolderBrowserDialog.ShowDialog(); switch (result) { case WinForms.DialogResult.OK: case WinForms.DialogResult.Yes: return xpFolderBrowserDialog.SelectedPath; default: return null; } } private string SelectWinVistaOrLaterFolder() { CommonFileDialogResult result = vistaFolderBrowserDialog.ShowDialog(); switch (result) { case CommonFileDialogResult.Ok: return vistaFolderBrowserDialog.FileName; default: return null; } } } My reasoning for this design is that now the 3 readonly variables can be mocked in unit tests via reflection, while this isn't an ideal way of doing it, it's better than nothing. While I am looking for all feedback, my focus here is on the WinForms.FolderBrowserDialog and the CommonOpenFileDialog. They both implement the IDisposable interface and my concern is that I might not be implementing that properly? I believe that I could make the IFolderPicker interface extend the IDisposable interface and then call the two .Dispose() methods from within the inherited Dispose method but I was hoping I could insulate the rest of my program from these two classes as much as possible - is disposing of them in the deconstructor like this also valid? Originally I had both these classed being instantiated in their respective Select...() methods in a using block. But while also not being mock-able, it meant they were being newed up each time the method was called - is this current implementation better than that? Additionally to the great answer of dfhwze, I'll provide an alternative implementation that includes some of the suggestions. Primary, I would implement each case separatly and create / dispose the actual dialog each time the method Show is called: public interface IFolderPicker { string Show(); }
{ "domain": "codereview.stackexchange", "id": 35507, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, memory-management, wpf, mvvm", "url": null }
c++, recursion, template, c++20, constrained-templates // recursive_reduce_all template function with execution policy and initial value, overload for std::array template<class ExPo, template<class, std::size_t> class Container, typename T, std::size_t N, class TI> requires (std::is_execution_policy_v<std::remove_cvref_t<ExPo>> && arithmeticable<recursive_array_unwrap_type_t<recursive_depth<Container<T, N>>(), Container<T, N>>> && std::same_as<recursive_array_unwrap_type_t<recursive_depth<Container<T, N>>(), Container<T, N>>, TI> && recursive_depth<Container<T, N>>() == 1) constexpr auto recursive_reduce_all(ExPo execution_policy, const Container<T, N>& input, TI init) { return std::reduce(execution_policy, std::ranges::cbegin(input), std::ranges::cend(input), init); }
{ "domain": "codereview.stackexchange", "id": 44838, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, recursion, template, c++20, constrained-templates", "url": null }
general-relativity, differential-geometry, tensor-calculus And well, this time I think I got it right by first making $T_b{}^d=A_{bc}B^{cd}$. Then I applied the usual covariant derivative over a tensor: $$\nabla_a T_b{}^d = \partial_a T_b{}^d - \Gamma^e{}_{ba}T_e{}^d+\Gamma^d{}_{ea}T_b{}^e$$ And here I just reversed the change $A_{bc}B^{cd}=T_b{}^d$ and got: $$\nabla_a A_{bc}B^{cd} = \partial_a (A_{bc}B^{cd}) - \Gamma^e{}_{ba}A_{ec}B^{cd}+\Gamma^d{}_{ea}A_{bc}B^{ce}=\ ...$$ Now applying the product rule on the first term leads to: $$... \ = \partial_a (A_{bc})B^{cd} + A_{bc}\partial_a (B^{cd}) - \Gamma^e{}_{ba}A_{ec}B^{cd}+\Gamma^d{}_{ea}A_{bc}B^{ce}=\ ...$$ Finally, just have to factor out the $A_{bc}$ and $B^{cd}$ in the corresponding terms and I ended up getting: $$... \ = (\partial_a A_{bc}- \Gamma^e{}_{ba}A_{ec})B^{cd} + A_{bc}(\partial_a B^{cd}+\Gamma^d{}_{ea}B^{ce}) = \nabla_a(A_{bc})B^{cd}+A_{bc}\nabla_a(B^{cd})$$ Which is the desired result.
{ "domain": "physics.stackexchange", "id": 76989, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, differential-geometry, tensor-calculus", "url": null }
special-relativity Title: A relativistic meter stick and a thin disk I have a question like the "pole in the barn" special relativity "paradox", but I'm not sure what to make of this: Question A meter stick lies along the $x$-axis and approaches the origin, moving along its length, with velocity $v_x$. A very thin plate, parallel to the $xz$ plane in the laboratory, moves upward in the $y$ direction with velocity $v_y$. The plate has a circular hole with diameter $1$ m centered on the y-axis. The center of the meter stick arrives at the origin at the same time as the center of the hole in the plate. In the laboratory frame, the meter stick is Lorentz contracted, so it's in the hole in the plate, and plate and stick continue on their paths without a collision. In the rest frame of the meter stick, however, it is the plate, and the hole in it, that is contracted along the $x$-axis. This would seem to predict a collision, contradicting the requirement that physical predictions must be invariant. Which of these two predictions are correct?
{ "domain": "physics.stackexchange", "id": 10218, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "special-relativity", "url": null }
php, html, random Title: Lotto/lucky draw The following script draws 6 numbers at random. I input another 6 numbers and compare with random numbers generated, if they're the same, you win. <html> <body> <form align="center" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post"> Numele jucatorului <input type="text" name="nume" min="1" max="10" required="yes"><br> <br> Numar 1: <input type="number" name="nr1" min="1" max="49" required="yes"><br> <br> Numar 2: <input type="number" name="nr2" min="1" max="49" required="yes"><br> <br> Numar 3: <input type="number" name="nr3" min="1" max="49" required="yes"><br> <br> Numar 4: <input type="number" name="nr4" min="1" max="49" required="yes"><br> <br> Numar 5: <input type="number" name="nr5" min="1" max="49" required="yes"><br> <br> Numar 6: <input type="number" name="nr6" min="1" max="49" required="yes"><br> <br> <input type="submit"> <br> <form> <?php #error_reporting(0); $server = ""; $user = ""; $password = ""; $conectare = new mysqli($server, $user, $password); if ($conectare->connect_error){ die("Conexiune esuata:" . $conectare->connect_error); }
{ "domain": "codereview.stackexchange", "id": 14502, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "php, html, random", "url": null }
electromagnetism, general-relativity, maxwell-equations, approximations, linearized-theory Title: What different approximations yield Gravitoelectromagnetism and Weak Field Einstein Equations? This question is inspired by this answer, which cites Gravitoelectromagnetism (GEM) as a valid approximation to the Einstein Field Equations (EFE). The wonted presentation of gravitational waves is either through Weak Field Einstein equations presented in, say, §8.3 of B. Schutz “A first course in General Relativity”, or through the exact wave solutions presented in, say §9.2 of B. Crowell “General Relativity” or §35.9 of Misner, Thorne and Wheeler. In particular, the WFEE show their characteristic “quadrupolar polarization” which can be visualized as one way dilations in one transverse direction followed by one-way dilations in the orthogonal transverse direction. GEM on the other hand is wholly analogous to Maxwell’s equations, with the gravitational acceleration substituted for the $\mathbf{E}$ vector and with a $\mathbf{B}$ vector arising from propagation delays in the $\mathbf{E}$ field as the sources move. My Questions:
{ "domain": "physics.stackexchange", "id": 49928, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electromagnetism, general-relativity, maxwell-equations, approximations, linearized-theory", "url": null }
quantum-mechanics, electromagnetic-radiation, double-slit-experiment, wave-particle-duality To get a feeling about coherence have a look at this link. It talks about light, but the mathematics are the same for coherent electron beams. It is evident that the point sources after inelastic scattering for each electron are incoherent between two different electrons, as the phase relation is lost by the inelastic scatter. The electron that only scatters elastically retains a phase relation to the beam and the other electrons coming consecutively, even though one at a time, by construction of the beam. Interference patterns only appear when there exists a phase between the particles. (btw, it is only the probability distribution for the electron that can exist for both slits.)
{ "domain": "physics.stackexchange", "id": 51066, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, electromagnetic-radiation, double-slit-experiment, wave-particle-duality", "url": null }
structural-analysis, beam, solid-mechanics, strength $$ \begin{aligned} \sigma_y h(x)^2 & = 6 \rho g \int_0^{L-x} h(t)\cdot t \, dt \\ \frac{d}{dx}\left[ \sigma_y h(x)^2 \right] & = \frac{d}{dx} \left[ 6 \rho g \int_0^{L-x} h(t)\cdot t \, dt \right] \\ 2 \sigma_y h(x)h'(x) & = -6 \rho g \cdot h(L-x)\cdot (L-x) \end{aligned} $$ And the problem is that I don't know how to solve this differential equation where h has two different arguments, first x, then L-x. I tried thinking about substitutions but they just seem to move the problem to another place. Attempt 2 Another thing I tried is choosing the origin at the tip of the beam, with the beam that goes towards the right this time. I followed the same procedure shown above and I managed to get another equation, but this time I got the following: $$ \sigma_y h(x)^2 = 6 \rho g \int_0^x h(t) \cdot (x-t) \, dt $$ I differentiated once both sides and got: $$ 2 \sigma_y h(x) h'(x) = 6 \rho g \int_0^x h(t) \, dt $$ Then differentiated again and got: $$ 2 \sigma_y [h(x) h''(x) + h'(x)^2] = 6 \rho g h(x) $$ $$ h(x) h''(x) + h'(x)^2 - \frac{3 \rho g}{\sigma_y} h(x) = 0 $$ Which is a nonlinear 2dn order ODE, but again I am a bit stuck with the solution of it as I am a bit rusty with ODEs and I don't know if this is an equation that can be solved nicely or if it could keep me up all day.
{ "domain": "engineering.stackexchange", "id": 5231, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "structural-analysis, beam, solid-mechanics, strength", "url": null }
quantum-mechanics, group-theory, lie-algebra \end{align} Infinitesimal generators. Each of the group actions above possesses an infinitesimal generator. To determine what that is for $\rho_1$, we write $\hat U(a) = e^{-ia\hat P}$, so that $\hat P$ is the infinitesimal generator of $\hat U$, and we notice that if we expand the right hand side of $(1)$ in $a$ we have \begin{align} \hat U(a)\hat\phi(x)\hat U(a)^{-1} &= (\hat I - ia\hat P)\hat \phi(x) (\hat I + ia\hat P) + O(a^2) \\ &= \hat \phi(x) + ia\hat\phi(x)\hat P - ia\hat\phi(x) \hat P + O(a^2) \\ &=\hat \phi(x) -ia\Big(\hat P\hat \phi(x)-\hat \phi(x) \hat P\Big) + O(a^2) \\ &= \hat\phi(x) -ia[\hat P,\hat \phi(x)] + O(a^2) \end{align} inspecting the term that is first order in $a$, we see immediately that the operator \begin{align} \hat \phi(x) \mapsto [\hat P,\hat \phi(x)] \end{align} is the infinitesimal generator of the first group action $\rho_1$. It turns out by the way that this operator has a special name: the adjoint operator, and it is often denoted $\mathrm{ad}_{\hat P}$. So all in all, we see that $\mathrm{ad}_{\hat P}$ is the infinitesimal generator of $\rho_1$ since we have shown that \begin{align}
{ "domain": "physics.stackexchange", "id": 14487, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, group-theory, lie-algebra", "url": null }
electrostatics, experimental-physics, potential, voltage Title: Is Electric Potential real? Is electric potential real? You might say it depends on what I mean by 'real' and I agree. But I remember reading about an experiment suggesting that electric potential is real, contra what had been previously thought. Are there any experiments that could have some bearing on the reality of electric potential? You're probably thinking of the Aharonov–Bohm effect. Quoting from the article: The Aharonov–Bohm effect, sometimes called the Ehrenberg–Siday–Aharonov–Bohm effect, is a quantum mechanical phenomenon in which an electrically charged particle is affected by an electromagnetic potential (Φ, A), despite being confined to a region in which both the magnetic field B and electric field E are zero. It is generally argued that Aharonov–Bohm effect illustrates the physicality of electromagnetic potentials, Φ and A. The Aharonov–Bohm effect shows that the local E and B fields do not contain full information about the electromagnetic field, and the electromagnetic four-potential, (Φ, A), must be used instead. By Stokes' theorem, the magnitude of the Aharonov–Bohm effect can be calculated using the electromagnetic fields alone, or using the four-potential alone. But when using just the electromagnetic fields, the effect depends on the field values in a region from which the test particle is excluded. In contrast, when using just the electromagnetic four-potential, the effect only depends on the potential in the region where the test particle is allowed. In classical electromagnetism the two descriptions were equivalent. With the addition of quantum theory, though, the electromagnetic potentials Φ and A are seen as being more fundamental.
{ "domain": "physics.stackexchange", "id": 72808, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electrostatics, experimental-physics, potential, voltage", "url": null }
universe, space, cosmological-inflation Title: The universe is dying vs the universe is ever expanding How does the idea that the universe is dying (trumpeted as some big new revelation the past few days on several new sites I keep seeing pop up on google news) square with the idea that the universe is ever expanding? Both are true. The universe is "dying" in the sense that stars eventually run out of hydrogen, and there aren't infinite amounts of hydrogen in galaxies to replace old stars. This will take a very long time, but eventually all stars will burn out and new stars will stop forming. This is what the study recently in the news is saying. The universe is ever expanding in the sense that distances between galaxies which are not bound together gravitationally is expanding all the time. If you look at very distant galaxies, they are all receding into the distance. Combine these two facts and the result is that the universe will become more and more "rarefied" (distances between galaxies will keep expanding), and also all existing stars in galaxies will burn out over trillions of years.
{ "domain": "astronomy.stackexchange", "id": 1030, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "universe, space, cosmological-inflation", "url": null }
inorganic-chemistry, ions, identification Title: Identifying a quadruply charged anion containing three carbon atoms This linear polyatomic ion containing three atoms of carbon has a negative four charge and is only found bonded with lithium and magnesium. Could anyone identify this for me? It's from a quiz bowl clue that doesn't have the answer with it. Sesquicarbide A quick Google search suggests that $\ce{Li4C3}$ is a real compound, but based on what I saw in the links, it probably is not ionic in the same way that lithium acetylide $\ce{Li2C2}$ is. $\ce{Mg2C3}$ appears to be the formula for magnesium carbide, or at least a magnesium carbide. A carbide is a binary compound of carbon and a less electronegative element, usually a metal or metalloid. Carbide is also a generic name for mono- and polyatomic anions containing only carbon. The following ions would all carbide ions: $\ce{C^{4-}, C2^2-, C2^{4-}, C2^{6-}, C3^{4-}, C3^{6-1}, C3^{8-}}$, etc. The special name of three of these carbide ions are: $\ce{C^{4-}}$ - Methide $\ce{C2^{2-}}$ - Acetylide $\ce{C3^{4-}}$ - Sesquicarbide
{ "domain": "chemistry.stackexchange", "id": 358, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "inorganic-chemistry, ions, identification", "url": null }
group-theory, elasticity, continuum-mechanics permutations_inv = [ (0, 1, 2, 3), (1, 0, 2, 3), (0, 1, 3, 2), (2, 3, 0, 1), (1, 0, 3, 2), (3, 2, 1, 0), (0, 3, 1, 2), (0, 2, 1, 3), ] # Invert permutation according definition permutations = [] for p in permutations_inv: permutations.append([ p.index(0), p.index(1), p.index(2), p.index(3), ]) H = 1.0/len(permutations) * sum( A.transpose(perm) for perm in permutations ) def has_sym_inner(A): sym = True for i in range(3): for j in range(3): for k in range(3): for l in range(3): if not all( [ A[i, j, k, l] == A[j, i, k, l], A[i, j, k, l] == A[i, j, l, k], A[i, j, k, l] == A[k, l, i, j] ] ): sym = False return sym print('has_sym_inner =', has_sym_inner(H)) Verifying visually using mechkit import mechkit con = mechkit.notation.Converter() print('A=\n', con.to_mandel9(A)) print('H=\n', con.to_mandel9(H))
{ "domain": "physics.stackexchange", "id": 73496, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "group-theory, elasticity, continuum-mechanics", "url": null }
species-identification, entomology, lepidoptera Title: Please identify this moth from Bangladesh Sorry for bad resolution of the picture. This picture is taken from JU campus, Savar. I think I have found the identification. It is a planthopper from ricaniidae family. Most likely Ricanula stigmatica. Image source: https://en.m.wikipedia.org/wiki/Ricanula_stigmatica
{ "domain": "biology.stackexchange", "id": 7016, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "species-identification, entomology, lepidoptera", "url": null }
quantum-mechanics, quantum-information, terminology, quantum-entanglement The reduced density matrix is what is left if you take the partial trace over one of the subsystems. In our example above: $$ \rho_A = tr_B(\rho)= tr_B(\frac{1}{2}(|01\rangle\langle 01|+|10\rangle\langle 01|+|01\rangle\langle 10|+|10\rangle\langle 10|))=\frac{1}{2}(|0\rangle\langle 0|+|1\rangle\langle 1|) $$ and the last part is exactly the identity, i.e. the state is maximally mixed. You can do the same over with $tr_A$ and see that the state $\rho$ is therefore maximally entangled.
{ "domain": "physics.stackexchange", "id": 20414, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, quantum-information, terminology, quantum-entanglement", "url": null }
machine-learning, time-series, feature-extraction Title: Any issue with "overlapping" sliding windows in time-series data analysis? I am developing some classification/regression models form accelerometry time-series data. So far, I have created datapoints by extracting features from non-overlapping sliding windows of the time-series data. I would like to try using overlapping windows as well. However, I was wondering whether it is conceptually sound or there might be some caveats to keep in mind as the data is reused in the overlapping windows. In general I don't see anything wrong with overlapping windows, it might make perfect sense depending on your task. In fact some learning models (e.g. for sequence labeling) do use features based on past data points, which is conceptually similar to having overlaps between them. However you need to be careful about the fact that this makes data points depend on each other, so of course the preprocessing must be done separately for the training and test set.
{ "domain": "datascience.stackexchange", "id": 5739, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "machine-learning, time-series, feature-extraction", "url": null }
quantum-mechanics, particle-physics, neutrinos, weak-interaction where L indicates the long-lived CP odd mass eigenstate, and S the dramatically shorter-lived CP even one. Similarly for the Bs. For the Kaons, of mass roughly half a GeV, the relevant mass difference proportional to the oscillation frequency is $$ \Delta m\approx 3\cdot 10^{-15}\hbox{ GeV}. $$ For the Bs, of mass roughly 5.366 GeV, the relevant frequency/ mass difference is $$ \Delta m\approx 1.17 \cdot 10^{-8} \hbox{MeV}\\ \approx 18\cdot 10^{12} \hbar /s , $$ dubbed 18 /ps in natural units. This corresponds to oscillation lengths of 20 μm, so, a far cry from kilometers for neutrinos!
{ "domain": "physics.stackexchange", "id": 85629, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, particle-physics, neutrinos, weak-interaction", "url": null }
python, sqlalchemy Title: SQLAlchemy code for calling parameters I'm using the following function to process API parameters for an specific endpoint. Using SQLAlchemy and Flask, I want to get feedback in terms of simplifying calling SQL code and nested statements. date_filter = r'\d{4}-((1[0-2]|[1-9])|0[1-9])-((3[01]|[12][0-9]|[1-9])|0[1-9])' def bits_filter(request): """ :param request: :return:(Model.Bits) List of bits """ # Get parameters. log.info('/bits request: %s', request) # Date parameters. date_value = request.args.get('date') # Bit or newsletter. bit_type_value = request.args.get('bit_type') # Process parameters. date_value = date_value or settings.DATE_VALUE bit_type = bit_type_value or settings.BIT_TYPE log.info('bit_type: %r', bit_type)
{ "domain": "codereview.stackexchange", "id": 27248, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, sqlalchemy", "url": null }
java, unit-testing, api, jodatime /** * * @return Consumption amount that the day tariff applies to. */ public Double duringDayTariff() /** * * @return Consumption amount that the night tariff applies to. */ public Double duringNightTariff() @Test public void nightConsumptionIsFromFirstHourToEighthHourWhenDST() throws Exception { BufferedReader reader = new BufferedReader(new StringReader("1 - 1" + "\n" + "8 - 1" + "\n" + "24 - 10" + "\n" + "9 - 10")); MonthConsumption monthConsumption = new MonthConsumption(reader, 4, 2013); assertEquals(2, monthConsumption.duringNightTariff(), 0); } @Test public void testIncludedWithTheTask() throws Exception { BufferedReader reader = new BufferedReader(new StringReader("1 - 2" + "\n" + "2 - 3" + "\n" + "26 - 3" + "\n" + "32 - 6" + "\n" + "744 - 0")); MonthConsumption monthConsumption = new MonthConsumption(reader, 1, 2013); assertEquals(8, monthConsumption.duringNightTariff(), 0); assertEquals(6, monthConsumption.duringDayTariff(), 0); } @Test public void daylightSavingStartsOnLastSundayOfMarchInEstoniaAt01UTC_March2013() throws FileNotFoundException { String fileName = "endOfMarch2013.csv"; String fileSeparator = System.getProperty("file.separator"); final String filePath = "src" + fileSeparator + "test" + fileSeparator + "resources" + fileSeparator + fileName; BufferedReader reader = new BufferedReader(new FileReader(filePath));
{ "domain": "codereview.stackexchange", "id": 5615, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, unit-testing, api, jodatime", "url": null }
ros, master, roscpp, publisher Originally posted by thebyohazard on ROS Answers with karma: 3562 on 2015-08-20 Post score: 1 Original comments Comment by 130s on 2015-08-20: Interesting. It makes more sense to me to be implemented in lower level (maybe rostopic and equivalent) to optionally return if there's no subscribers (pretty much like your reference). Comment by 130s on 2015-08-20: Or do you think coordinated behavior (by pipeline) better? Anyway this is enhancement discussion that's better opened at somewhere else. Afaik this does not exist in ROS and I would have suggested to unsubscribe on demand. As you describe this, you want to uphold the subscription to see this in the node graph, but only stop processing internally. As nodes do not have any way to figure this out, you will need something external. Given that any pipeline node cannot know anything about the configuration and where the exit subscribers are, you will have to either setup some kind of manager (for nodelets the nodelet manager could be used) or provide an parallel pipeline mechanism that connects all pipeline nodes and instead of the data only provides the information if things should be computed backwards through the pipeline. Originally posted by dornhege with karma: 31395 on 2015-08-21 This answer was ACCEPTED on the original site Post score: 0
{ "domain": "robotics.stackexchange", "id": 22493, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, master, roscpp, publisher", "url": null }
Your answers for the area of region R and the area of region S are correct. The methods for revolving about the x-axis are essentially the same as for revolving about the y-axis. You can use disks/washers or cylindrical shells. Disks/Washers: In this case washers. Form a washer from a rectangle which extends from y_1 to y_2 vertically and has a of width, Δx. Rotate the rectangle about the x-axis. The volume of the washer is $\displaystyle \text{v}= \left(\pi y_2^{\,2}-\pi y_1^{\,2}\right)\Delta x\,.$ In the case of region S, $\displaystyle y_1=\tan(x)$ and $\displaystyle y_2=\sqrt{3}.$ Letting Δx be very small, it becomes dx. Integrate this over x to get the volume. $\displaystyle V=\pi\int_0^{\pi/3} \left(\sqrt{3}\right)^2-\tan^2(x)\,dx$ Cylindrical shells:Form a cylindrical shell from a rectangle which extends from x_1 to x_2 horizontally and has a of height, Δy, located a distance of y above the x-axis.. Rotating this about the x-axis gives a cylindrical shell with a volume of $\displaystyle \text{v}= 2\pi y\left( x_2- x_1\right)\Delta y\,.$ In the case of region S, $\displaystyle x_1=0$ and $\displaystyle x_2=\tan^{-1}(y).$ Letting Δy be very small, it becomes dy. Integrate this over y to get the volume. $\displaystyle V=2\pi\int_0^{\sqrt{3}} y\tan^{-1}(y)\,dy$
{ "domain": "mathhelpforum.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9848109503004293, "lm_q1q2_score": 0.8466062750785024, "lm_q2_score": 0.8596637505099168, "openwebmath_perplexity": 588.7771720448559, "openwebmath_score": 0.9167386889457703, "tags": null, "url": "http://mathhelpforum.com/calculus/167026-integration-area-volume.html" }
navigation, ekf, odometry, robot-pose-ekf Originally posted by Tom Moore with karma: 13689 on 2014-08-04 This answer was ACCEPTED on the original site Post score: 2 Original comments Comment by arenillas on 2014-08-05: I used robot_localization and get bad results. If you want, I can send you some graphics of the error using GPS and odom and only using GPS. Comment by Tom Moore on 2014-08-05: Please do! Feel free to send me bag files, errors, etc. Once we sort out your issues, we can post the answer here for everyone. Comment by l0g1x on 2014-08-05: Are you sending covariance values with your sensor inputs? Specifically Odom. Comment by l0g1x on 2014-08-05: Tom, would you by change know of any dynamic covariance example methods for odometry? This would help me out as well since I pretty much have same problem as the author. Thanks Comment by Tom Moore on 2014-08-05: I think that deserves its own question, actually. Post it and I'll respond to it later today.
{ "domain": "robotics.stackexchange", "id": 18896, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "navigation, ekf, odometry, robot-pose-ekf", "url": null }
organic-chemistry, inorganic-chemistry, acid-base, solvents, molecules Title: How can one find products when one knows the reagents? I'm going to use an example (I could have used a different one); On the document it is about the study of the chemical balance of an acid-basic solution. The chemists have written the chemical reaction equation to make a table of the evolution of pH during the reaction. If I understand with this equation I'll be able to understand others. $\ce{CH3COOH + H2O ->CH3COO- + H3O+}$ Here is what I already understand: This is the equation of methanoic acid with water I understood why the general formula of methanoic acid is $\ce{CH3COOH}$ What I want to know is how do we know that $\ce{CH3COOH}$ changes into $\ce{CH3COO-}$ ? $\ce{H2O}$ changes into $\ce{H3O+}$?
{ "domain": "chemistry.stackexchange", "id": 315, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "organic-chemistry, inorganic-chemistry, acid-base, solvents, molecules", "url": null }
dimensional-analysis Title: Possible fundamental dimensions in Pi Buckingham theorem While the Pi Buckingham is often taught in a fluid dynamics context, in which the relevant fundamental dimensions are generally : Mass, Length, Time and Temperature, it can obviously be applied to much more complex physics. Is there a source that gives an extensive list of the possible fundamental dimensions? I would presume something similar to Moles would also be a fundamental quantity? One authority on this is NIST; they have a webpage giving length (in meter) Mass (in kilogram) time (in second) electric current (in ampere) thermodynamic temperature (in kelvin) amount of substance (in mole) and luminous intensity (in candela) as the SI base units, and also provide a long list of derived units expressed in terms of the base units.
{ "domain": "physics.stackexchange", "id": 51486, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "dimensional-analysis", "url": null }
roslaunch Why does OnShutdown refuse to execute actions other than LogInfo? How can I execute a bash script on shutdown of a launch process ? For reference and convenience: Link to the code responsible for OnShutdown I can reproduce this. I don't have advice about the root cause, but it looks like you can provide a callable to the on_shutdown= argument which might work for your use case. For example, I can define: def shutdown_func_with_echo_side_effect(event, context): os.system('echo [os.system()] Shutdown callback function can echo this way.') return [ LogInfo(msg='Shutdown callback was called for reason "{}"'.format(event.reason)), ExecuteProcess(cmd=['echo', 'However, this echo will fail.'])] and register it with the OnShutdown event handler like this: ld = LaunchDescription([ talker_node, RegisterEventHandler( OnShutdown(on_shutdown=shutdown_func_with_echo_side_effect) ) ])
{ "domain": "robotics.stackexchange", "id": 2708, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "roslaunch", "url": null }
Conversely, suppose that $T$ is an invertible positive operator. We show that $\langle \cdot,\cdot\rangle_T$ is an inner product on $V$ by checking definition 6.3. Positivity: Note that $T$ is positive, we have $$\langle v,v\rangle_T=\langle Tv,v\rangle \geqslant 0.$$ Definiteness: If $v=0$, then $$\langle v,v\rangle_T=\langle Tv,v\rangle \geqslant 0.$$If $\langle v,v\rangle_T=0$, since $T$ is invertible positive operator on $V$, it follows from Problem 7 that $v=0$. Additivity, homogeneity, and conjugate symmetry can be checked directly with out any difficulties.
{ "domain": "linearalgebras.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.988491849579606, "lm_q1q2_score": 0.8279805088035487, "lm_q2_score": 0.8376199653600371, "openwebmath_perplexity": 148.50501647031686, "openwebmath_score": 0.9993876814842224, "tags": null, "url": "https://linearalgebras.com/7c.html" }
biochemistry, enzymes Title: Can an enzyme be activated without allosteric inhibition or activation? Are there ways by which an enzyme may be activated or inhibited by non substrate molecules other than allosteric activation or inhibition? Apart from what Phototroph mentioned in their answer (competitive and non-competitive inhibition), an enzyme can be activated/inhibited via covalent modification of the protein (post-translational modification) such as phosphorylation by protein kinases (phosphorylation is the most common modification).
{ "domain": "biology.stackexchange", "id": 5050, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "biochemistry, enzymes", "url": null }
lambda-calculus, correctness-proof, software-verification, interpreters This creates new problems that you will have to figure out (Now it's too strong for the case of variables, how to weaken it a bit? Is this recursive property even well-defined? (if not, how to make it so?)). Hopefully this gets the ball rolling for you.
{ "domain": "cs.stackexchange", "id": 21756, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "lambda-calculus, correctness-proof, software-verification, interpreters", "url": null }
python Title: Character instance slowdown I'm making a Mario clone in PyGame and I am writing a function that, after releasing the left and right button while Mario is moving horizontally, slows him down until he is at rest. As of right now, the code I am using is functional and works the way it should. Though, I am not sure if there is a way I can write the following code more efficiently: self.deacc = 0.5 # Always a positive number, never changed anywhere in the code. if self.horzDir == 'l': # if mario is moving left. self.x += self.dx self.dx += self.deacc # To ensure marios velocity doesnt go below zero. if self.dx > (self.deacc * -1): self.dx = 0 else: self.x += self.dx self.dx -= self.deacc # Also to ensure marios velocity doesnt go below zero. if self.dx < self.deacc: self.dx = 0 Everything is working correctly, but I feel like it can be more efficient than this because the if and else statements are very similar, just with slightly different calculations. Any ideas? The most important difference between your if and your else is this: self.dx += self.deacc vs. self.dx -= self.deacc The rest can work just fine without being in if or else. Also, when you copy-paste code, which you apparently did to check the bounds on self.dx, you should change the comments. Both of your comments say "go below zero". It was a bit hard for me to understand the purpose of your if self.dx > (self.deacc * -1):. If I understand your code correctly, and if my Python syntax skills are correct, I think it should work to do it like this: self.x += self.dx self.dx += (self.deacc if self.horzDir == 'l' else -self.deacc) if Math.abs(self.dx) < self.deacc: self.dx = 0
{ "domain": "codereview.stackexchange", "id": 14876, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python", "url": null }
ros-kinetic, ubuntu, ubuntu-xenial /usr/bin/c++ -O3 -DNDEBUG CMakeFiles/parameters.dir/parameters/parameters.cpp.o -o /home/secret_agent/top_secret/catkin_ws/devel/lib/roscpp_tutorials/parameters -L/opt/ros/kinetic/lib -rdynamic /opt/ros/kinetic/lib/libroscpp.so -lboost_filesystem -lboost_signals /opt/ros/kinetic/lib/libxmlrpcpp.so /opt/ros/kinetic/lib/librosconsole.so /opt/ros/kinetic/lib/librosconsole_log4cxx.so /opt/ros/kinetic/lib/librosconsole_backend_interface.so -llog4cxx -lboost_regex /opt/ros/kinetic/lib/libroscpp_serialization.so /opt/ros/kinetic/lib/librostime.so /opt/ros/kinetic/lib/libcpp_common.so -lboost_system -lboost_thread -lboost_chrono -lboost_date_time -lboost_atomic -lpthread -lconsole_bridge -lboost_date_time -lboost_thread -lboost_chrono -lboost_system -lboost_atomic -lpthread -lconsole_bridge -Wl,-rpath,/opt/ros/kinetic/lib: CMakeFiles/parameters.dir/parameters/parameters.cpp.o: In function `main': parameters.cpp:(.text.startup+0x3d): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
{ "domain": "robotics.stackexchange", "id": 33616, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros-kinetic, ubuntu, ubuntu-xenial", "url": null }
thermodynamics, angular-momentum, energy-conservation, rotation, moment-of-inertia If we substitute Eqns. 4-6 into Eqns. 7 and 8, and disregard higher order non-linear terms, we obtain $$\Delta (KE) = M(\omega_iR_0)^2(\alpha \Delta T)\tag{9}$$ $$\Delta (SE) = -M(\omega_iR_0)^2(\alpha \Delta T)\tag{10}$$ This verifies that the decrease in kinetic energy of the system is precisely compensated for by the increase in stored elastic energy of the system. This is the way that energy is conserved in the system. These same qualitative results will apply to the disk problem.
{ "domain": "physics.stackexchange", "id": 33240, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "thermodynamics, angular-momentum, energy-conservation, rotation, moment-of-inertia", "url": null }
gazebo, moveit, ros-kinetic Title: how does Moveit communicate to Gazebo? Hi all, I was able to simulate the UR5 and control it in simulation from RViz, fololwing these steps: $ roslaunch ur_gazebo ur5.launch $ roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch sim:=true $ roslaunch ur5_moveit_config moveit_rviz.launch config:=true Now I would like to know how to control the real UR5, but first I need to know how RViz is talking to Gazebo in order to make the robot moves. Does anyone know what kind of input is needed by gazebo? Or better, what kind of information is being sent to Gazebo when I press "plan and execute" in RViz? I suspect they are the joints states, but I don't know where to read this information. Thank you for your help in advance. Edit: Thanks a lot for your answer, now everything is a bit more clear. But I have another question at this point. I tried to communicate with the real hardware and I was able to move the robot running "test_move.py" from the "ur_modern_driver package". After that I tried to move the robot with MoveIt! following this tutorial: http://wiki.ros.org/universal_robot/Tutorials/Getting%20Started%20with%20a%20Universal%20Robot%20and%20ROS-Industrial Problems arise when launching this command: roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch limited:=true In the terminal the following lines appear: [ WARN] [1529329845.474785699]: Waiting for /joint_trajectory_action to come up [ WARN] [1529329851.474995251]: Waiting for /joint_trajectory_action to come up [ERROR] [1529329857.475168563]: Action client not connected: /joint_trajectory_action
{ "domain": "robotics.stackexchange", "id": 30981, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gazebo, moveit, ros-kinetic", "url": null }
php, object-oriented /** * False == No Data * 0 == Widowed socket / Remote client closed connection */ if($response === false || $response === 0) { $this->removeSocket($connectionId); return ''; } $response = $data; if((ord(substr($response, -1)) == 26 || ord(substr($response, -1)) == 0 || is_null($response)) === false) { while($socketStatus = @socket_recv($connection, $data, 1024, 0)) { /** * false = no data */ if($socketStatus === false) break; /** * 0 = widowed socket -> remote client closed connection; */ if($socketStatus === 0) { $this->removeSocket($connectionId); break; } if(!is_null($data)) $response .= $data; if(ord(substr($data, -1)) == 26 || ord(substr($data, -1)) == 0 || is_null($data)) break; } } $response = substr($response, 0, -1); return $response; } /** * Reads information from the facelink service * @return string Information from the facelink service */ protected function readFacelinkSocket() { $response = ""; while(false !== @socket_recv($this->facelinkSocket, $data, 1024, 0)) { if(!is_null($data)) $response .= $data; if(ord(substr($data, -1)) == 26 || ord(substr($data, -1)) == 0 || is_null($data)) { break; } } return $response; } /** * Main loop, starts the proxy * @return void */ public function run () { /* * Client connections' pool */ $this->clients = array();
{ "domain": "codereview.stackexchange", "id": 196, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "php, object-oriented", "url": null }
gazebo The following command will install the correct version of Gazebo and ros_gz for your ROS installation on a Linux system. I can open Gazebo by gz sim empty.sdf, but get package 'gazebo_ros' not found when running a launch file intended to spawn a robot in Gazebo. Comment by azeey on 2023-06-21: Ah, my mistake, it looks like ros-humble-ros-gz indirectly depends on libignition-gazebo6, so yes, it does install it. If you have a launch file that is looking for gazebo_ros, that launch file is probably meant to be used with Gazebo-classic. It'll need to be updated to work with the new Gazebo. Comment by Simple Simpson on 2023-06-22: cool, thanks. Do you have any links to documentation how to replace gazebo_ros references with new Gazebo? Comment by Simple Simpson on 2023-06-22: Reading the docs, gazebo_ros is still a package name, right? Comment by azeey on 2023-06-22: gazebo_ros is still a package name, but it's meant to work with Gazebo classic. You'll want to use ros_gz with the new Gazebo. Here's a repo with examples. This video should also help Comment by Simple Simpson on 2023-06-22: thanks man!
{ "domain": "robotics.stackexchange", "id": 4709, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gazebo", "url": null }
motors, gears, mechanisms Title: Gear mechanism for automatic gate I have a sliding gate installed on my compound wall. I want to control the gate opening/closing with a motor. I have the electronic circuitry to control motor start/stop. I m thinking about attaching rack on the gate and pinion on the motor to achieve this. But the gate should be able to open/close manually in case of a power failure and I don't think this is possible with a gear motor. I have been searching for some mechanism to achieve this and I found planetary gear system. Does this solve my issue or is there any other mechanism to achieve the same? As long as you're able to lock one of the planetary elements while the motor is powered that solves your problem but that doesn't seem like the most efficient solution. I would try an electromagnetic clutch between the motor and the pinion. When you have power, the clutch is engaged and the motor can turn the pinion. When you lose power, the clutch disengages and you can manually turn the pinion with a crank or equivalent.
{ "domain": "engineering.stackexchange", "id": 3445, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "motors, gears, mechanisms", "url": null }
performance, php, mysql, pdo Note: The Database(), generate_new_session(), and get_level_name() have not been included because they are not relevant. By the second query, I already know that the session is valid so there is no need to compare the values all over again. I just can't think of an alternative. Your two queries are essentially the same, except the second query is also joining to the users table. This suggests that you might be able to remove the first query and simply execute the second query. OUTER JOIN Since you've said that it is possible for a client to have an active session, but no user associated with it, then you would need to to use an outer join, which mysql seems to support, to connect to the users table. The explanation in the documentation isn't overly easy to follow, but essentially, when you do a normal join results are only returned if all the join criteria are met. If you do an outer join, then results from the outer joined table (users) will be returned if present, otherwise columns from that table will be returned as null. You can then determine if a user has a session (a row is returned) and if they're logged on (users columns have values) from a single query.
{ "domain": "codereview.stackexchange", "id": 21204, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "performance, php, mysql, pdo", "url": null }
quantum-mechanics, wavelength, quantum-states The electron can't move in all orbits allowed by Newtonian mechanics. For circular orbits, only those radii are possibile which correspond to an angular momentum $L$ multiple of $\hbar=h/(2\pi)$. The atom can absorb or emit radiation only by "jumping" from one allowed (stationary) state to another. Frequency (and wavelength) of emitted/absorbed radiation is determined by conservation of energy together with Planck's rule: $$E_2 - E_1 = h\,\nu = \hbar\,\om.$$ By combining these postulates with 2nd Newton's Law and Coulomb's Law for electrical force between electron and proton, Bohr got to the famous formula $$E_n = {m\,e^4 \over 2\,n^2 \hbar^2} \qquad \hbox{(Gauss' units)}$$ which accounted with extraordinary precision for the observed spectral lines. However both postulates were incompatible with mechanics and electromagnetism as known at that time. So it was clear Bohr's idea was a first tentative step towards a new physics. De Broglie's (1924) idea was to justify the first Bohr postulate as a consequence of a more general one: to every particle there is "associated" a wave, whose wavelength is determined by particle's momentum, according to the relation $$\lam = {h \over p}.$$ He added another idea: Bohr stationary states are those where the associated wave is a standing wave along electron's orbit.
{ "domain": "physics.stackexchange", "id": 55434, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, wavelength, quantum-states", "url": null }
ros Title: What is the concept of ROS wrapper? I'm new to ROS and now I have no idea what is the concept of ROS wrapper? I have been searching around the webs and still not understand about it. Hope anyone can kindly describe to me. Thank you very much. Originally posted by sean819 on ROS Answers with karma: 25 on 2016-02-01 Post score: 2 Most likely this is where you write your business logic / algorithms completely ROS-agnostic (so no use of ROS, its datastructures or any of its algorithms) and then add a relatively thin layer that adds ROS compatibility. A concrete example: let's say you have some audio processing code for speech recognition. You put this in a libMySpeechProcessor. That library is completely stand-alone, does not make use of any part of ROS anywhere. Now to be able to use that in ROS, you create a ROS node that advertises a service processAudio(..), performs any initialisation necessary for your speech recognition engine and then makes use of the functionality provided by libMySpeechProcessor in the callback associated with the service server. Note that libMySpeechProcessor does not have any dependencies on ROS. The main advantage of this is that your library can now be used on its own, without someone wanting to use your speech processor having to install ROS (or Linux, perhaps it is even Windows compatible like this). Note also that this is not a new concept, or something specific to ROS: in general it is always a good idea to avoid dependencies as much as possible and to not tie yourself to one specific framework or library. Originally posted by gvdhoorn with karma: 86574 on 2016-02-01 This answer was ACCEPTED on the original site Post score: 4
{ "domain": "robotics.stackexchange", "id": 23609, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros", "url": null }
beginner, php, object-oriented, authentication, mysqli $this->db_connect = $db; } } } ?> Output of utility class You are outputting error conditions and debugging statements to the output buffer on several occassions. This is an utility class, used by other code to log into a game. Error conditions should set a specific attribute that other code can use to detect an error and show an appropriate message such as "The server is currently under maintanance. Please try again later." when a database is not found, while you log useful information for developers only. Similarly, you can show a similar message when the player is, for example, already logged into the game. Don't show sql errors to the user. They belong in a private error log somewhere. Give the user a user-friendly error message instead. The ever-growing switch In your constructor you have an ever-growing switch statement. These details do not belong in this class. You might choose to store them in their own table, or have a file with constants somewhere. You are setting yourself up for a world of hassle by duplicating login data, id's etc. over several files, then having to change them everywhere and potentially forgetting something. Class naming I don't think Login is a good name for this particular class. What you seem to try to emulate is a game session, so you probably should name it that instead. Token generation I am not sure what you are trying to accomplish with your token generation. uniqid() has two optional parameters, the first being a string containing a prefix, the second being a boolean to have more entropy. You seem desperate to get something unique, so you generate a random number between 0 and rand_max (which is then converted to a string for a prefix), and set "more entropy" to true, so you generate an even bigger token. Uniqueness is still not guaranteed though. Then you throw it through md5(), which is a hash function, which will thus increase the likelyhood that your token matches an other token.
{ "domain": "codereview.stackexchange", "id": 22901, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "beginner, php, object-oriented, authentication, mysqli", "url": null }
error-correction, stabilizer-code $^1$ The question doesn't specify the convention used, but some generators in Nielsen & Chuang anti-commute with the candidate (weight three) logical operators while all generators in Gottesman commute with them.
{ "domain": "quantumcomputing.stackexchange", "id": 4430, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "error-correction, stabilizer-code", "url": null }
quantum-mechanics, electromagnetism, magnetic-fields Title: Townsend's Quantum Mechanics Text Question We're using Townsend's A Modern Approach to Quantum Mechanics for our QM class, and I'm just rereading Chapter 1 right now. Perhaps I'm reading too closely to the first section (in which, really, Townsend's only aim is to motivate the theory and formalism for QM based on the observed deviations from classical theory in the SG experiment), but I'm bogged by the way Townsend ends the section (1.1). I imagine it's just me not understanding classical E&M: Incidentally, we chose to make the bottom N pole piece of the Stem-Gerlach (SG) device the one with the sharp tip for a simple reason. With this configuration, $B_z$ decreases as $z$ increases, making $\frac{\partial B_z}{\partial z}$ negative. As we noted earlier, atoms with a negative $\mu_z$ are deflected upward in this field. Now an electron has charge $q = - e$ and from (1.3) with $g = 2$, $\mu_z = (-\frac{e}{m_ec})S_z$. Thus a silver atom with $S_z = h/4\pi$, a spin-up atom, will conveniently be deflected upward. Here is the SG setup he is alluding to:
{ "domain": "physics.stackexchange", "id": 71182, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "quantum-mechanics, electromagnetism, magnetic-fields", "url": null }
navigation, odometry, ros-melodic --- header: seq: 3088 stamp: secs: 1583007758 nsecs: 438024746 frame_id: "odom" child_frame_id: "base_link" pose: pose: position: x: -19.4368515607 y: -17.7955061665 z: 0.0 orientation: x: 0.0 y: 0.0 z: 0.702041753232 w: 0.71213578531 covariance: [0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01] twist: twist: linear: x: 0.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.0 covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] --- header: seq: 3089 stamp: secs: 1583007758 nsecs: 538186524 frame_id: "odom" child_frame_id: "base_link"
{ "domain": "robotics.stackexchange", "id": 34527, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "navigation, odometry, ros-melodic", "url": null }
python, python-3.x, image, pathfinding Title: Pathfinder from image file I've created a simple pathfinder programme that receives its input from a very small .png file. Example file here: Here's a link to the file (note that the green pixel represents the start, the red pixel represents the end and black pixels represent walls). Also, the file needs to be saved as map.png, in the same folder that the programme is running, for it to be recognised as the input. Although the programme generally works, it often fails to find a path to the exit in more complicated mazes. I'm certain there are many improvements that could be made to make it work in a more efficient way. from PIL import Image import sys, numpy class Node(object): distance = 0 end = False start = False pathItem = False def __init__(self, color, position): self.color = color; self.position = position if color == "0, 0, 0": self.passable = False else: self.passable = True def updateDistance(self, end): diffX = abs(end[0]-self.position[0]) diffY = abs(end[1]-self.position[1]) self.distance = diffX+diffY if self.distance < 10: self.distance = "0"+str(self.distance) else: self.distance = str(self.distance) def checkAround(self): #returns how many available nodes are passable around self. Excluding diagonal counter = [] x = self.position[0] y = self.position[1] if x < width-1: if map[y][x+1].passable: counter.append("r") if x > 0: if map[y][x-1].passable: counter.append("l") if y < height-1: if map[y+1][x].passable: counter.append("d") if y > 0: if map[y-1][x].passable: counter.append("u") return counter
{ "domain": "codereview.stackexchange", "id": 21639, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-3.x, image, pathfinding", "url": null }
python, pandas, powerbi Is there a way to achieve this effect in less than 10 lines of code using Python/Pandas plus some html parser opensource library? Or should I resign myself to writing lower level code to handle this? With a bit of parsing via BeautifulSoup, we can get a pandas.Dataframe using pandas.read_html() like: Code: def get_tables(source): elems = iter(BeautifulSoup(source, 'lxml').find_all(['table', 'h1'])) df = pd.DataFrame( pd.read_html(str(next(elems)), header=0)[0].iloc[0].rename(h1.text) for h1 in elems) df.index.names = ['Caption'] return df Test Code: import pandas as pd from bs4 import BeautifulSoup with open('test.html', 'r') as f: print(get_tables(f)) Results: Col1 Col2 Col3 Caption Group 1 ValA ValB ValC Group 2 ValP ValQ ValR
{ "domain": "datascience.stackexchange", "id": 3539, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, pandas, powerbi", "url": null }
Guldin's rule then yields the volumina \begin{align} V_\pm &= \ell_\pm\cdot A = 2\pi(R\pm r_c) \cdot \frac12 \pi r^2 = \pi^2 r^2 \left(R \pm \frac4{3\pi}r\right) \\ &= \pi^2 r^2 R \,\pm\, \frac43 \pi r^3 \end{align} which we can express as $$V_\pm = \frac12 V_\text Z \,\pm\, \frac43 \pi r^3$$ where $$V_\text Z = 2\pi R\cdot\pi r^2$$ is the volume of a cylinder of radius $$r$$ and length $$2\pi R$$. (And the summand after the ± is (incidentally?)$$^3$$ the volume of a sphere of radius $$r$$.) Now we can plug in numbers, where I won't do the $$V_\text Z$$ part. Your $$r=0.0005=5\cdot10^{-4}$$ gives \begin{align} V_\pm - \frac12 V_\text Z &= \frac43 \pi r^3 \\ &= \frac43 \pi \cdot 0.0005^3 = \frac43 \pi \cdot 1.25 \cdot 10^{-10} \\ &= \frac \pi{6 \cdot 10^9} \end{align} And there you have it! Why is this? Because the difference in volume is independent of $$R$$ and only depends on $$r$$. This is much easier to infer from formulae than by staring at magic numbers :-) ...and there wasn't even a need to plug in $$r=0.0005$$. $$^1$$Perhaps "Centroid" is more common in English than center of mass. $$^2$$Tthe needed integral is hidden in your calculation already.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9850429107723175, "lm_q1q2_score": 0.8430501086181742, "lm_q2_score": 0.8558511506439708, "openwebmath_perplexity": 333.9106226213065, "openwebmath_score": 0.9708139300346375, "tags": null, "url": "https://math.stackexchange.com/questions/4258161/why-do-two-half-toruses-add-up-to-the-same-volume" }
industrial-robot Title: What happens from code to robotic action? Starting in the code and through the hardware, what is the "path" that explains the robotic movement. Are there electrical signals involved? How they are initiated and formed and/or interpreted then by the "machine"/robot? Can you explain what happens from code to robotic action? what is the "path" that explains the robotic movement Normally, a path refers to a path in the robot configuration space. Think of it like this. Suppose a robot has 6 joints. When you want to move the robot from pose A, at which the values of those motors -- a configuration -- are $q_A = [0, 0, 0, 0, 0, 0]$, to pose B, with $q_B = [1, 1, 1, 1, 1, 1]$. (Each of the numbers may be specified in radian, for example.) Roughly speaking, a path for that robot is a (continuous) vector-valued function $p$. It takes a time parameter $t$ as an input and outputs the configuration on the path at time $t$. So if the above motion takes $5$ seconds, $p(0) = q_A$ and $p(5) = q_B$. But when one actually communicates with the robot (or rather with the robot controller), one does not tell the robot where it is supposed to be at every single time instant. Instead, one only gives the robot a set of waypoints -- points spread along the path $p$ that the robot needs to pass through. (Those waypoints are generally not too far from one another.) And then the controller then kind of guess what is between two waypoints and tells the robot to move accordingly. Are there electrical signals involved? Yes. How they are initiated and formed and/or interpreted then by the "machine"/robot?
{ "domain": "robotics.stackexchange", "id": 1360, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "industrial-robot", "url": null }
Note that the rows of my $E$ add up to the 1st row of OP's $E$, while 3 times row 1 plus 4 times row 2 of my $E$ gives 4 times row two of OP's $E$, so both matrices have the same row space. More generally, there is a basis for the nullspace containing, for each non-pivot column, one vector where that component is 1 and the other non-pivot components are zero, and the exact value of such vectors is easily read off from the reduced row-echelon form. - So the null space of the null space of a matrix, is that matrix's row space? Makes sense; that's what I was missing, this understanding. Thanks! –  dlaser Sep 29 '13 at 21:15 That's what I meant when I wrote, "the nullspace and the row space are orthogonal complements to each other" (which I think is a better way to say it, as I am comfortable talking about the nullspace of a matrix, but not the nullspace of a vector space). –  Gerry Myerson Sep 29 '13 at 23:03
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9799765610497293, "lm_q1q2_score": 0.8101581809326305, "lm_q2_score": 0.8267117940706734, "openwebmath_perplexity": 189.97294660002268, "openwebmath_score": 0.8969999551773071, "tags": null, "url": "http://math.stackexchange.com/questions/508216/is-there-a-simple-way-to-find-a-matrix-whose-null-space-is-the-span-of-a-given-s/508497" }
javascript, algorithm, array But the interviewer was not satisfied; but appreciated my application of logic. Is there a better solution for the above problem. Requesting to please do a code review and also suggest if I can do better here, please guide me, waiting for valuable reply. Flag variables are ugly Flag variables generate mental overhead. You set a flag to something, and then later you check its value to do something. You have to register the intention of the flag variable in your memory, remember it when you see it again. And the best part, make sure to not change it incorrectly. When the program doesn't work as intended, one of the first debugging steps is verifying that the flag variable wasn't modified somewhere by mistake. It's very annoying. Always look for ways to achieve your purpose without flag variables when possible. A very good way to get rid of a flag variable is to introduce a helper function. Let's eliminate isDuplicateFound used in the second implementation: function unique(nums) { var unique = [], seen = new Tracker(), index, num; for (index = 0; index < nums.length; index++) { num = nums[index]; if (!seen.contains(num)) { unique.push(num); seen.add(num); } } return unique; } What is Tracker? I don't know, but I know it should have contains and a add methods. This implementation is short, and hopefully easy to read, with distractions removed. The essence of the implementation logic should be quite clear and natural. Of course the Tracker and its methods are missing. The interview would likely ask to implement those. Time complexity You haven't mentioned anything about the time complexity of the implementation. It's important to mention that during an interview, and discuss about alternatives. Your implementation was \$O(N^2)\$. The example started in the previous section still leaves that question open. Using a hash set, it could become \$O(N)\$.
{ "domain": "codereview.stackexchange", "id": 26272, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "javascript, algorithm, array", "url": null }
c#, winforms, reflection private void AddControls() { foreach (Control ctrl in formControls) { MainPanel.Controls.Add(ctrl); // MainPanel is a Panel Control } } Can it be simplified? I may have to add more types to it. In my commented I suggested a class that could do what you want it to do out of the box. However sometimes having a custom piece of code to show things in a better way is the goal. I can see this going in two different ways. One is to use a variation of the Visitor pattern and a list, and the other is to use a dictionary with Type and the key, and the class that represents how to view it as the value. The first way you could make the IVisitor interface one of two ways. public interface IVisotor { //option 1 void Accept(Control control); //option 2 bool Accept(Control control); } then to implement you'd make a new class per type that you want to show a specific way. Here is an example with both. public class StringVisitor : IVisitor { public bool Accept(PropertyInfo property, Control control) { if(property.PropertyType != typeof(string)) return false; Accept(control); return true; } public void Accept(Control control) { control = new TextBox(); control.Tag = "String"; control.Size = new System.Drawing.Size(170, 20); } } Now in your class you have two options, make a List<IVisitor> or make a Dictionary<Type, IVisitor>. Here is an example of what I mean. It is by no means complete (and might even have a compiler error as I did it in Notepad++) public class PropertyViewer { private readonly List<IVisitor> visitors1; private readonly Dictionary<Type, IVisitor> visitors2; public PropertyViewer() { visitors1 = new List { new StringVisitor(), //... };
{ "domain": "codereview.stackexchange", "id": 15889, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c#, winforms, reflection", "url": null }
catkin, ros-indigo, rosbuild Title: how to replace rosbuild_link_boost() with the catkin macro I am trying to convert a rosbuild package(DSP-3000 package source) to catkin package. Currently on section 1.3 step 5 of this tutorial. In the old package (rosbuild), the DSP-3000/CMakeLists.txt has the following: cmake_minimum_required(VERSION 2.4.6) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) rosbuild_init() rosbuild_add_boost_directories() set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) include_directories(cereal_port/include) rosbuild_add_executable(dsp3000 src/dsp3000.cpp) target_link_libraries(dsp3000 cereal_port) rosbuild_link_boost(dsp3000 thread) add_subdirectory(cereal_port) The tutorial said If rosbuild macros were used, switch from rosbuild macros to the underlying CMake commands. so, I replaced all the rosbuild macros with catkin macros, shown below: cmake_minimum_required(VERSION 2.4.6) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) find_package() set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) include_directories(cereal_port/include) add_executable(dsp3000 src/dsp3000.cpp) target_link_libraries(dsp3000 cereal_port) add_subdirectory(cereal_port)
{ "domain": "robotics.stackexchange", "id": 30796, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "catkin, ros-indigo, rosbuild", "url": null }
homework-and-exercises, electromagnetism, waves, newtonian-gravity Title: Two balls are dropped from the same height. Ball A is metallic and B, made up of an insulating material. Which of them touches ground first? General motion under gravity states that both of them reach the ground simultaneously. But here, ball B reaches first. I searched for the solution but couldn't find any. Does it have anything to do with Earth's electromagnetic field?? If yes, then please explain. Question source https://questions.examside.com/past-years/jee/question/pspherical-insulating-ball-and-a-spherical-metallic-ball-o-jee-main-physics-motion-bql7sgt3pxedb8dt [2]: https://i.stack.imgur.com/LhUZZ.jpg The web-site's arguement, that the insulating ball will reach the earth's surface first, appears valid so long as there is some change in the magnitude or orientation of the magnetic field over the path taken by the balls. It is probably simplest to argue from the point of view of conservation of energy rather than attempting a force calculation. The changing flux will generate an emf proportional to $\cfrac{d\Phi}{dT}$ that will induce circulating currents and/or charge separation in the conducting ball. So a fraction of the initial gravitational potential energy of the conducting ball will be converted into inductive or capacitive energy storage (and heat as currents decay) instead of kinetic energy, hence it will fall (slightly) slower. A more extreme version of this behaviour can be observed if you push a (non-ferromagnetic) conductor into a large magnetic field. A copper rod inserted in this manner can feel like it is being pushed through treacle.
{ "domain": "physics.stackexchange", "id": 97287, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, electromagnetism, waves, newtonian-gravity", "url": null }
c++, c++11, template-meta-programming template<template<typename> typename Pred, typename... Ts> struct type_list_filter<type_list_end, Pred, Ts...> { using type = typename type_list_builder<Ts...>::type; }; } template<typename... Ts> using List = typename impl::type_list_builder<Ts...>::type; template<typename TypeList, typename T> static constexpr bool Contains() { return impl::type_list_contains<TypeList, T>::value; } template<typename TypeList, typename T> static constexpr size_t IndexOf() noexcept { static_assert(Contains<TypeList, T>(), "TypeList does not contain T"); return impl::type_list_index_of<0u, TypeList, T>::value; } template<typename TypeList> static constexpr size_t Size() noexcept { return impl::type_list_size<0u, TypeList>::value; } template<template<typename...> typename Target, typename TypeList> using Rename = typename impl::type_list_rename<Target, TypeList>::type; template<typename TypeList, template<typename> typename Pred> using Filter = typename impl::type_list_filter<TypeList, Pred>::type; } } mpl_sizes.h #pragma once namespace MPL { namespace Sizes { namespace impl { struct size_list_end{}; template<size_t I, size_t... Is> struct size_list { static const constexpr size_t current = I; using next = size_list<Is...>; }; template<size_t I> struct size_list<I> { static const constexpr size_t current = I; using next = size_list_end; };
{ "domain": "codereview.stackexchange", "id": 26918, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, c++11, template-meta-programming", "url": null }
c++, c++11, template, vectors Title: A vector implementation I am an undergraduate currently learning data structures and C++. I am trying to implement some simplified STL containers. Here is my implementation of vector, which does not have the allocator. My objective is to understand the mechanics how the vector works behind the scenes as well as practice modern C++ techniques. I have also published code under github. Here is the link: https://github.com/TohnoYukine/DataStructures #pragma once #include <stdexcept> #define MAX_VECTOR_SIZE 1073741824U //1GB namespace DataStructures { template<typename T> class Vector { public: using value_type = T; using reference = T&; using const_reference = const T&; using pointer = T*; using const_pointer = const T*; using difference_type = ptrdiff_t; using size_type = size_t; using iterator = T*; using const_iterator = const T*; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; //Constructor, Destructor and Assignment Vector() noexcept; explicit Vector(size_type n); Vector(size_type n, const T& val); Vector(const_iterator first, const_iterator last); template<typename InputIterator, typename = typename std::enable_if_t<std::_Is_iterator<InputIterator>::value>> Vector(InputIterator first, InputIterator last);
{ "domain": "codereview.stackexchange", "id": 28148, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, c++11, template, vectors", "url": null }
java, beginner, linked-list This specifies a complete ordering of the data, but the problem doesn't. Yes, this is a correct ordering, but there are others. For example 3, 2, 1, 10, 8, 5, 5 Is an entirely valid ordering. But this test would fail it. Consider for (int i = 0; i < 3; i++) { assertNotNull(n); assertTrue(n.data < partitionValue); n = n.next; } for (int i = 3; i < 7; i++) { assertNotNull(n); assertFalse(n.data < partitionValue); n = n.next; } This tests the actual assertion, that the list would be partitioned such that the first three elements were less than the partitionValue and the next four were not. So if you changed the function to preserve the original ordering within each partition, this would pass. The current test would fail. 1, 2, 3, 10, 5, 8, 5 does not match int[] expected = new int[]{1, 2, 3, 5, 8, 5, 10};. Or note that the example output in the question would not match the test although it is a valid ordering of the input. One advantage of the current version is that it tells you what element it finds that it should not have found there. But you can restore that behavior if you want. Consider String message = "Found " + n.data + " at " + i + " which is less than " + partitionValue; assertFalse(message, n.data < partitionValue); You can control what message is shown if you want. So use that to make the message informative if you need that.
{ "domain": "codereview.stackexchange", "id": 22100, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, beginner, linked-list", "url": null }
python, beginner, python-3.x print("Copying...") try: shutil.copytree(old_directory, new_directory) print("Successfully copied files to directory %s" % new_directory) except IOError as error: print(error) copy_directory() copy_directory() remove_dirs() Add following header for *nix users #!/usr/bin/env python # ~*~ codding: utf-8 ~*~ Not required variable definition test_dir = None Because of loop for test_dir in dirs: Use native generator insted def get_dirs(dirs): """Get all immidiate directories in the current directory""" if not len(dirs) > MAX_DIRS: return [] for test_dir in dirs: try: yield datetime.strptime(test_dir, TIME_FORMAT) except ValueError: print("Directory %s does not match date format, ignoring..." % test_dir) If you will use it like module, add if __name__ == '__main__': copy_directory() remove_dirs() IMHO: don't use direct input with input(), try parse command line instead using sys.argv or with help of some more powerful libraries.
{ "domain": "codereview.stackexchange", "id": 9771, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, beginner, python-3.x", "url": null }
c++, algorithm, stack } int Mystack::pop() { if (isEmpty()) { std::cout << "Stack Underflow" << std::endl; return 0; } else { std::cout << "The popped element is" << A[top]; return A[top--]; } } bool Mystack::isEmpty() { if (top == -1) { std::cout << "Stack is empty" << std::endl; return true; } else { std::cout << "Stack is not empty" << std::endl; return false; } } int Mystack::topElement() { std::cout<<"The top element is : "<< A[top]; return A[top]; } void Mystack::print() { for (int i = 0; i <=top; i++) { std::cout << A[i]<< " "; } } void main() { Mystack s1; int num,choice = 1; while (choice >0) { std::cout << "\n1. PUSH"<< std::endl; std::cout << "2. TOP" << std::endl; std::cout << "3. IsEmpty" << std::endl; std::cout << "4. POP" << std::endl; std::cout << "5. EXIT" << std::endl; std::cout << "6. Print" << std::endl; std::cout << "7. IsFull" << std::endl; std::cout << "Enter the choice" << std::endl; std::cin >> choice; switch (choice) { case 1: std::cout << "Enter the number to be pushed" << std::endl;
{ "domain": "codereview.stackexchange", "id": 11404, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, algorithm, stack", "url": null }
Matrix B then, preserves the difference between the legs. If we take (3,4,5) and repeatedly apply the transformation B, we get (21, 20, 29); (119, 120, 169); etc. I’m sure there is more hidden in the fabric of Barning trees, so if you see what I didn’t, drop me a line. ## Saturday, 20 September 2008 ### Pythagoras and Matrices You can click on any image to expand it and make it sharper It’s been a good weekend for Geometry for me. Several notes from folks telling me about geometry stuff I never knew… While I’m waiting on permission from the author of one, I wanted to tell you about the other.. The graph (tree) below shows a set of Primitive Pythagorean triples… All the ones with hypotenuse less than 100. Primitive Pythagorean triples are right triangles that have all sides as integers and none of them have a common factor. What was new (to me) was that any one of them (and all the others not shown here) can be found as transformations of (4,3,5) using only three transformations. Let me make that clearer. If you think of a primitive Pythagorean triple as a point in three-space, then any other primitive Pythagorean triple is a point in three space that is just a transformation of this one… but there are only three transformations needed to get ALL of them. The tree shows which ones are generated by which ones, but you need to crank out the calcualtor and do some of these to see how neat it really is. This type of graph is called a Barning-Tree because it seems to have first been discovered by F. J. M. Barning, “On Pythagorean and quasi-Pythagorean triangles and a generation process with the help of unimodular matrices, (Dutch) Math. Centrum Amsterdam Afd. Zuivere Wisk, ZW-011 (1963) 37 pp..
{ "domain": "com.es", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9919380075184122, "lm_q1q2_score": 0.8222559140729097, "lm_q2_score": 0.8289388125473628, "openwebmath_perplexity": 1112.7468124861077, "openwebmath_score": 0.47979435324668884, "tags": null, "url": "http://pballew.blogspot.com.es/2008/09/" }
image-processing, computer-vision This seems a slightly better weight function. I added also cutoffs $\omega_c = \pi/32$ and $\omega_c = \pi/64$. They use larger N resulting in a different cropping of the image and not strictly comparable MSCD values. 1-d histogram The benefit of the square-length weight function is more apparent with a 1-d weighted histogram of $Z_k$ phases. Python script: # Optional histogram hist_plain, bin_edges = np.histogram(np.arctan2(imZ, reZ), weights=np.ones(absZ.shape)/absZ.size, bins=900) hist, bin_edges = np.histogram(np.arctan2(imZ, reZ), weights=absZ/np.sum(absZ), bins=900) hist_alt, bin_edges = np.histogram(np.arctan2(imZ_alt, reZ_alt), weights=absZ_alt/np.sum(absZ_alt), bins=900) plt.plot((bin_edges[:-1]+(bin_edges[1]-bin_edges[0]))*45/np.pi, hist_plain, "black") plt.plot((bin_edges[:-1]+(bin_edges[1]-bin_edges[0]))*45/np.pi, hist, "red") plt.plot((bin_edges[:-1]+(bin_edges[1]-bin_edges[0]))*45/np.pi, hist_alt, "blue") plt.xlabel("angle (degrees)") plt.show()
{ "domain": "dsp.stackexchange", "id": 7521, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "image-processing, computer-vision", "url": null }
selected. Probability Study Tips. When calculating the probability of dependent events we must take into account the effect of one event on the other. So the probability that it will not rain tomorrow is 0. Let’s think of cases where this happens:. Captain Luis has a ship, the H. The resilience of a system is generally defined in terms of its ability to withstand external perturbations, adapt, and rapidly recover. In online poker, the options are whether to bet, call, or fold. player (probability p 2) and also you win against at least one of the two other players [probability p 1 + (1 p 1)p 3 = p 1 + p 3 p 1p 3]. The strong e ect of !ˇ!0 on Pa!b(t) is easily illustrated by plotting Pa!b as a function of ! for xed t, yielding a function which falls o rapidly for !6= !0. , Define the events and as follows: Their respective probabilities are The probability of the event is Hence, As a consequence, and are independent events. Two events, and , are called independent if and only if ; otherwise, they are called dependent. This principle can be extended to any number of individual. The is the set of all. the probability of a transition drops to zero periodically. Probability is the mathematical term for the likelihood that something will occur, such as drawing an ace from a deck of cards or picking a green piece of candy from a bag of assorted colors. 2 - Determine the probability of simple events involving independent and dependent events and conditional probability. The toss of a coin, throw of a dice and lottery draws are all examples of random events. The intersection of A and B, and the probability of B. In contrast, any group that has a below-average mean on the covariate will have its mean score on the dependent variable raised. Dependent essentially mean without replacement in this case. Penrose GED Prep 4. Please enter the necessary parameter values, and then click 'Calculate'. Students will find the probability of dependent events. In other words, one event depends on the other. The probability of a transition between one atomic stationary state and some other state can be calculated with the aid of the time-dependent Schrödinger equation. Fun maths practice! Improve your skills with free problems in 'Probability of independent and dependent events' and thousands of other practice lessons. In
{ "domain": "lepettinose.it", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.98657174604767, "lm_q1q2_score": 0.808883604326827, "lm_q2_score": 0.8198933403143929, "openwebmath_perplexity": 457.2867079604051, "openwebmath_score": 0.6957274675369263, "tags": null, "url": "http://khpj.lepettinose.it/dependent-probability.html" }
homework-and-exercises, newtonian-mechanics, forces, kinematics, vectors Title: How to use equation of motion like this here? So I will explain my problem exactly what it is.Please do answer in such a format by telling me places where I am wrong from the text I write.I posted this question earlier also but I noticed many of them to give answers which I didn’t even ask and had to explain all the things again in the comments. In the end , some of them leave in between or some don’t even tell the reason why the post is not good.So please check upon these points. Questions is as follows: Q : particle of mass 1 kg has a velocity of 2 m/s. A constant force of 2 N acts on the particle for 1 s in a direction perpendicular to its initial velocity. Find the velocity and displacement of the particle at the end of 1 second. My questions: Doubt regarding direction of force: Force means push or pull. In image 1, I drew the force in downwards direction or pulling force (downward vector) which is perpendicular to u (right direction) Image 2 I drew the force in upwards direction or pushing force (upward vector) which is perpendicular to u (right direction). So which of these 2 images is right ? Question doesn’t specify it. Also, whether what I though is right or not? Doubt 2:: In the solution, they have made the equations of motion into two mutually perpendicular vectors.
{ "domain": "physics.stackexchange", "id": 74836, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "homework-and-exercises, newtonian-mechanics, forces, kinematics, vectors", "url": null }
"the number of Heads is between $a_n$ and $b_n$", and "the number of Heads is between $b_n$ and $2^n$" has approximately the probability $\frac{1}{3}$. Alternatively, you could apply your procedure to get four outcomes with the same probability (Heads-Heads, Tails-Tails, Heads-Tails, Tails-Heads) to your problem in the following way: Associate the three outcomes Heads-Heads, Tails-Tails, Heads-Tails with your three possible choices. In the case that Tails-Heads occurs, just repeat the experiment. Sooner or later you will find an outcome different from Tails-Heads. Indeed, by symmetry, the probability for first Heads-Heads, first Tails-Tails, or first Heads-Tails is $\frac{1}{3}$, respectively. (Alternatively, you could of course throw a die and select your first choice if the outcome is 1 or 2, select your second choice if the outcome is 3 or 4, and select your third choice if the outcome is 5 or 6.) - Can't you count tails-heads as the same as heads-tails? –  Tyler Hilton Aug 13 '10 at 15:26 @Affan, it would not be fair as that possibility would occur with the same probability as the other two combined. –  Joshua Shane Liberman Aug 13 '10 at 15:35 Oh I get ya, thanks! –  Tyler Hilton Aug 13 '10 at 17:15 I think what Rasmus meant (in the second part) is that you would always toss in pairs and take into account the order of the two tosses: only if the first toss (of a pair) is tails and the second toss is heads toss the coin another two times. –  Andre Holzner Aug 19 '10 at 18:58 A simple (practical, low-computation) approach to choosing among three options with equal probability exploits the fact that in a run of independent flips of an unbiased coin, the chance of encountering THT before TTH occurs is 1/3. So: Flip a coin repeatedly, keeping track of the last three outcomes. (Save time, if you like, by assuming the first flip was T and proceeding from there.) Stop whenever the last three are THT or TTH.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9702399026119353, "lm_q1q2_score": 0.8021087705672685, "lm_q2_score": 0.8267117940706734, "openwebmath_perplexity": 798.5174683652874, "openwebmath_score": 0.7787874937057495, "tags": null, "url": "http://math.stackexchange.com/questions/2356/is-it-possible-to-split-coin-flipping-3-ways/2357" }
gene-expression, rna Title: Expression of bidirectional promoters How are bidirectional promoters expressed ? (Won't RNA Pol have to go in 3'-5' direction?) Why are they more commonly found in eukaryotes than prokaryotes? Genes controlled by bidirectionl promoters are in head-to-head configurations, meaning that their 5' ends are facing one-another. Remember that DNA is double stranded, so this means one gene is on the 'top' strand and one gene is on the 'bottom' strand. Check out the diagram below, genes are in capitals, bidirectional promoter in parenthesis. Both genes are transcribed 5'->3' --> Gene 1 5'-atgcagtcatga(ctgactaagt...tcagtcatga)CTGACTGACTAGTCAT-3' |||||||||||| ||||||||||||||||||||||| |||||||||||||||| 3'-TACGTCAGTACT(gactgattca...agtcagtact)gactgactgatcagta-5' Gene 2 <-- As for why they are more commonly found in eukaryotes, those questions are definitely hard to answer. It has been shown that genes on bidirectional promoters are expressed together more often than two genes that are next to each other on different promoters. That means this might be a eukaryotic strategy similar to prokaryote's usage of polycistronic mRNA, an easy way to have similar expression patterns of genes that should often be expressed in similar amounts.
{ "domain": "biology.stackexchange", "id": 1254, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gene-expression, rna", "url": null }
java, unit-testing @Test public void testRunWithDefaults() { new DefaultRunner(RunWithDefaults.class).run(); assertEquals(1, runCount); } } What I don't like is the runCount static variable, manipulated from inside the annotated method. Initially I wanted to use mocks (with Mockito), but couldn't really see how to do this. I'm wondering if I'm missing something. For reference, not necessarily for review, here's the complete test class: public class DefaultRunnerTest { public static int runCount = 0; public static int runCountOfCustom = 0; @Benchmark public static class RunWithDefaults { @MeasureTime public void sample() { ++runCount; } } @Before public void setUp() { runCount = 0; runCountOfCustom = 0; } @Test public void testRunWithDefaults() { new DefaultRunner(RunWithDefaults.class).run(); assertEquals(1, runCount); } @Benchmark(iterations = 5) public static class RunWith5Iterations { @MeasureTime public void sample() { ++runCount; } } @Test public void testRunWith5Iterations() { new DefaultRunner(RunWith5Iterations.class).run(); assertEquals(5, runCount); } @Benchmark(warmUpIterations = 3) public static class RunWith3WarmUpIterations { @MeasureTime public void sample() { ++runCount; } } @Test public void testRunWith3WarmUpIterations() { new DefaultRunner(RunWith3WarmUpIterations.class).run(); assertEquals(3 + 1, runCount); } @Benchmark(iterations = 5, warmUpIterations = 3) public static class RunWith5Iterations3WarmUpIterations { @MeasureTime public void sample() { ++runCount; } }
{ "domain": "codereview.stackexchange", "id": 10115, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, unit-testing", "url": null }
c++, beginner, object-oriented, http, client void httpRequest::initialize(std::string methodName, std::string hostName, std::string uriValue) { this->method = methodName; this->httpVer = "HTTP/1.1"; this->host = hostName; this->uri = " " + uriValue + " "; } std::string httpRequest::parseHeaders() { for(int i = 0; i < this->headers.size(); i++) { this->parsedHeaders += this->headers.at(i); } return this->parsedHeaders; } void httpRequest::setMethod(std::string methodName) { this->method = methodName; } void httpRequest::setHost(std::string hostName) { this->fullHost = "HOST: " + hostName; this->host = hostName; } void httpRequest::setUri(std::string uriValue) { this->uri = " " + uriValue + " "; } void httpRequest::addHeader(std::string httpHeader) { this->headers.push_back(httpHeader + "\r\n"); } void httpRequest::buildRequest() { this->fullRequest = this->method + this->uri + this->httpVer + "\r\n"; this->fullRequest = this->fullRequest + this->fullHost + "\r\n"; this->fullRequest = this->fullRequest + this->parseHeaders() + "\r\n"; this->fullRequest = this->fullRequest + "\r\n"; } std::string httpRequest::getHost() { return this->host; } std::string httpRequest::toString() { return this->fullRequest; }
{ "domain": "codereview.stackexchange", "id": 17614, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, beginner, object-oriented, http, client", "url": null }
ros, care-o-bot Title: Building cob_people_detection package on Hydro Hello, I'm currently running Ros Hydro on Ubuntu 12.04 and I want to use a Kinect for face recognition. I found the cob_people_detection package and downloaded cob_people_perception-hydro_dev to my catkin_ws/src/ folder, but when I try to build it with catkin_make I get errors concerning several configuration files, like this ones: CMake Error at /opt/ros/hydro/share/catkin/cmake/catkinConfig.cmake:75 (find_package): Could not find a configuration file for package cob_image_flip. CMake Error at /opt/ros/hydro/share/catkin/cmake/catkinConfig.cmake:75 (find_package): Could not find a configuration file for package cob_perception_msgs. Here is the complete log. I tried deleting the devel and build folders, and then building, but I get the same error. I don't have a similar problem with any of the other packages I'm using, so I'm not sure if I'm missing something here. Thank you in advance,
{ "domain": "robotics.stackexchange", "id": 21612, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, care-o-bot", "url": null }
in the comments section. At what speed does the second train B travel if the first train travels at 120 km/h. You can approach this as if you were solving for an unknown in math class or you can use the speed triangle. Time, Speed and Distance: Key Learnings. ) Since the distances are the same, I set the distance expressions equal to get: Unit of speed will be calculated based on unit of distance and time. Distance, Rate and Time content standard reference: grade 6 algebra and functions 2. aspxCollins Aerospace ARINCDirect maintains a multitude of data on airports and airways around the world. My other lessons on Travel and Distance problems in this site are - (Since the speed through the steel is faster, then that travel-time must be shorter. Initial speed of the car = 50km/hr Due to engine problem, speed is reduced to 10km for every 2 hours(i. 5th Grade Numbers Page 5th Grade Math Problems As with the speed method of calculation, the denominator must fit into 60 minutes. In National 4 Maths use the distance, speed and time equation to calculate distance, speed and time by using corresponding units. Distance divided by rate was equal to time. Pete is driving down 7th street. Speed, Distance, Time Worksheet. This Speed Problems Worksheet is suitable for 4th - 6th Grade. If the speed of the jeep is 5km/hr, then it takes 3 hrs to cover the same For distance word problems, it is important to remember the formula for speed: Definition: Speed = Distance/Time. An executive drove from home at an average speed of 30 mph to an airport where a helicopter was waiting. Again, if you look at the formula triangle, you can see that you get distance by multiplying speed by time. Next time you are out walking, imagine you are still and it is the world that moves under your feet. Q) Mr. Distance is directly proportional to Velocity when time is constant. The problem gives the distance in feet and the speed in miles per hour. The detailed explanation will help us to understand how to solve the word problems on speed distance time. Average Speed = Total distance ÷ Total time = 110 ÷ 5/6 = 110 × 6/5 = 132 km/h. 6T + 4T = 20 km. The result will be the average speed per unit of time, usually an hour. We will practice different Distance, Speed and
{ "domain": "carlaandme.dk", "id": null, "lm_label": "1. YES\n2. YES\n\n", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9845754506337407, "lm_q1q2_score": 0.8003292124605091, "lm_q2_score": 0.8128673246376009, "openwebmath_perplexity": 842.279061976792, "openwebmath_score": 0.5783324241638184, "tags": null, "url": "http://carlaandme.dk/atgando/wt2jtp2.php?gakoombkk=speed-distance-time-problems" }
computer-architecture In today's multi-issue processors, the processor will decode several consecutive instructions in the same cycle. Some instructions are complicated and their length may be hard to determine, and only one such instruction can be handled in a cycle. But other times you might have four very simple instructions in a row, and the processor can start executing all four of them, calculating only the program counter after executing the fourth instruction. The address of the 2nd, 3rd and 4th instruction might never make it into the program counter. And then there are processors which translate instructions into RISC instructions. Such a processor may rarely know the program counter, but be able to determine the program counter if needed.
{ "domain": "cs.stackexchange", "id": 18693, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "computer-architecture", "url": null }
astrophysics, stars, supernova Title: Do supernovae push neighboring stars outward? I know that a supernova can mess up the heliosphere of nearby stars, but I'm wondering if it could physically push neighboring stars off their trajectories. It's fun to imagine all the stars surrounding a supernova being propelled outward and tumbling out of the galactic arm! I would expect that a really close star, such as a partner in a binary pair, would get really messed up. I'm thinking more about the neighbors a few light-years away. I realize that a supernova involves both the initial EM burst and the mass ejection which arrives later. I'm open to the effects of any of these things. Consider a star of mass $M$ and radius $R$ at a distance $r$ from the supernova. For a back-of-the-envelope estimate, consider how much momentum would be transferred to the star by the supernova. From that, we can estimate the star's change in velocity and decide whether or not it would be significant. First, for extra fun, here's a review of how a typical core-collapse supernova works [1]: Nuclear matter is highly incompressible. Hence once the central part of the core reaches nuclear density there is powerful resistance to further compression. That resistance is the primary source of the shock waves that turn a stellar collapse into a spectacular explosion. ... When the center of the core reaches nuclear density, it is brought to rest with a jolt. This gives rise to sound waves that propagate back through the medium of the core, rather like the vibrations in the handle of a hammer when it strikes an anvil. .. The compressibility of nuclear matter is low but not zero, and so momentum carries the collapse beyond the point of equilibrium, compressing the central core to a density even higher than that of an atomic nucleus. ... Most computer simulations suggest the highest density attained is some 50 percent greater than the equilibrium density of a nucleus. ...the sphere of nuclear matter bounces back, like a rubber ball that has been compressed. That "bounce" is allegedly what creates the explosion. According to [2],
{ "domain": "physics.stackexchange", "id": 55062, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "astrophysics, stars, supernova", "url": null }
turing-machines, finite-automata, computer-architecture and we have some fixed string p. Consider the following Python function t': def t(x): ... def t'(x): return t(p) Then it is easy to see that the behavior of t' on any input is equivalent to the behavior of t on input p. (Here we have hard-coded a lexical constant string in the place indicated with p above.) You can do the same thing with Turing machines, where the machine first writes $P$ on the tape, and then starts executing $T$, to define a Turing machine $T'$ that proves the claim above.
{ "domain": "cs.stackexchange", "id": 17826, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "turing-machines, finite-automata, computer-architecture", "url": null }
mechanical-engineering, flywheels Title: Calculate Forces on a Flywheel I am working on a flywheel currently, and I was wondering what is the force needed to recenter the flywheel when it is spinning and it is nudged slightly off axis? Is it related to gyroscopic precession? For this answer I'll assume "off-center" means the axis of rotation differs from the desired axis of rotation by angle $\theta$ The goal is to realign the axis of rotation, which can be accomplished by changing the rotational momentum vector. This goal can be achieved by applying forces to the axle. Applying symmetric forces as shown of magnitude $F$ a distance of $R$ from the center will add rotational inertia at a rate of $2FR$ Which will rotate the axis of the Gyroscope at angular rotation rate of $\frac{2FR}{I\omega}$ the axis of which will be perpendicular to the axis of the flywheel and parallel to the force being applied. This process will not change the magnitude of the angular velocity of the flywheel.
{ "domain": "engineering.stackexchange", "id": 728, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "mechanical-engineering, flywheels", "url": null }
sql, sql-server, t-sql SET @SqlCommand = 'SELECT ' + @SQLColumnList + @SqlFromCommand + @SqlWhereCommand + @SqlGroupCommand Not anything groundbreaking, but I use the template replicate(myString,aFlag) to decide to include a string or not. Also, you don't really need the isnull() here, because if your variable is indeed null, all checks fail, including <>''. Here: SET @SqlWhereCommand = @SqlWhereCommand +replicate(' AND Id IN (SELECT val AS linkType FROM dbo.Split(''' + @Ids + ''','',''))' , case when @Ids <> '' then 1 else 0 end) +replicate(' AND LinkTypeId IN (SELECT val As subCategorys FROM dbo.Split(''' + @SubCategories + ''', '',''))' , case when @SubCategories <> '' then 1 else 0 end) +replicate(' AND LanguageId IN (SELECT val As subCategorys FROM dbo.Split(''' + @LanguageIds + ''', '',''))' , case when @LanguageIds <> '' then 1 else 0 end)
{ "domain": "codereview.stackexchange", "id": 45127, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "sql, sql-server, t-sql", "url": null }
catkin-make, ros-kinetic [ 28%] Built target _pr2_msgs_generate_messages_check_deps_SetPeriodicCmd [ 28%] Built target _pr2_msgs_generate_messages_check_deps_BatteryState2 [ 28%] Built target _pr2_msgs_generate_messages_check_deps_DashboardState [ 28%] Built target _pr2_msgs_generate_messages_check_deps_BatteryServer [ 28%] Built target _pr2_msgs_generate_messages_check_deps_SetLaserTrajCmd [ 28%] Built target _pr2_msgs_generate_messages_check_deps_PowerBoardState [ 28%] Built target geometry_msgs_generate_messages_lisp [ 28%] Built target geometry_msgs_generate_messages_nodejs [ 28%] Built target std_msgs_generate_messages_lisp [ 28%] Built target std_msgs_generate_messages_nodejs [ 28%] Built target geometry_msgs_generate_messages_eus [ 28%] Built target std_msgs_generate_messages_eus [ 28%] Built target geometry_msgs_generate_messages_py [ 28%] Built target std_msgs_generate_messages_py [ 28%] Built target std_msgs_generate_messages_cpp [ 28%] Built target geometry_msgs_generate_messages_cpp [ 28%] Built target _pr2_msgs_generate_messages_check_deps_GPUStatus [ 28%] Built target _ur_msgs_generate_messages_check_deps_SetIO [ 28%] Built target _ur_msgs_generate_messages_check_deps_ToolDataMsg [ 28%] Built target _ur_msgs_generate_messages_check_deps_RobotStateRTMsg [ 28%] Built target _ur_msgs_generate_messages_check_deps_IOStates [ 28%] Built target _ur_msgs_generate_messages_check_deps_MasterboardDataMsg
{ "domain": "robotics.stackexchange", "id": 30866, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "catkin-make, ros-kinetic", "url": null }
electrochemistry, experimental-chemistry, electrolysis That looks like rust, Ferric Oxide, exactly! However, the cell should be Titanium, it contains no iron, but that doesn't mean it can't oxidize. Or "Rust", all metals do, Ti's oxidation would be white and powdery. So either there is a non Ti component inside that cell that contains iron, such as steel that is breaking down, or there's something upstream of it, a Ferrous metal that's rusting, thus producing Ferric Oxide and dribbling down the pipe and into the cell. Is there any on the upstream side of the cell? If not, then it has to be localized to inside the cell. Another though is that you have a very high iron content in your water, mixed with the electrolysis process is causing it to oxidize on the anode, where it combines /w oxygen molecules in the water to form rust, Fe2O3. This would keep it localized to the cell, and not be upstream, only at the cell, since that's the catalyst, or source and slightly downstream as the flow of generated Ferric Oxide tapers off. This shouldn't effect the Ti plates though, just simply clean them with MA and you're golden!! Ti is virtually indestructible, so they should be fine. EDIT: Hayward says to submerge it just to the top of the cell, so the wiring harness, the electronics on the cell are not touching the acid, coiling the harness may be helpful prior to immersing. 4:1 dilute, 1 gallon of water to 1 quart of MA. And remember, always, always add the acid to the water, never, ever the other way around. The manuf. says to soak for a few, then rinse with a high pressure hose, then repeat if needed, until the plates are clean. BTW, Acid attacks Oxides, including Ferric Oxide. Full thread here Related Stackposts: Salt product in water electrolysis
{ "domain": "chemistry.stackexchange", "id": 6782, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "electrochemistry, experimental-chemistry, electrolysis", "url": null }
parsing, prolog %-------------------------------------------------------- % Some colour %-------------------------------------------------------- c_red(Str) :- write('[0;31m'), write(Str),write('[0m'). c_green(Str) :- write('[0;32m'), write(Str),write('[0m'). c_yellow(Str) :- write('[0;33m'), write(Str),write('[0m'). c_byellow(Str):- write('[1;33m'), write(Str),write('[0m'). c_blue(Str) :- write('[0;34m'), write(Str),write('[0m'). c_magenta(Str):- write('[0;35m'), write(Str),write('[0m'). c_cyan(Str) :- write('[0;36m'), write(Str),write('[0m'). c_white(Str) :- write('[0;37m'), write(Str),write('[0m').
{ "domain": "codereview.stackexchange", "id": 1634, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "parsing, prolog", "url": null }
Now as $X$ is connected and as $U$ is a non-empty open subset of $X$, so $U$ cannot be closed. Therefore, $U$ has a limit point $b$, say, that does not belong to $U$. Then $b$ is not an upper bound of set $A$, which implies the existence of an element $a \in A$ such that $b < a$, we can also conclude that $$b \in (-\infty, a) \subset X\setminus U,$$ with $(-\infty, a)$ being an open set. This contradicts our choice of $b$ as a limit point of set $U$. Hence the set $U$ of all the upper bounds in $X$ of set $A$ must have a smallest element, and that element is the least upper bound of $A$. Thus we have shown that every non-empty subset $A$ of $X$ that is bounded above in $X$ has a least upper bound in $X$. Therefore, $X$ has the least upper bound property. (2) Suppose that $a$ and $b$ are any two elements of $X$ such that $a < b$. If there is no element $c \in X$ such that $a < c < b$, then $X$ is the union of the open rays $$(-\infty, b) \colon= \{ \ x \in X \ \colon \ x < b \ \}$$ and $$(a, +\infty) \colon= \{ \ x \in X \ \colon \ a < x \ \},$$ both of which are open sets in the order topology and are also non-empty; the former contains $a$, whereas the latter contains $b$. This contradicts the fact that $X$ is connected. So there exists an element $c \in X$ such that $a < c < b$. Is this proof satisfactory enough? Or else, is there any problem in the logic or presentation thereof? If so, where exactly is this proof in need of improvement or correction? Finally, here is Theorem 24.1 in Munkres:
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9852713861502773, "lm_q1q2_score": 0.8145354731875053, "lm_q2_score": 0.826711791935942, "openwebmath_perplexity": 36.29184720513734, "openwebmath_score": 0.9214931130409241, "tags": null, "url": "https://math.stackexchange.com/questions/2541639/prob-4-sec-24-in-munkres-topology-2nd-ed-if-an-ordered-set-in-the-order-t" }
optics, energy, geometric-optics, fiber-optics, solar-cells This is assuming an ideal lossless beam splitter with all beams perfectly aligned, etc. In reality, you will not get perfect transmission (nor would you in the reverse case) but you will get much better than 50%.
{ "domain": "physics.stackexchange", "id": 34364, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "optics, energy, geometric-optics, fiber-optics, solar-cells", "url": null }
gauge-theory, field-theory, atomic-physics, gauge-invariance, berry-pancharatnam-phase Title: Is the artificial gauge field a gauge field? The so-called artificial gauge fields are actually the Berry connection. They could be $U(1)$ or $SU(N)$ which depends on the level degeneracy. For simplicity, let's focus on $U(1)$ artificial gauge field, or artificial electromagnetic field. One can show that it is indeed gauge invariant. My criterion for a gauge field is that it should satisfy Maxwell's equations (or Yang-Mills' equations in the non-Abelian case). Then I doubt whether the artificial gauge field is really a gauge field. How to write down the $F_{\mu\nu}^2$? What's the conserved current? And can we make gapped Goldstone modes using artificial gauge fields? The Berry connection/Curvature can be formulated as the connection/curvature of a principal bundle over the parameter space, in this sense it can be thought of as a "gauge theory". It can also contain topological information, such as the first Chern number (measuring "magnetic charge"), second Chern number (measuring "instanton charge") etc., so geometrically/topologically it looks like a gauge theory. But it is not a usual gauge field for various reasons. First of all, the Berry connection is a "gauge field" on the parameter space and not the space-time. Secondly, the Berry phase is a purely geometrical/topological object and does not have any dynamics. So I don't think it makes sense to have a Maxwell/Yang-Mills term in the (spacetime) Lagrangian, since these terms contain the dynamical features of a gauge field. Also for this reason, I don't think it makes any sense to talk about conserved currents, etc. for the Berry connection. It is however possible to have emergent dynamical gauge fields, but I only know about these examples in strongly interacting theories (search for example for quantum spin-liquids).
{ "domain": "physics.stackexchange", "id": 5644, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "gauge-theory, field-theory, atomic-physics, gauge-invariance, berry-pancharatnam-phase", "url": null }
c++, object-oriented, game, game-of-life, sfml Menu: We don't need to pass the Settings class in the constructor, just the window size passed in as an sf::Vector2f. Thus we avoid including the settings header. The positioning could definitely be neater. I'm just going to point out that we can get the size of an sf::Text using text.getLocalBounds().width and text.getLocalBounds().height. We can also get a reasonable height for a line of text by doing font.getLineSpacing(text.getCharacterSize()). Either of these could help to lay out the buttons more neatly. Options: Using std::cin is bad! It makes our app unresponsive to normal input and means we can't render anything. Could provide a simple widget with a plus and minus button to change the size, e.g.: "Simulation size: [-] 20 [+]". This could be part of the menu state, or a similar but separate state. One other thing: it's a good idea to put all your code into a namespace. :)
{ "domain": "codereview.stackexchange", "id": 43172, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c++, object-oriented, game, game-of-life, sfml", "url": null }
image-processing Title: Why do we use the top left corner as the origin in image processing? Why do we do this in image processing?: Instead of this?: I propose that the raster scan is a Western invention, in analogy with the way we write: left to right, top to bottom. Remember that "rastrum" denotes a rake. When you rake a surface, or paint a floor, one usually does this such that one does not step on the raked or painted surface. The "raker" or "painter" moves backwards. One wants to avoid the situation described in Painted Into A Corner: This defines a sort of 2D causality, using data for above and if not, from the same level (row) but left. Parsing the 2D space top to bottom then left to right could have been an option. However, we know that the human vision is more sensitive to vertical than to horizontal, as one can see from the JPEG quantization matrix. So perhaps, by going left to right first, the human mind could more easily spot a vertical change in a whole picture. * However, the ancient slowness of a beam parsing a screen is not less important. For web browsing, it can be more important to first display a global low resolution patch and refine it iteratively, like in the progressive JPEG, JPEG 2000, or the clever Adam7 algorithm used in PNG. See for instance http://www.libpng.org/pub/png/pngpics.html
{ "domain": "dsp.stackexchange", "id": 4525, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "image-processing", "url": null }
navigation, service, occupancy-grid, laserscan, publisher Originally posted by jgilsenan on ROS Answers with karma: 181 on 2013-08-30 Post score: 7 Original comments Comment by Thomas D on 2013-08-30: This is a good post. Comment by jorge on 2013-08-30: I personal guess (and as it's just a guess I add a comment instead of an answer) is that publish/subscribe must be less expensive, as services imply both request and response, but the difference must be minimal. Comment by jorge on 2013-08-30: But I think the important point is whether the client needs to know if all went ok and/or must wait for the map to be ready. Those things are provided by a service. Publish/subscribe is a looser relationship, where the publisher don't mind at all about how their messages are used. Comment by jorge on 2013-08-30: Hope I'm not telling bullshit.... Please someone correct me of I'm wrong! Comment by jgilsenan on 2013-08-31: The one benefit I have noticed is that since everything is still in the development phase, and I haven't yet been able to perfectly sync all of my nodes for publishing/subscribing, this eliminates the need to check for "fresh" data since it returns false if a response was not received. If you have multiple other nodes that need map data on a irregular, relatively low rate, on-demand basis, it likely is a good idea to use service calls. This way, bandwidth and CPU (for serialization) are only consumed when needed and (depending on the actual scenario) map data can be more up-to-date than when using the last published map data. I think it´ s pretty hard to state a general rule, as there are multiple factors playing a role here: Service calls for example can´t be recorded with rosbag, which can be a disadvantage when trying to understand interaction in a complex system of nodes. A single service call has higher delay and consumed bandwidth when compared to a single publication on a topic, but using service calls can mean that only single queries are required as opposed to a "stream" on a topic.
{ "domain": "robotics.stackexchange", "id": 15390, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "navigation, service, occupancy-grid, laserscan, publisher", "url": null }
java, beginner, object-oriented, inheritance, interface System.out.println("Enter information about the Embarkation ship \n"); System.out.println("Enter the name of the client"); r.nextLine(); String l=r.nextLine(); s.setName(l); System.out.println("Enter the number of the client"); int o=r.nextInt(); s.setNumClient(o); System.out.println("Enter the number of days of the rental"); int t=r.nextInt(); s.setNumDays(t); System.out.println("Enter the mooring position"); r.nextLine(); //to avoid non-read lines String u=r.nextLine(); s.setPosition(u); System.out.println("Enter the enrollment"); int x=r.nextInt(); System.out.println("Enter the slovak"); double y=r.nextDouble(); System.out.println("Enter the year of fabrication"); int z=r.nextInt(); System.out.println("Enter the number of engine power"); double aa=r.nextInt(); b[2]=new Embarkation(x,z,y,aa); System.out.println(b[2].ShowData()+" "+b[2].RentCost()); } } OK, Hello again. So here are my comments: You should not have an array of boats in class Rental, but just a reference to a single boat. That boat should be given in the constructor, and a getter and a setter should be added: The fields should not be static Here's a new version of the Rental class: class Rental { private String name, position; private int numDays, numClient; private Ship ship; Rental() { }
{ "domain": "codereview.stackexchange", "id": 27124, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "java, beginner, object-oriented, inheritance, interface", "url": null }
python, performance, python-2.x, primes # It's a prime if not proven false until here return True def seeker(num_start, num_end): ''' Search for primes from and including num_start to num_end. Uses 'is_prime_td()'. ''' # The smallest prime number is two. So, always skip if num's < 2. # We could add this check also to the loop below where we Increment # accordingly, but this would just add a useless extra check each # iteration. if num_start >= 2: num = num_start else: num = 2 try: while num <= num_end: if is_prime_td(num): yield num # Since there are no even primes except 2, we only want to # test odd numbers in the loop. Increment accordingly so we never # test even numbers and thus saving some time. if num % 2 == 0: num += 1 else: num += 2 except KeyboardInterrupt: pass if __name__ == '__main__': # Define the range to be searched here. num_start = 0 num_end = 100 # Print only positive findings. for num in seeker(num_start, num_end): print num Instead of doing this you should instead use a sieve, where you filter the output. It would make the code much simpler, and would make it much faster. Your comments are useless at best. If you know two languages it'd not make sense to say the same thing in both. Which is what you are doing here. Instead what you want to use comments for, is for high-level overviews of your code. Say you create a primality test which is heavily optimized, you would want to put a comment on the hard to read parts. Such as your sqrt part. To improve the actual code, I'd:
{ "domain": "codereview.stackexchange", "id": 23387, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, performance, python-2.x, primes", "url": null }
Do all groups come with an inverse operation such that $$a \in S$$ and $$b \in S$$, $$a \circ^{-1}b \in S$$? Do you mean "$$a^{-1} b \in S$$"? If so, then yes, the existence of inverses is literally one of the group axioms! I think a precise meaning of the word "generated" will help answer this question. Let $$G$$ be a group, and let $$S$$ be any subset of $$G$$. The subgroup of $$G$$ generated by $$S$$, sometimes denoted $$\langle S \rangle_G$$, is defined to be the intersection of all subgroups of $$G$$ which contain $$S$$ as a subset. From this definition, we see that $$\langle S \rangle_G$$ is the unique smallest subgroup of $$G$$ which contains $$S$$ as a subset, and from this it's not too hard to prove that $$\langle S \rangle_G$$ is also the set of elements of $$G$$ of the form $$x_1 x_2 \cdots x_n$$ where each $$x_1, \dots, x_n$$ is either an element of $$S$$ or the inverse of an element of $$S$$. So the inverses aren't coming out of nowhere: they arise naturally from this construction of the subgroup generated by a subset!
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9780517437261226, "lm_q1q2_score": 0.8063664226191734, "lm_q2_score": 0.8244619242200082, "openwebmath_perplexity": 131.8736256147401, "openwebmath_score": 0.774782657623291, "tags": null, "url": "https://math.stackexchange.com/questions/3850689/how-can-cyclic-groups-be-infinite/3850690" }
reference-request, agi, research, algorithm-request, model-request In short, if you're interested in AGI algorithms and models, look into AIXI, Godel machines, Numenta's work, cognitive architectures (like SOAR or OpenCog), in addition to the more traditional ML approaches, like RL. I also recommend that you read the paper Artificial General Intelligence: Concept, State of the Art, and Future Prospects.
{ "domain": "ai.stackexchange", "id": 3305, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "reference-request, agi, research, algorithm-request, model-request", "url": null }
It just turns out nicely for C that he is one of the people whose hat colors D and C both know about. To introduce a modified challange: if the task were to yell out C's hat color right away, D would know for certain, C would have the increased probability of $2/3$ and A and B would be stuck with the random guess of $1/2$. D still knows more.
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9553191271831559, "lm_q1q2_score": 0.8248145242944477, "lm_q2_score": 0.8633916152464017, "openwebmath_perplexity": 541.4644721113484, "openwebmath_score": 0.7188256978988647, "tags": null, "url": "https://math.stackexchange.com/questions/47471/four-men-hats-and-probability" }
$$p_3(-1)=-6,\quad p_3(0)=0,\quad p_3(1)=6,\quad p'_3(2)=1.$$
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9859363713038173, "lm_q1q2_score": 0.8060764079465811, "lm_q2_score": 0.817574471748733, "openwebmath_perplexity": 106.55214369879162, "openwebmath_score": 0.9560206532478333, "tags": null, "url": "https://math.stackexchange.com/questions/3021533/interpolation-with-a-new-point-of-f" }
You are right about $f(x^2)$; and $f(x)^2$ simply means $f(x)f(x)$. The troublesome notation is $f^2$, whether used to talk about the function $f^2$ or its value at the point $x$, namely $f^2(x)$. One convention often used is that it is the function whose values are the squared values of $f$, namely $f^2:x\mapsto f(x)^2$. However, in the sort of mathematics where we are more interested in compounding functions than in doing algebraic operations on their values, concatenation is a convenient way to represent composition, particularly because such composition is associative. Thus, $fgh$ means $x\mapsto f(g(h(x)))$. Using a more explicit expression of composition, we might write this associativity as $(f\circ g)\circ h=f\circ(g\circ h)$, but writing all those little circles is rather tedious when we are not doing algebra with the values and don't need to distinguish it from composition. • I think in abstract algebra it is pretty common for $f^2$ to indicate $f\circ f$ as well, as it is in line with how we denote other binary operations applied multiple times and also extends to negatives to denote the inverse functions – aidangallagher4 Apr 3 '18 at 10:22 • The moral is: if you use notation $f^2(x)$, then define what you mean. In every new document, define it again. If that is too inconvenient for you, then use $f(x)^2$ or $f^{\circ 2}(x)$, or ... Exception: trig functions, but even though $\sin^2 x$ and $\sin^{-1} x$ have known meanings, still students are confused by them all the time. – GEdgar Apr 3 '18 at 13:16
{ "domain": "stackexchange.com", "id": null, "lm_label": "1. YES\n2. YES", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9702399026119353, "lm_q1q2_score": 0.8207671136420652, "lm_q2_score": 0.8459424431344437, "openwebmath_perplexity": 256.0694085469901, "openwebmath_score": 0.9072338342666626, "tags": null, "url": "https://math.stackexchange.com/questions/2664932/f2x-vs-fx2-vs-fx2" }
python, python-3.x, time-limit-exceeded, numpy, simulation def update_strategy(self): self.demand = self.pick_strat(1) def update_probablities(self): for i in range(9): self.propensities[1 + i] *= 1 - mew pensity_sum = self.calculate_sum(self.propensities) for i in range(9): self.probabilites[i] = self.calculate_probability(self.propensities, 1 + i, pensity_sum) def update(self): self.update_probablities() self.update_strategy() class Responder: # methods same as proposer class, can skip-over def __init__(self): self.propensities = create_random_propensities() self.probabilites = [] self.max_thresh = 0 # the maximum demand they are willing to accept def pick_strat(self, n_trials): results = multinomial(n_trials, self.probabilites) i, = np.where(results == max(results)) if len(i) > 1: return choice(i) + 1 else: return i[0] + 1 def calculate_probability(self, dict_data, index, total_sum): return dict_data[index]/total_sum def calculate_sum(self, dict_data): return sum(dict_data.values()) def initialize(self): init_sum = self.calculate_sum(self.propensities) for strategy in range(1, 10): self.probabilites.append(self.calculate_probability(self.propensities, strategy, init_sum)) self.max_thresh = self.pick_strat(1) def update_strategy(self): self.max_thresh = self.pick_strat(1)
{ "domain": "codereview.stackexchange", "id": 35045, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "python, python-3.x, time-limit-exceeded, numpy, simulation", "url": null }
human-biology, microbiology, food, digestive-system, mycology Aflatoxins produce acute necrosis, cirrhosis, and carcinoma of the liver in a number of animal species; no animal species is resistant to the acute toxic effects of aflatoxins; hence it is logical to assume that humans may be similarly affected. A wide variation in LD50 values has been obtained in animal species tested with single doses of aflatoxins. For most species, the LD50 value ranges from 0.5 to 10 mg/kg body weight. Animal species respond differently in their susceptibility to the chronic and acute toxicity of aflatoxins. The toxicity can be influenced by environmental factors, exposure level, and duration of exposure, age, health, and nutritional status of diet. Aflatoxin B1 is a very potent carcinogen in many species, including nonhuman primates, birds, fish, and rodents. In each species, the liver is the primary target organ of acute injury. Metabolism plays a major role in determining the toxicity of aflatoxin B1; studies show that this aflatoxion requires metabolic activation to exert its carcinogenic effect, and these effects can be modified by induction or inhibition of the mixed function oxidase system.
{ "domain": "biology.stackexchange", "id": 4266, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "human-biology, microbiology, food, digestive-system, mycology", "url": null }
general-relativity, gravitational-waves, diffeomorphism-invariance [EDIT] More precisions : The linear diffeomorphism is only the linearization of the standard diffeomorphism : $g^{'\mu\nu} = \frac{\partial x^{'\mu}}{\partial x^{\sigma}} \frac{\partial x^{'\nu}}{\partial x^{\tau}} g^{\sigma\tau}$ for a coordinate transformation $x^{'\mu} = x^\mu + \epsilon^\mu(x)$ where you plug $g^{\sigma\tau} = \eta^{\sigma\tau} + h^{\sigma\tau}$, and $\frac{\partial x^{'\mu}}{\partial x^{\sigma}} = \delta^\mu_\sigma +\partial_\sigma \epsilon^\mu$, and where you keep only terms linear in $\epsilon$. Due to Lorentz invariance, you have only $4$ possible quadratic terms in first derivative of $h_{\mu\nu}$ , and we are searching the correct combination which leaves the action invariant under the linear diffeomorphism (which is nothing but a gauge invariance for spin $2$ field). So you may write : $S = \int d^4x (A ~\partial_\alpha h_{\nu\beta}~\partial^\alpha h^{\nu\beta} + B ~\partial_\alpha h_\nu^\nu~\partial^\alpha h_\nu^\nu +C ~\partial_\alpha h^{\alpha\nu}~\partial^\beta h_{\beta\nu}+D ~\partial^\alpha h_\nu^\nu~\partial^\beta h_{\beta\alpha}) $ We may fix a value for $A$, here $A = \frac{-1}{32G} (\frac{1}{2})$, so we have only $3$ variables to be checked.
{ "domain": "physics.stackexchange", "id": 10978, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "general-relativity, gravitational-waves, diffeomorphism-invariance", "url": null }
meteorology, tornado, coriolis And then conversely, Australia doesn't have a lot of land Poleward yet is still a reasonably busy tornado spot. Mountain ranges Poleward also generally aren't a big deal... even pretty large ones; one of the biggest tornado areas is Bangladesh\India, despite the disruption the Himalayas presents. Because enough cold air can filter into the region in spite of the blockage. The only thing that would be a real large scale geographic issue to the needed cold air would be a warm sea Poleward that modifies the incoming cold air significantly. But that's pretty tough to have geographically. Perhaps more possible in the Autumn... maybe the Great Lakes serves as a slight dampener on fall season tornadoes in parts of the US? Though their effect is still mostly pretty small overall. Bring too near any large body of water, in any direction, is really a downer on supercellular tornadoes, as it modifies temperature gradients and instability. To your direct question... there actually is a very good example of what Tornado Alley would look like in the Southern Hemisphere already: the Pampas Lowlands of Argentina. It has that big mountain range to the west, in the midlatitudes, and does have fairly warm water a ways northward. But it doesn't have quite as large of a region east of the mountains to have the tornadoes in, the cold air (and storm system strength) is probably modified due to the closed nature of the Antarctic vortex and the widespread oceans of the SH modifying air masses, and the source water isn't probably as well located being so far north (and is it warm?). But even still, Pampas area might be the second most consistent tornado region on Earth. Such that some US storm chasers have traveled down there in our winter. In the end, local effects play a huge role too, creating mesoscale ingredients (seabreezes\temperature boundaries, upsloping, local vortex flow, etc) to add plenty of rotation to the ledger (see Florida, one of highest tornadoes per square mile in US, in large part due to seabreeze water spouts and hurricanes). But all things equal, being east of mountains in the midlatitudes is a jackpot ingredient to climatological tornado formation (regardless of hemisphere).
{ "domain": "earthscience.stackexchange", "id": 905, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "meteorology, tornado, coriolis", "url": null }
performance, algorithm, matrix, combinatorics, matlab U = cellfun(@unique, reps_Events, 'UniformOutput', false); repeat_counts = cellfun(@length, U); kk=1; for i1=1:50 for i2=1:50 for i3=1:50 for i4=1:50 for i5=1:50 for i6=1:50 for i7=1:50 if i1~=i2 && i2~=i3 && i3~=i4 && i4~=i5 && i5~=i6 && i6~=i7 myEvents = [i1 i2 i3 i4 i5 i6 i7]; v= b(cellfun(@(x)all(ismember(myEvents,x)),U),:); intersection(1,kk)=v(1); intersection(2,kk)=v(2); intersection(3,kk)=v(3); intersection(4,kk)=v(4); intersection(5,kk)=i1; intersection(6,kk)=i2; intersection(7,kk)=i3; intersection(8,kk)=i4; intersection(9,kk)=i5; intersection(10,kk)=i6; intersection(11,kk)=i7; kk=kk+1; end end end end end end end end There's quite a few things that you can do to reduce computation time. First of all, if you know that an outcome has to be the combination of seven events, you can throw out whatever has fewer of them. Then, you can preassign the output array (growing in a loop is usually not very fast). Finally, you want to generate all possible subsets if there are, say, 9 events from which you can choose 7. So you'd start %# throw out useless stuff tooFewIdx = repeat_counts < 7; b(tooFewIdx,:) = []; U(tooFewIdx) = []; repeat_counts(tooFewIdx) = [];
{ "domain": "codereview.stackexchange", "id": 990, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "performance, algorithm, matrix, combinatorics, matlab", "url": null }
linux, assembly Format_AL_AsHexWithSpaceTo_EBX: push eax shr eax,4 call .EAX_nibble pop eax call .EAX_nibble mov [ebx],BYTE ' ' inc ebx ret .EAX_nibble: and eax,0x0F mov al,[HexLUT+eax] mov [ebx],al inc ebx ret Finish: call DisplayDataBuffer ; display any incomplete line of data mov ebx,eax ; error code from SYS_READ is exit code mov eax,SYS_EXIT int 80h
{ "domain": "codereview.stackexchange", "id": 21769, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "linux, assembly", "url": null }
ros, rostopic, ardrone-autonomy Originally posted by Mani with karma: 1704 on 2015-11-01 This answer was ACCEPTED on the original site Post score: 1
{ "domain": "robotics.stackexchange", "id": 22875, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ros, rostopic, ardrone-autonomy", "url": null }
ruby, programming-challenge def initialize matrix @matrix = matrix @dim = @matrix.size end def horizontals @matrix end def verticals @matrix.transpose end def diagonals (0..@dim-1).map { |i| diag(0, i) }.reverse + (1..@dim-1).map { |i| diag(i, 0) } end def inv_diagonals reverse.diagonals end private def diag x, y result = [] while x < @dim && y < @dim result << @matrix[x][y] x += 1 y += 1 end result end def reverse Grid.new(@matrix.map { |row| row.reverse }) end end def max_product lines lines.flat_map { |line| line.each_cons(4).to_a }.map { |cons| cons.inject { |prd, x| prd * x} }.max end grid = Grid.parse str p [:horizontals, :verticals, :diagonals, :inv_diagonals].map { |method| max_product(grid.send(method)) }.max Your Code Class method You created the class method parse with this snippet: class << self def parse str Grid.new str.split("\n").map { |row| row.split(" ").map { |val| val.to_i } } end end That works, but a more conventional definition is just: def self.parse str Grid.new str.split("\n").map { |row| row.split(" ").map { |val| val.to_i } } end Further, since self equals Grid when this method is created, it is better to write: def self.parse str new str.split("\n").map { |row| row.split(" ").map { |val| val.to_i } } end
{ "domain": "codereview.stackexchange", "id": 11031, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "ruby, programming-challenge", "url": null }
are simply the combination of rational and irrational numbers, in the number system. A real number is a number that can take any value on the number line. definition. D. Irrational Use MathJax to format equations. Be sure to account for ALL sets. To learn more, see our tips on writing great answers. What is internal and external criticism of historical sources? For example, 5i is an imaginary number, and its square is −25. 10, as 10 + 0i - that would be too pedantic, to say the … We call x +yi the Cartesian form for a complex number. Strictly speaking (from a set-theoretic view point), $\mathbb{R} \not \subset \mathbb{C}$. It solves x²+1=0. MathJax reference. 1 See answer AnshulDavid3143 is waiting for your help. 2/5 A. Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. But since the set of complex numbers is by definition $$\mathbb{C}=\{a+bi:a,b\in\mathbb{R}\},$$ doesn't this mean $\mathbb{R}\subseteq\mathbb{C}$, since for each $x \in \mathbb{R}$ taking $z = x + 0i$ we have a complex number which equals $x$? Is Delilah from NCIS paralyzed in real life? To which subset of real numbers does the following number belong? What is the "Ultimate Book of The Master". By now you should be relatively familiar with the set of real numbers denoted $\mathbb{R}$ which includes numbers such as $2$, $-4$, $\displaystyle{\frac{6}{13}}$, $\pi$, $\sqrt{3}$, …. Real numbers are a subset of complex numbers. Two complex numbers a + bi and c + di are defined to be equal if and only if a = c and b = d. If the imaginary part of a complex number is 0, as in 5 + 0i, then the number corresponds to a real number. Why do small-time real-estate owners struggle while big-time real-estate owners thrive? Complex numbers are distinguished
{ "domain": "com.au", "id": null, "lm_label": "1. Yes\n2. Yes", "lm_name": "Qwen/Qwen-72B", "lm_q1_score": 0.9719924810166349, "lm_q1q2_score": 0.8682900169335366, "lm_q2_score": 0.8933093968230773, "openwebmath_perplexity": 267.5919787374287, "openwebmath_score": 0.7106465101242065, "tags": null, "url": "https://www.weddingsupplierswa.com.au/viz6m3yu/is-real-number-a-subset-of-complex-number-489fe3" }
meteorology, wind Is this the correct definition? I'm a bit confused, since this contradicts the company support guys (which are specialist for this thing). They insist, there is not time-averaging-period attached to the definition of "Wind gust" which is, in my understanding, not sensible. There must be some time information attached to any definition of "wind gust" as far as I understand? But then again I'm not a meteorologist and might miss something basic. Obliged for any help to clarify this respectively lets me understand this better. The WMO definition of wind gust for observing stations is,
{ "domain": "earthscience.stackexchange", "id": 2538, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "meteorology, wind", "url": null }
tensorflow, rnn Title: How Tensorflow text prediction predicts without softmax activation In the Colab notebook here: RNN text generation in def generate_text(), there is predicted_id = tf.random.categorical(predictions, num_samples=1)[-1,0].numpy() I looked into tf.random.categorical here: stackoverflow answer and sort of understand how it works. I tried to debug/figure out what it does with print statements: for i in range(num_generate): predictions = model(input_eval) # remove the batch dimension predictions = tf.squeeze(predictions, 0) # using a categorical distribution to predict the word returned by the model predictions = predictions / temperature predicted_id1 = tf.random.categorical(predictions, num_samples=1) predicted_id2 = tf.random.categorical(predictions, num_samples=1)[-1,0] predicted_id3 = tf.random.categorical(predictions, num_samples=1)[0,0] predicted_id4 = tf.random.categorical(predictions, num_samples=1)[-2,0] predicted_id5 = tf.random.categorical(predictions, num_samples=1)[1,0] predicted_id6 = tf.random.categorical(predictions, num_samples=1)[2,0] predicted_id7 = tf.random.categorical(predictions, num_samples=1)[3,0] #predicted_id8 = tf.random.categorical(predictions, num_samples=1)[4,0] predicted_id = tf.random.categorical(predictions, num_samples=1)[-1,0].numpy() #index 0 for
{ "domain": "datascience.stackexchange", "id": 7095, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "tensorflow, rnn", "url": null }
c, strings I'm interested specifically in: Performance. This code gets called a lot. I want it to be as fast as possible. Memory safety. While I'm fairly sure that this doesn't leak memory (assuming it's used properly), I'm not confident, and I'm not sure how to check. Edge cases. It works, as far as I can tell, but that doesn't mean that it's bug-free. Tested here. Bug: Initial allocation not cleared to zero Your initial allocation of sb->mem uses malloc instead of calloc, so its contents are uninitialized. If you then append a few characters and call sb_as_string(), you will get back a string that is not properly terminated. You should use calloc instead. Minor bug If your call to realloc fails, your buffer will be incorrect because it will no longer be null terminated (you just appended a character to the last spot). You should either rewrite a '\0' to the end of the buffer if realloc fails, or do the realloc before you append the character. Argument check When creating a string buffer, you should handle the case where init_cap is passed in as 0. You can set it to some default value in that case. Right now, an initial capacity of 0 will cause a crash down the line because your append function will append to a zero length buffer without ever reallocating. Usability I would much prefer an append function that took a string argument instead of a character argument. I'm not sure that I would ever need to append one character at a time. Also, it might be nice to have a to_string type function that returns the string but also frees the stringbuilder. The way you currently have it, you can retrieve the string, but if you subsequently free the stringbuilder it will also free the string you just retrieved. That makes it difficult to use the string because its lifetime is tied to the lifetime of the stringbuilder.
{ "domain": "codereview.stackexchange", "id": 32006, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "c, strings", "url": null }
microcontroller, gazebo, ros-kinetic Originally posted by ahendrix with karma: 47576 on 2018-04-10 This answer was ACCEPTED on the original site Post score: 1 Original comments Comment by gvdhoorn on 2018-04-10: Additionally: it might be good to check whether the (Gazebo) plugins used impose any (artificial) limits. 20 - 4 == 16. That is too nice a number to be a coincidence. Comment by nm46nm on 2018-04-10: I had changed the ulimit by ulimit -n 20480 before, it seemingly didn't work. Besides, when I try lsof -P {PID} , it says "No such file or directory", why?(I had replaced the pid) Comment by ahendrix on 2018-04-10: oops; that should be a lowercase p: lsof -p {PID} Comment by nm46nm on 2018-04-11: Thank you but it toled me "lsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing ,Output information may be incomplete." When I put sudo in front of the lsof, it said "lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs ,Output information may be incom..." Comment by nm46nm on 2018-04-11: @gvdhoorn, it is not always 16. If we want to simu 30 uavs, there are just 9 or 14 or 11 etc uavs connected.
{ "domain": "robotics.stackexchange", "id": 30593, "lm_label": null, "lm_name": null, "lm_q1_score": null, "lm_q1q2_score": null, "lm_q2_score": null, "openwebmath_perplexity": null, "openwebmath_score": null, "tags": "microcontroller, gazebo, ros-kinetic", "url": null }