text stringlengths 1 1.11k | source dict |
|---|---|
quantum-mechanics, quantum-information, mathematical-physics, density-operator
Title: Post-measurement density matrix derivation This is something standard, by I'm trying to redo this with spectral theory. Suppose we start with the usual postulates of quantum mechanics:
States are unit rays on a separable Hilbert space. In particular they are described by unit vectors.
Observables are hermitian operators acting on the Hilbert space.
The possible values of an observable are the ones from its spectrum.
If $A$ is an observable with associated projection-valued measure $\mathbb{P}_A$ given by the spectral theorem, its values on the state $\Psi$ are described by the probability measure $$\mu_A(E)=(\Psi,\mathbb{P}_A(E)\Psi),\quad \forall \text{ measurable $E\subset \sigma(A)$}$$
If the measurement outcome lies in $E\subset \sigma(A)$, then the post-measurement state is the normalized projection $$\Psi'=\frac{1}{\|\mathbb{P_A(E)}\Psi\|}\mathbb{P}_A(E)\Psi$$ | {
"domain": "physics.stackexchange",
"id": 54776,
"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, mathematical-physics, density-operator",
"url": null
} |
math-expression-eval, powershell
# Cycle each permutation
0..($permutations - 1) | ForEach-Object{
# Convert the number to a base equal to the element count in operators. Use those values to represent the index of the operators array.
$mathString = $formatString -f @([string[]][char[]]((ConvertTo-Base -Number $_ -Base $operators.Count).PadLeft($range.count - 1,"0")) | ForEach-Object{$operators[[int]$_]})
# Build an object that contains the result and the mathematical expression
[pscustomobject]@{
Expression = $mathString
Value = Invoke-Expression $mathString
}
# Since this take a while try and give the user some semblance of progress.
Write-Progress -Activity "Performing mathematical calculations" -Status "Please wait." -PercentComplete ($_ / $permutations * 100) -CurrentOperation "$([math]::Round($_ / $permutations * 100))% Completed." | {
"domain": "codereview.stackexchange",
"id": 34648,
"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": "math-expression-eval, powershell",
"url": null
} |
php, classes, pagination, php7
// prepare navigator
if ($this->total_pages > 1) {
$previous = null;
$following = null;
$this->navigator = "<div id=\"paginator\">%1";
for ($count = 1; $count <= $this->total_pages; $count++) {
if ($this->page != $count) $this->navigator .= "<a href='" . $this->url. "$count'>$count</a>";
else {
$this->navigator .= "<a href='#'>$count</a>";
if ($this->page != 1) {
$previous = '<a href="' . $this->url.($count-1).'"><</a>';
$this->navigator = str_replace("%1", $previous, $this->navigator);
} else {
$this->navigator = str_replace("%1", "", $this->navigator);
} | {
"domain": "codereview.stackexchange",
"id": 44583,
"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, classes, pagination, php7",
"url": null
} |
programming-languages, program-correctness, software-verification
Now I'm going to assume that you are interested in proving strong properties about your programs. If you are interested in security properties (your program can not reach a certain state), then in general it seems the best approach is model checking. However if you wish to fully specify the behavior of a Java program, your best bet is to use a specification language for that language, for instance JML. There are such languages for specifying the behavior of C programs, for instance ACSL, but I don't know about C++.
Once you have your specifications, you need to prove that the program conforms to that specification.
For this you need a tool that has a formal understanding of both your specification and the operational semantics of your language (Java or C++) in order to express the adequacy theorem, namely that the execution of the program respects the specification. | {
"domain": "cs.stackexchange",
"id": 14773,
"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": "programming-languages, program-correctness, software-verification",
"url": null
} |
newtonian-mechanics, classical-mechanics, forces, work, power
What happens when you stop giving the force?
The object eventually stops.
Why does it stop?
Well, there must be some deceleration acting on the object, essentially a dissipative force like friction or, in some cases, viscosity.
So the initial constant force acting on the object is necessary to oppose and cancel out this dissipative force, so that the object has a net constant velocity.
Hope this helps you. | {
"domain": "physics.stackexchange",
"id": 37611,
"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": "newtonian-mechanics, classical-mechanics, forces, work, power",
"url": null
} |
quantum-mechanics, wavefunction, schroedinger-equation, potential
But I would like to pursue the same for non-separable analytical solution to the Schrodinger equation. Can anyone suggest how to go about it or what resources could I use to attempt the problem? I don't want to be too much precise, but the Schrödinger equation ($i \dot{\psi}= H\psi$ to avoid confusion) has at most an unique solution under very general assumptions on the Hamiltonian operator $H$, even if you see it as a liner equation in the more general setting of Banach spaces.
In particular, it is not a priori necessary that $H$ is self-adjoint for the solution to be unique (and anyways if it is, then it is unique). | {
"domain": "physics.stackexchange",
"id": 22952,
"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, wavefunction, schroedinger-equation, potential",
"url": null
} |
python, xml, web-scraping, beautifulsoup
xml=xmlcreator
xml.rootC('database')
xml.sub1C('product')
xml.sub2('ptitle','price','purl','urlimage','categ','subcateg')
urllist=[["http://www.walmart.com/browse/computer-accessories/usb-flash-drives/3944_3951_132959_529295?tab_value=online&catNavId=%3Cc%3aout+value%3d%27%26lt%3bc%3aout+value%3d%27%26lt%3bc%3aout+value%3d%27132959%27%2f%26gt%3b%27%2f%26gt%3b%27%2f%3E&ss=false&ic=32_0",'Electronics','USB Flash Drives']]
for i in range(0,len(urllist)):
print 'Scrapping '+urllist[i][0]+' in '+urllist[i][1]+' Category and '+urllist[i][2]+' subcategory.......'
count=0
err=[]
url=urllist[i][0]
request = urllib2.Request(url)
request.add_header('UserAgent', 'Ruel.ME Walmart Scraper')
htmlFile = urllib2.urlopen(request)
data = htmlFile.read()
soup=BeautifulSoup(data)
y=soup.find_all("span",class_="floatLeft numResults mt5")
y=re.findall('<span class="floatLeft numResults mt5">(.*)</span>',str(y[0]))
y=y[0].strip('Results');
y=int(y) | {
"domain": "codereview.stackexchange",
"id": 11157,
"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, xml, web-scraping, beautifulsoup",
"url": null
} |
recurrence-relation, discrete-mathematics
Title: Solving the recurrence T(n) = 4T(n/4) + n log n with the iterative method I'm trying to solve
$$ T(n) = 4T(n/4) + n \log_{10}n.$$
I'm having trouble with Iteration Method near the end.
As far as I went, I obtained the General Formula as:
$$4^kT(n/4^k)+n\log n+\sum (n/4^k)\log(n/4^k)$$
And trying to get the moment when it finishes iterating:
$$(n/4^k)=1$$
$$n=4^k$$
$$\log_4n=k$$
And here I get stuck. I know I have to substitute $k$ with $\log_4n$ but after that I'm lost. Can I get a bit of help with explanation of every step?
Here are some more details:
Swapped $\log_4n$ on all $k$:
$$4^{\log_4n} T(n/4^{\log_4n})+n\log_2n+\sum_{n=0}^{\log_4n}n\log n$$
From logarithm rules of $a^{log_an} = n$, it ends like this:
$$(n)(1)+n\log_2n+\sum_{n=0}^{\log_4n}n\log n$$ | {
"domain": "cs.stackexchange",
"id": 6861,
"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": "recurrence-relation, discrete-mathematics",
"url": null
} |
denominator is the bottom part of a fraction. . Rationalising denominators A fraction whose denominator is a surd can be simplified by making the denominator rational. There is another example on the page Evaluating Limits (advanced topic) where I move a square root from the top to the bottom. This image may not be used by other entities without the express written consent of wikiHow, Inc. | {
"domain": "locksmith-milton.ca",
"id": null,
"lm_label": "1. Yes\n2. Yes\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.968381236381426,
"lm_q1q2_score": 0.832482242109358,
"lm_q2_score": 0.8596637469145053,
"openwebmath_perplexity": 914.316174587637,
"openwebmath_score": 0.8417977690696716,
"tags": null,
"url": "http://locksmith-milton.ca/hydroxy-bhcuvy/archive.php?id=rationalizing-the-denominator-8f9c31"
} |
ros, bagfile, vlp16, velodyne
Comment by joq on 2017-02-08:
Yes, there should.
Comment by Pelacho on 2017-04-26:
Hi there, I got this in one window: end of file reached -- done reading.
but the recording windows remains: Recording to grabacion.bag. and never finish
I finish it manually and nothing appear when I rosplay it
Comment by sohel on 2017-11-13:
I am getting .bag.active file in my home directory. where is my .bag file
Comment by mathbeaudry on 2017-12-02:
I got the same result as Pelacho, what could we do with this ?
Comment by GuimingChen on 2020-03-20:
Hi, I was trying to do the same thing. But I realized that the recorded rosbag file has some missing frames compared with the pcap file. (I did make sure that I ran the record before start playing the pcap file) Is this expected? Is there a way to capture all the frames in pcap file? | {
"domain": "robotics.stackexchange",
"id": 22102,
"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, bagfile, vlp16, velodyne",
"url": null
} |
roslaunch
yields:
data: Please keep this running in a separate tab.
Though maybe the data: is undesirable
Adding a -p to the echo yields:
%time,field.data
1510939080429253101,Please keep this running in a separate tab.
Originally posted by lucasw with karma: 8729 on 2017-11-17
This answer was ACCEPTED on the original site
Post score: 4 | {
"domain": "robotics.stackexchange",
"id": 29387,
"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
} |
sonar
Make the shape of your test tank such that all echoes are reflected into a trap. The TRANSDEC anechoic pool accomplishes this with its eliptical shape; sounds that hit the bottom are directed toward the edge, which has a "trap" around its perimeter. (I can no longer find the cut-away diagram for that... sorry).
Put foam wedges along the outside of the tank to absorb acoustic energy, similar to the way that recording-studio anechoic chambers are designed.
Aerate the water to scatter the echoes, a technique described in this paper: "Anechoic aquarium
for ultrasonic neural telemetry". The use of microbubbles is apparently able to prevent most of the multipath effects. | {
"domain": "robotics.stackexchange",
"id": 252,
"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": "sonar",
"url": null
} |
python, gui, tkinter
self.lbl_branch = tkinter.Label(
self, textvariable=self.repo_branch, relief=SUNKEN, anchor=W
)
self.chk_commit = tkinter.Checkbutton(
self, text='Commit', variable=self.option_commit,
command=self.on_commit_click
)
self.ent_branch_name = tkinter.Entry(
self, textvariable=self.new_branch_name
)
self.branch_name_label = tkinter.Label(self, text='New branch name')
self.commit_message_label = tkinter.Label(self, text='Commit message')
self.txt_commit_message = tkinter.Text(self, height=4)
self.chk_close = tkinter.Checkbutton(
self, text='Close branch', variable=self.option_close
)
self.chk_merge_test = tkinter.Checkbutton(
self, text='Merge with Test', variable=self.option_merge_test,
command=self.on_merge_test_click
)
self.chk_merge_test_silent = tkinter.Checkbutton( | {
"domain": "codereview.stackexchange",
"id": 23916,
"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, gui, tkinter",
"url": null
} |
ruby, programming-challenge, dice
def test_score_of_a_triple_1_is_1000A
assert_equal 1150, score([1,1,1,5,1])
end
def test_score_of_a_triple_1_is_1000B
assert_equal 350, score([3,4,5,3,3])
end
def test_score_of_a_triple_1_is_1000C
assert_equal 250, score([1,5,1,2,4])
end
end There are a few issues with the code:
Do not check for == nil when it is not specified as a valid value for the method. Here,checking for it and returning 0 might mask another problem.
Do not use return statements unless necessary. In ruby, almost everything is an expression, and methods return the value of the last expression. Here you can use if...elsif, or case instead of a series of if statement.
Do not modify parameters that come into your function (dice.sort!).
Do not use recursion if it makes the code less readable. | {
"domain": "codereview.stackexchange",
"id": 6253,
"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, dice",
"url": null
} |
quantum-mechanics
In the first point, I mentioned the eternal inflation in which a point in space suddenly goes crazy and decides to produce a whole new Universe. The process of "getting crazy" depends on quantum mechanics as well. The small region of space is getting crazy because of another kind of a quantum fluctuation. So it's a random quantum process - essentially quantum tunneling (analogous to the ability of an object to spontaneously penetrate the wall, something that wouldn't be possible in non-quantum physics) - that is responsible for the emergence of the self-perpetuating multiverse, too. | {
"domain": "physics.stackexchange",
"id": 484,
"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",
"url": null
} |
slam, navigation
I've added a description for how to install ROS Fuerte and RGBDSLAM on Ubuntu from scratch to the wiki page. This was a test of the installation and worked for me without problems. I think it was a 64bit Ubuntu 11.04 or 11.10, so it should work for you. If you are using a 32bit Ubuntu, I cannot guarantee anything, because I have none to test it on.
Good luck | {
"domain": "robotics.stackexchange",
"id": 11426,
"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": "slam, navigation",
"url": null
} |
motors
Title: On using gears and a low powered motor I have system I want to move with a DC motor that requires about 1 kW of power when taking into account rolling resistance, drag resistance and when moving on an inclined plane with a specific velocity. I had trouble finding small enough motors to provide that power so I asked a friend for help and he told me to use a gear system with low power motors. | {
"domain": "engineering.stackexchange",
"id": 3556,
"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",
"url": null
} |
r, ggplot2
rlData <- rawData %>%
pivot_longer( # Put all the counts in a single column
cols = contains("Sample"),
names_to = "Sample",
values_to = "Count"
) %>%
split(f = .$Sample) %>% # Separate into each sample
lapply(function(x){
# Now create a run-length encoded vector
# This encodes millions of repetitive values into 2 numbers
# 1) the value & 2) how many
Rle(values = x$Readlength, lengths = x$Count)
# They can be a bit difficult to plot though
}) | {
"domain": "bioinformatics.stackexchange",
"id": 1253,
"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": "r, ggplot2",
"url": null
} |
Company A rents copiers for a monthly charge of $240 plus 8 cents per copy. Company B rents copiers for a monthly charge of$480 pluse 4 cents per copy. What is the number of copies above which Company A's charges are the higher
7. ### math
I cant figure this thing out fully, I feel so clueless. Does anyone have any pointers or tips for me? Company needs a new copy machine. Rent costs are = 17.5 cents / each. Number of copies = atleast 200 000. (The company agrees to
8. ### algebra
Company A rents copiers for a monthly charge of $360 plus 12 cents per copy. Company B rents copiers for a monthly charge of$720 plus 6 cents per copy. What is the number of copies above which Company A's charges are the higher
9. ### Math
"How many ways are there to arrange some, but not all, of the letters in "Suspension" if at most once copy of each letter can be used? I have a start... I think the part that says "at most" one copy means that you have to remove
10. ### math | {
"domain": "jiskha.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9674102542943773,
"lm_q1q2_score": 0.8316475327058135,
"lm_q2_score": 0.8596637559030338,
"openwebmath_perplexity": 2688.4290318616568,
"openwebmath_score": 0.5708466172218323,
"tags": null,
"url": "https://www.jiskha.com/questions/1016830/A-local-photocopying-store-advertises-as-follows-We-charge-9-cents-per-copy-for"
} |
for the multiplication, $$\begin{split} \xi(r_1r_2) = \phi ( \varphi (r_1r_2) ) = \phi ( r_{1}^{'} r_{2}^{'} ) = r_{1}^{''} r_{2}^{''} = \phi ( \varphi (r_1) ) \phi ( \varphi (r_2) ) =\xi(r_1) \xi(r_2) \end{split}$$
and for the unit element in $R$,
Then, $$\begin{split} \xi(1_{R}) &= \phi ( \varphi (1_{R}) ) = \phi ( 1_{R'} ) = 1_{R''} \end{split}$$
Hence, $\xi$ is a ring homomprphism.
Doubt:
1) Is the proof right?
2) If this is right, is this (i.e. $\xi$) the unique ring homomorphism? I have no idea of how to prove uniqueness result if it's true.
## 1 Answer
The proof is fine.
Your question on uniqueness exhibits a slight misunderstanding. Actually the second sentence of the proposition is written awkwardly. It should read: Then the composition function $\xi= \phi \circ \varphi$ is a homomorphism $\xi : R \rightarrow R''$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9852713878802045,
"lm_q1q2_score": 0.825282981792659,
"lm_q2_score": 0.8376199613065411,
"openwebmath_perplexity": 262.02009107218896,
"openwebmath_score": 0.9711309671401978,
"tags": null,
"url": "https://math.stackexchange.com/questions/2493315/homomorphism-of-rings-from-composition-of-2-ring-homomorphisms"
} |
electronic-configuration
Title: How can elements have the same number of electrons, but different electron configurations? $\ce{Ti}$ and $\ce{Cr^2+}$ are isoelectronic, yet their electron configurations are different, with the former's being $\ce{[Ar] 4s^2 3d^2}$ and the latter's being $\ce{[Ar] 3d^4}$.
How can that be explained? When you fill electrons in different orbitals, you keep in mind the $n+l$ rule, but when you remove electrons you have to consider the principal quantum number. Between 3d and 4s, 4s has a lower value of $n+l$, so electrons will be first filled in it, that's why titanium metal has the atomic configuration $\ce{[Ar] 4s^2 3d^2}$.
In case of $\ce{Cr^2+}$ you have to first write configuration of $\ce{Cr}$, which is $\ce{[Ar] 4s^2 3d^4}$ and then remove two electrons from the orbital having highest value of $n$ (principal quantum number) which is 4s. after removing 2 electrons from 4s you will get configuration of $\ce{Cr^2+}$ which is $\ce{[Ar] 3d^4}$. | {
"domain": "chemistry.stackexchange",
"id": 6337,
"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": "electronic-configuration",
"url": null
} |
time, measurements, error-analysis, physical-constants
Footnotes:
$^{[1]}$ Equation (1) is most familiar from non-relativistic single-particle quantum mechanics, but it is also valid in relativistic quantum field theory, with a more complicated $H$ and with a state $\psi$ that depends on many — nominally infinitely many — abstract variables, none of which are directly associated with "particles." Those details are beside the point; the point is simply that equation (1) is a legitimate starting point for the present analysis.
$^{[2]}$ The holographic principle suggests that the usual concept of space (even curved space) breaks down in a black hole, leading to weird non-local effects. When our attempts to resolve a small distance involve enough energy to make a black hole, the idea isn't that smaller distances can't be resolved, but that smaller distances don't even make sense. | {
"domain": "physics.stackexchange",
"id": 56555,
"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": "time, measurements, error-analysis, physical-constants",
"url": null
} |
general-relativity, spacetime, differential-geometry, mathematical-physics, topology
\end{cases}
\end{array}
\end{equation}
The overlap with other charts only happens for $r > 0$ or $r < 0$, so that the transition is always smooth. We therefore have a smooth manifold out of it.
If we want to get the gluing of a manifold that already has a metric on it, things get trickier. We need to not only glue the manifold but also the tensor bundle. If the original manifold has some tensor bundle $(T^r_sM, M, \pi)$, then we'll consider the glued manifold
$$T^r_s M / \sim_\psi$$
where $\psi$ is similarly a diffeomorphism on the boundary of $T^r_s M$, such that $\psi = h_*$, the pushforward of $h$, gluing the boundaries $\pi^{-1}(S_i)$ together. The original metric $g$ gives rise to a continuous metric $\bar{g}$ if $h_* g(S_1) = g(S_2)$. You can find some more details on the topic in Takiguchi. | {
"domain": "physics.stackexchange",
"id": 58169,
"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, spacetime, differential-geometry, mathematical-physics, topology",
"url": null
} |
c#, event-handling, winforms, rubberduck
private TestExplorerItem FindItem(IEnumerable<TestExplorerItem> items, TestMethod test)
{
return items.FirstOrDefault(item => item.ProjectName == test.ProjectName
&& item.ModuleName == test.ModuleName
&& item.MethodName == test.MethodName);
}
public void Refresh(IDictionary<TestMethod,TestResult> tests)
{
_allTests = new BindingList<TestExplorerItem>(tests.Select(test => new TestExplorerItem(test.Key, test.Value)).ToList());
testOutputGridView.DataSource = _allTests;
testOutputGridView.Refresh();
}
public void SetPlayList(IDictionary<TestMethod,TestResult> tests)
{
_tests = tests.Select(test => new TestExplorerItem(test.Key, test.Value)).ToList();
UpdateCompletedTestsLabels();
} | {
"domain": "codereview.stackexchange",
"id": 11250,
"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#, event-handling, winforms, rubberduck",
"url": null
} |
let u= 2x - 3
=> du = 2 dx
so our integral becomes
int(1/sqrt(u^2 - 1))du
Now continue using trig substitution
4. Originally Posted by topsquark
Start this by looking under the square root sign. You want to do a "complete the square."
x^2 - 3x + 2 = (x^2 - 3x) + 2 = (x^2 - 3x + 9/4 - 9/4) + 2 = (x^2 - 3x + 9/4) - 9/4 + 2
= (x - 3/2)^2 - 1/4
Now let y = x - 3/2, dy = dx
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy]
One more trick and we're done. Pull a 1/4 out from under the radical:
Int[1/((1/4)(2y)^2 - 1/4)^{1/2}dy] = 2*Int[1/((2y)^2 - 1)^{1/2}dy]
And now let z = 2y, dz = 2dy and your integral becomes:
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy] = Int[1/(z^2 - 1)^{1/2}dz]
This is a more standard problem. Can you take it from here?
-Dan
Ha ha, i took forever typing this up only to see that u beat me to it once i clicked "submit reply"
Thanks a lot Dan | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8607401173852395,
"lm_q2_score": 0.8840392832736083,
"openwebmath_perplexity": 1382.927568327193,
"openwebmath_score": 0.837983250617981,
"tags": null,
"url": "http://mathhelpforum.com/calculus/12005-integration-unsure-method.html"
} |
python, json
gSizer1.Add(sbSizer1, 1, wx.ALL | wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT, 5)
self.SetSizer(gSizer1)
self.Layout()
self.Centre(wx.BOTH)
# Connect Events
self.Bind(wx.EVT_MENU, self.Exit, id=self.m_Exit.GetId())
self.m_search.Bind(wx.EVT_BUTTON, self.search)
self.m_choice2.Bind(wx.EVT_CHOICE, self.Display)
self.m_add.Bind(wx.EVT_BUTTON, self.addnew)
def __del__(self):
pass
# Virtual event handlers, overide them in your derived class
def search(self, event):
inst.Presearch(self.m_textname, self.m_textage, self.m_textId, self.m_statusBar2, self.m_choice2)
def addnew(self, event):
inst.exporttojson(self.m_textname, self.m_textage, self.m_textId, self.m_statusBar2)
def Display(self, event):
inst.Postsearch(self.m_textname, self.m_textage, self.m_textId, self.m_statusBar2,self.m_choice2)
def Exit(self, event):
self.Close(True) # Close the frame. | {
"domain": "codereview.stackexchange",
"id": 36508,
"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, json",
"url": null
} |
data by emphasizing the frequency or proportion of the data. The Bayesian approach allows direct probability statements about the parameters. For frequentists and Bayesians alike, the value of a parameter may have been fixed from the start or may have been generated from a physically random mechanism. It is different for every person. Frequentist Probability Probability of the observed difference (if the experimental therapy does not work) Bayesian Probability Probability that the experimental therapy works/doesn't work (given observed difference and prior knowledge). ] I was helping Boyi Xie get ready for his Ph. In this blog we're going to discuss about frequentist approach that use p-value, vs bayesian approach that use posterior. The paper continues to discuss the critique on frequentist approach and discusses the two contrasting Bayesian views. Bayesian Estimation • The frequentist approach can fail miserably, by wrongly the Bayesian estimate is that the probability of snow on | {
"domain": "erci.pw",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9822876976669629,
"lm_q1q2_score": 0.8120688227348857,
"lm_q2_score": 0.8267117919359419,
"openwebmath_perplexity": 1148.3731933812414,
"openwebmath_score": 0.7229945063591003,
"tags": null,
"url": "http://jjpe.erci.pw/frequentist-vs-bayesian-probability.html"
} |
magnetic-fields, magnetic-monopoles
* Note that these are also additional impositions on the form of the produced magnetic field and the response to external fields. However, both postulates are reasonable things to assume: if the relations were substantially different, then we wouldn't want to call those objects magnetic monopoles. Moreover, it should be essentially possible to get to those forms using very little more than symmetry considerations. | {
"domain": "physics.stackexchange",
"id": 34145,
"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": "magnetic-fields, magnetic-monopoles",
"url": null
} |
java, strings, interview-questions, balanced-delimiters, escaping
Instead, isBalanced() should instantiate the stack as a local variable, and explicitly pass it to any helper function that needs it.
Algorithm
I'm not a big fan of the BRACELETS constants, with the first half being the opening delimiters, with their counterparts in the second half. I think it's more cryptic than it needs to be. I'd just write a switch containing all of the characters of interest: it compiles to very clean and efficient bytecode, even simpler than String.indexOf().
When you encounter an opening delimiter, it would be smarter to push its counterpart onto the stack instead. That way, you don't have to repeatedly ask "is this the right closing delimiter?" when looking at every subsequent character.
public class BalancedParenthesis {
private static class CharStack {
private StringBuilder sb = new StringBuilder();
public boolean isEmpty() { return this.sb.length() == 0; }
public void push(char c) { this.sb.append(c); } | {
"domain": "codereview.stackexchange",
"id": 32484,
"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, strings, interview-questions, balanced-delimiters, escaping",
"url": null
} |
ros-kinetic, ros-indigo
I've read other questions like #q9915 and #q76279. I've tried to disable the firewall, set the ROS_HOSTNAME, but neither of those solutions worked for me.
My intuition says to me that it should not be a problem with the messages between the machines since I am only sending a String which is one of the basic std_msgs.
Could it be a networking problem?
Could it be a compatibility problem since I am running Kinetic on one device and Indigo on the other?
Any help will be appreciated | {
"domain": "robotics.stackexchange",
"id": 32317,
"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, ros-indigo",
"url": null
} |
python, tic-tac-toe
def update_score(self):
"""Recalculate the score.
There are 26 total directions from each point, or 13 lines, calculated in
the DirectionCalculation() class. For each of the 13 lines, look both ways
and count the number of values that match the current player.
This will find any matches from one point, so it's simple to then iterate
through every point. A hash of each line is stored to avoid duplicates.
"""
try:
self.grid_data_last_updated
except AttributeError:
self.grid_data_last_updated = None
if self.grid_data_last_updated != hash(tuple(self.grid_data)):
#Store hash of grid_data in it's current state to avoid unnecessarily running the code again when there's been no changes
self.grid_data_last_updated = hash(tuple(self.grid_data))
self.current_points = defaultdict(int)
all_matches = set() | {
"domain": "codereview.stackexchange",
"id": 15510,
"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, tic-tac-toe",
"url": null
} |
ros, c++, ros-melodic, service
I tried to initialize my service client by
svc_client = n.serviceClient("/set_led_color", true);
however it is not working.
Originally posted by kyubot on ROS Answers with karma: 60 on 2021-07-11
Post score: 0
I did not add below lines in package.xml
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>std_msgs</run_depend>
and then it is able to generate service header according to the service files defined in srv folder.
In my node.hpp file I added
#include "r1mini_gui_teleop/Color.h"
...
private:
...
ros::ServiceClient serviceClient; //Client node to call service
my_node::Color serviceSetColor; //Service set color
And in node.cpp file
init(...){
...
serviceClient = n.serviceClient<r1mini_gui_teleop::Color>("/set_led_color");
}
some function(...)
...
serviceClient.call(serviceSetColor);
Solved my problem.
Originally posted by kyubot with karma: 60 on 2021-07-11
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 36687,
"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, c++, ros-melodic, service",
"url": null
} |
This fits into the general principle that each of the fundamental properties of logarithms can be seen as a translation of a property of their inverses, the exponential functions. For example, logarithms convert products to sums ($\log_b(xy)=\log_b(x)+\log_b(y)$) because exponential functions convert sums to products ($b^{x+y}=b^xb^y$). Here, the fact that $b^x=a^{x\log_a(b)}$ says that you can change bases of your exponential function by multiplying the input variable by the constant $\log_a(b)$. In other words, exponential functions with different bases are related by horizontal stretches or shrinks of the graphs. When expressed in terms of the inverse functions, input and output switch, and the horizontal stretch (or shrink) changes to a vertical stretch (or shrink). That is, instead of multiplying the input by $\log_a(b)$, you divide the output by $\log_a(b)$ to get $\log_b(x)=\frac{\log_a(x)}{\log_a(b)}$. More succinctly, $g(x)=f(cx)$ implies $g^{-1}(x)=\frac{1}{c}f^{-1}(x)$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9674102571131692,
"lm_q1q2_score": 0.8751682017857003,
"lm_q2_score": 0.9046505299595162,
"openwebmath_perplexity": 190.53354425315823,
"openwebmath_score": 0.9344242811203003,
"tags": null,
"url": "http://math.stackexchange.com/questions/14133/clarify-why-all-logarithms-differ-by-a-constant"
} |
php, security, image, .htaccess
Title: Serve rescaled jpg images on demand with myphoto!500.jpg syntax (here 500px-width rescaled) On web pages, obviously large photos (e.g. 4000x4000px) cannot be served with a reliance on CSS to do the resizing: it would be too slow for end users and too bandwidth-consuming for the server.
So it's important to rescale photos to the desired size that will be actually used on the website. For this reason I usually resized the image with a tool like Photoshop to, say 800px width. But then later you always have the case "I would finally have preferred 10000px instead! and then ... you have to export the JPG again, re-upload, etc. Annoying!
Instead here is an automated solution in which you upload the top-quality version (never served to end users because it would be too big), and the tool automatically resizes on-demand.
Here is code that: | {
"domain": "codereview.stackexchange",
"id": 42570,
"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, security, image, .htaccess",
"url": null
} |
c, shell, unix, posix
The only variable used later is ret. So this could be moved into its own function.
I don't know what ret is. Perhaps a more descriptive name?
Beyond that, I'd move the function call to get ret and the entire while loop into its own function. You might further break up that function as well, but that stuff doesn't belong in main.
That would make your main very simple:
int main(int argc, char *argv[]) {
err_setarg0(argv[argc - argc]);
change_interrupt_handler();
change_child_handler();
respond_to_shell_commands();
// silence compiler warning with unnecessary return
return 0;
} | {
"domain": "codereview.stackexchange",
"id": 19550,
"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, shell, unix, posix",
"url": null
} |
fizzbuzz, brainfuck
BUZZ
--> Create indicator
++++++[->+++++++++++<]> Create B
[->+>+>+>+<<<<] Copy 4x B
+++++ Set modulo operator to 5
>>+>++++++>++++++> Adjust BBBB to BCHH
++++++++[-<++++<++++<++++>>>] Make lower case
++++++[-<+++<+++<+++>>>] Adjust Bchh to Buzz
>> Leave two zeros at the end
-->--- Mark the ending with 254 and 253
END OF SETUP
ALGORITHM START
+[-<+]- Go backwards to the 255 mark
<< Go to the countdown
[
->> Decrease countdown
>+> Increase counter
++[-->++]--> Find next 254 and go one step beyond it
Loop through all 254s
+++[--- Make sure that we are not at 253 (end)
<-- Go to 254 marker and change to 252 to indicate that we are processing it
>+ Increase fizzbuzz counter
>- Decrease fizzbuzz countdown | {
"domain": "codereview.stackexchange",
"id": 15577,
"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": "fizzbuzz, brainfuck",
"url": null
} |
ros, ros-fuerte
Title: replace the existing fuerte with a new copy
ubuntu 12.04 and ros fuerte
Hi,
I currently have fuerte and ubuntu 12.04. I would like to remove all the components of fuerte and again install a new copy of fuerte with all the components. I think i have messed up some files in opt/ros/fuerte.
Any suggestions?
Originally posted by sai on ROS Answers with karma: 1935 on 2013-05-14
Post score: 0
Did you manually messed with files in /opt/ros? Generally there is no need to do so.
Uninstall all fuerte packages with config removal: sudo aptitude purge --prompt ros-fuerte~n
Check directories for left files you don't want anymore:
/opt/ros
~/.ros
~/ros_workspace, ~/ros_stacks or similar
...?
Install fuerte
Originally posted by felix k with karma: 1650 on 2013-05-15
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by joq on 2013-05-16:
At the command line: sudo apt-get remove ros-fuerte-*, then re-install. | {
"domain": "robotics.stackexchange",
"id": 14174,
"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, ros-fuerte",
"url": null
} |
ros, messages
Originally posted by Tsirif on ROS Answers with karma: 106 on 2014-12-19
Post score: 5
ROS used to have messages with a common base class. Switching to templated messages made things faster and enabled custom datatypes with custom serialization.
You can find the relevant changelog here: http://wiki.ros.org/ROS/ChangeList/1.2/roscpp_changes The behaviour has been moved into templated traits.
Some of the in process reviews are linked from there to here and here
There are techniques to operate on the data as @Wolf points out. Shape Shifter is an example of how to work with messages without fully knowing their type.
Originally posted by tfoote with karma: 58457 on 2015-03-02
This answer was ACCEPTED on the original site
Post score: 3 | {
"domain": "robotics.stackexchange",
"id": 20385,
"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, messages",
"url": null
} |
matrix nearness problems. Note that a permutation matrix is orthogonal, its inverse is An immediate consequence of Theorem 1. (29) The trace of a matrix is also equal to the sum of its eigenvalues: trace{A} ˘ X ‘ ‚‘ ˘trace{⁄} (30) with ⁄ being the matrix of the eigenvalues of A. The trace of a square matrix A, denoted by tr(A), is defined to be the sum of its diagonal elements. Matrix Room. In Section 4, we deduce the zero asymptotics for the orthogonal matrix polyno- mials from the matrix of measures W. 91 - Last update: November 29, 2007. The trace of a square matrix A is the sum of the elements along the main diagonal. Both hA;Bii= trace ATBand hA;Bi= trace ABT de ne an inner product on R2 2. Symmetric idempotent matrices. Transpose, trace, inverse. Enjoy! tracematrix. For frame-size N (widthxheight), the length of m-sequences is N, hence, there are N orthogonal m-sequences. The trace of the matrix is the sum of the main diagonal For this reason it is possible to define the trace of | {
"domain": "loscoprisport.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.979354072876341,
"lm_q1q2_score": 0.8182342109010522,
"lm_q2_score": 0.8354835432479661,
"openwebmath_perplexity": 616.5236194341313,
"openwebmath_score": 0.8378595113754272,
"tags": null,
"url": "http://aqw.loscoprisport.it/trace-of-orthogonal-matrix.html"
} |
c#, object-oriented, coordinate-system, checkers-draughts
Title: 3-axis coordinate system for a Chinese Checkers board About a year ago, my brother and I came up with this cool idea for how to solve the problem of determining if any given "cell" on a Chinese Checkers board was adjacent to the cell in question.
Recently we started digging our teeth back into the idea and how we could work on variations of the game in which more than directly adjacent cells are of interest. I took up the task of figuring out how to adjust the grid system.
We'd previously developed some concept code in both C++ and C#, but decided for this project to work in C# (which I'm a little rusty in; been working with C and C++ mostly lately). To start, I merged the concepts of coordinates and direction into a more mathematical "vector" concept. However, it quickly became apparent that it is valuable to have a type-enforced way of separating unit vectors from vectors of non-unit magnitude. | {
"domain": "codereview.stackexchange",
"id": 21172,
"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, coordinate-system, checkers-draughts",
"url": null
} |
computability, reductions, semi-decidability
and for now only have a vague idea about it. You can define a notion of reducibility which will ensure that if $A$ reduces to $B$ and $B$ is recognizable then so is $A$. The definition allows an oracle call to $B$, but the semantics are different: if the contents of the oracle tape are in $B$ then the machine continues, and otherwise it gets stuck (never halts). | {
"domain": "cs.stackexchange",
"id": 5554,
"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": "computability, reductions, semi-decidability",
"url": null
} |
hardware.... Are, 1 ) the complement of a product is equal to the sum of the Boolean software. System to manipulate logic equations so that the minimum can be written as 17 is used as a Boolean is. Optimize minimization Boolean algebra finds its most practical use in the expressions of logic.... Manipulate logic equations can view Result with Detail Solution of each Question after completion of the Test of logic.... To the sum of the Boolean expression can be found the same as ordinary algebra reminded of! Boolean expression can be written as 17 the rules such that there is less terms and each! One minimization even if others are possible the simplified form of the terms AB a... A variable and is represented by a 1 ) the complement of a variable is main... Would never really use it 10 through 12 will be viewed in terms of the simpler rules the! The laws previously discussed and every Boolean algebraic theorem to simplify their hardware implementation form important of. The minimum can | {
"domain": "kathytaslitzinteriors.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9473810481379379,
"lm_q1q2_score": 0.817960856735764,
"lm_q2_score": 0.8633916187614823,
"openwebmath_perplexity": 791.7693690131123,
"openwebmath_score": 0.6016388535499573,
"tags": null,
"url": "http://kathytaslitzinteriors.com/tutta-colpa-btoxlu/page.php?aea331=boolean-algebra-minimization"
} |
java, performance, programming-challenge, primes
To put things into perspective: my SPOJ TDPRIMES submission from which the pseudo code was taken (printing every 100th prime up to 100,000,000) clocked 190 milliseconds on SPOJ (C#). The time for sieving the first 10,000 prime-indexed primes with this approach should be on the order of a millisecond. | {
"domain": "codereview.stackexchange",
"id": 19388,
"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, performance, programming-challenge, primes",
"url": null
} |
python, django
"""Creating the user with
user = User(...)
user.save()
does not properly hash and salt the password. Although it does
save it to the database, attempting
self.client.login(username='theusername', password='thepassword')
fails (returns False)
See
https://docs.djangoproject.com/en/1.7/ref/contrib/auth/#django.contrib.auth.models.UserManager.create_user
http://stackoverflow.com/questions/26306424/cant-login-a-just-created-user-in-a-django-test
"""
user = User.objects.create_user(
username=test_user['username'], password=test_user['password'],
first_name=test_user['first_name'],
last_name=test_user['last_name'], email=test_user['email'])
#The user's id is automatically created by the database. To function
#as the foreign key, it must be duplicated to the profile.
profile = UserProfile(user_id=user.id, birth_year=test_user['birth_year'])
profile.save() | {
"domain": "codereview.stackexchange",
"id": 10075,
"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, django",
"url": null
} |
quantum-mechanics, homework-and-exercises, hilbert-space, quantum-information, notation
Having recognised this, we are therefore free to choose $a$ and $b$ such that $a$ is real - if $a$ were not real, we could just shift the phase of $|\psi\rangle$ so it was. Using the polar representation of complex numbers, we can then just redefine our coefficients by $b\to e^{i\phi}b$ so $b$ is real and $\phi$ is its phase. You should recognise we have not made any restrictions here, we have just changed how we are describing things. We can restate our original restriction then by $|a|^2 + |e^{i\phi}b|^2 = a^2 + b^2 = 1$ where both $a$ and $b$ are real. Immediately looking at this you should be reminded of Pythagoras' theorem, which might remind you of trigonometry, and further you could notice how this related to the unit circle. Given that $-1 \leq a \leq 1$, we can represent it as $a =\cos(\frac{\theta}{2})$. One of the most important identities of trigonometry is that $\sin^2(x) + \cos^2(x) = 1$, which comes directly from Pythagoras' theorem. We can thus say that $b^2 = 1 - a^2 = | {
"domain": "physics.stackexchange",
"id": 49680,
"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, homework-and-exercises, hilbert-space, quantum-information, notation",
"url": null
} |
java
Title: Efficiently managing connections, prepared statements and ResulSet Review: Please review the User class, mainly CRUD operations, getUsers, insert, delete method and Connection class.
Background: A User class implementing an interface IUser that provides a function getUsers that returns either ArrayList of UserBeans or throws an Exception as per the contract, caller handles all kinds of exceptions. Also provided insert and delete.
Connection to MySQL DataSource is static and implemented as Singleton to be shared between User and other classes. Didn't want to use DataSource provider by the container and depend on it, for the purpose to make it easy for deployment in different environments.
IUser
public interface IUser {
ArrayList<UserBean> getUsers() throws SQLException;
UserBean insert(String emailAddress) throws SQLException;
void delete(int id) throws SQLException;
}
User
public class User implements IUser {
private DataSource dataSource; | {
"domain": "codereview.stackexchange",
"id": 29938,
"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",
"url": null
} |
c++, beginner, homework, bioinformatics
}
bool match(char a, char b) {
return (AT(a, b) || CG(a, b));
}
int main() {
int case_count = 0;
string base;
string temp;
int base_size;
int temp_size;
int count;
cin >> case_count;
for (int i = 0; i < case_count; ++i) {
cout << "Case " << i << ":\n";
bool check = false;
cin >> base;
cin >> temp;
base_size = base.size();
temp_size = temp.size();
if (base_size < temp_size) {
cout << "None";
continue;
}
if (base_size == temp_size) {
count = 0;
for (int index = 0; index < base_size; ++index) {
if (!(match(base[index], temp[index]))) {
cout << "None\n";
break;
}
else
count++; | {
"domain": "codereview.stackexchange",
"id": 16552,
"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, homework, bioinformatics",
"url": null
} |
ros, teb-local-planner, ros-kinetic, robot
max_vel_y: 0.0
acc_lim_y: 0.0
footprint_model/type: "point"
#### Goal Tolerance Parameters ####
# 2.5 degrees: 0.0436332313
# 5.0 degrees: 0.0872664626
# 10.0 degrees: 0.174532925
xy_goal_tolerance: 0.2
yaw_goal_tolerance: 0.2
free_goal_vel: false
#### Trajectory Configuration Parameters ####
dt_ref: 0.3
dt_hysteresis: 0.1
min_samples: 3
global_plan_overwrite_orientation: true
global_plan_viapoint_sep: -0.1
max_global_plan_lookahead_dist: 10
force_reinit_new_goal_dist: 1.0
feasibility_check_no_poses: 4
publish_feedback: false
shrink_horizon_backup: true
allow_init_with_backwards_motion: false
exact_arc_length: false
shrink_horizon_min_duration: 10.0
teb_autosize: true | {
"domain": "robotics.stackexchange",
"id": 33632,
"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, teb-local-planner, ros-kinetic, robot",
"url": null
} |
python, programming-challenge, recursion, time-limit-exceeded, fibonacci-sequence
def fibonacci(n):
if n in cache:
return cache[n]
if n == 1 or n == 2:
return 1
else:
result = fibonacci(n-1) + fibonacci(n-2)
cache[n] = result
return result | {
"domain": "codereview.stackexchange",
"id": 25918,
"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, programming-challenge, recursion, time-limit-exceeded, fibonacci-sequence",
"url": null
} |
quantum-information, quantum-entanglement, quantum-computer
So the answer seems to be that if one of the qubit clocks are boosted, if the degree of freedom is something like spin, then entanglement can remain although they would no longer be in perfect sync. Remember that entanglement does not mean the two systems are perfectly the same or unchanging, but rather that describing one system will necessarily imply things about the other system in a nontrivial way. | {
"domain": "physics.stackexchange",
"id": 60608,
"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-information, quantum-entanglement, quantum-computer",
"url": null
} |
quantum-chemistry, density-functional-theory, basis-set, ab-initio
The use of Pople-style (STO-nG, 3-21G, 6-31G*, 6-311++G(d,p), etc.) basis sets would be incorrect with wavefunction-based methods, perhaps even for qualitative understanding depending on how "difficult" your system is. Like the TURBOMOLE basis sets, they are designed to capture the mean-field atomic energies, but many have constraints (identical s- and p-type exponents, the "SP" functions that are often seen) due to the computational resources available at the time of their creation. Many of the older basis sets (notably 6-31G and not 6-311G) were optimized to use Cartesian rather than pure d-type functions, leading to potential inconsistencies in results. It is also not as obvious how to systematically improve the quality of the basis sets, and none are larger than triple-$\zeta$. Ultimately, the virtual MO space created by these basis sets is not sufficient to recover the correlation energy, and the benefits of using coupled cluster are completely lost. | {
"domain": "chemistry.stackexchange",
"id": 5899,
"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-chemistry, density-functional-theory, basis-set, ab-initio",
"url": null
} |
quantum-field-theory, string-theory, gauge-theory, ads-cft, partition-function
The first line of equation $C.4$ seems to be the same as equation $5.3$ of this earlier linked paper but not quite...
I was pretty much confused with the idea in equation $C.5$ and $C.6$ of thinking the eigenvalues of the $U(N_c)$ group on the circle to be given by a distribution function $\rho (\theta) \geq 0$ with a mysterious normalization as in equation $C.5$.
I would be glad if someone can help understand how equation C.6 was determined.
A lot of steps seem to be skipped here which I found hard to reinstate!
Going by this paper it seems that the original more general equation $2.43$ on page 17 has two possible limits as in equation $2.45$ on page 17 when there are $c$ matter fields in the adjoint and $N_c \rightarrow \infty$ or equation $2.48$ in the Veneziano limit with fundamental matter fields.
I would like to know the derivation/reference for the equations 2.45 and 2.48 cited above. | {
"domain": "physics.stackexchange",
"id": 4182,
"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-field-theory, string-theory, gauge-theory, ads-cft, partition-function",
"url": null
} |
c++, boost
boost_cmd_po::options_description cmd_options::init_cmd_po_logger_options() {
auto group = boost_cmd_po::options_description("Logger options");
group.add_options();
return group;
}
boost_cmd_po::options_description cmd_options::init_cmd_po_hidden_options() {
auto group = boost_cmd_po::options_description("Logger options");
group.add_options()
("log-path,l", boost_cmd_po::value<std::string>(&_options_data.log_file_path)->default_value( "/home/sherlock/message_from_computer"), "Path to login/logout logger.");
return group;
} | {
"domain": "codereview.stackexchange",
"id": 36247,
"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++, boost",
"url": null
} |
Incidentally, do you know which "very" popular property of mathematics (a+b)/c = a/c + b/c is an example of?
Regards,
Rich B.
8. Are you saying that : 1-(3/(X+5))
Is that same as: 1+( 7/X-3))
Because they're not. Right?
Incidentally, do you know which "very" popular property of mathematics (a+b)/c = a/c + b/c is an example of?
What is this? Isnt it just adding...
9. Originally Posted by phgao
Are you saying that : 1-(3/(X+5))
Is that same as: 1+( 7/X-3))
Because they're not. Right?
What is this? Isnt it just adding...
No, they are not. I was just giving another example.
It is adding indeed (along with another operation). But (2^3)(2^5) = 2^8 is just multiplying. Nevertheless, it is multiplication via one of the "special" properties of exponents. Likewise, (a+b)/c = a/c + b/c utilizes a special property, the name of which shall remain incognito until others have had an opportunity to guess (answer).
Enjoy the day!
Rich B. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9852713878802044,
"lm_q1q2_score": 0.8167296963881612,
"lm_q2_score": 0.8289388146603364,
"openwebmath_perplexity": 1255.6665762599328,
"openwebmath_score": 0.7059183120727539,
"tags": null,
"url": "http://mathhelpforum.com/math-topics/1854-equation.html"
} |
# Given series of complex terms converges locally uniformly
Prove that the series $$f(z)=\frac{z}{1-z^2}+\frac{z^2}{1-z^4}+\frac{z^4}{1-z^8}+ \cdots$$ conveges locally uniformly to $\frac{z}{1-z}$ when $z$ is in the unit disc $D$ and to $\frac{1}{1-z}$ when $z \notin \overline{D}.$ Are these two limiting functions analytic continuations of each other? If not, is $\partial D$ the natural boundary of analyticity for $f(z)$ ?
I came across this problem while studying for my complex preliminaries. I tried to factor out the term $\frac{z}{1-z}$ and consider the difference $|f(z)-\frac{z}{1-z}|$ and go by to show that it's less than $\epsilon$ for all $z.$ But it wasn't successful. And any help in this part and other two parts are much appreciated. I wouldn't ask if I was able to solve the problem. Thank you for your time. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.97112909472487,
"lm_q1q2_score": 0.8366648248481301,
"lm_q2_score": 0.8615382129861583,
"openwebmath_perplexity": 113.83106264852245,
"openwebmath_score": 0.9400172829627991,
"tags": null,
"url": "https://math.stackexchange.com/questions/1892568/given-series-of-complex-terms-converges-locally-uniformly"
} |
astronomy, astrophysics, solar-system, asteroids, comets
If we observe two objects exhibiting identical behavior/measurements/observations, the only reasonable scientific deduction is that the objects are most likely composed of the same materials and operate with the same mechanics - at the very least until future observations can confirm/deny. This appears to be indisputable logic, and the physics community at StackExchange has collectively been unable to demonstrate otherwise as of yet, thereby indirectly validating the integrity of this logic. | {
"domain": "physics.stackexchange",
"id": 32799,
"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": "astronomy, astrophysics, solar-system, asteroids, comets",
"url": null
} |
c++
void glider_gun_conf(frame_matrix &grid) {
size_t ref_point_y = Frame::FRAME_HEIGHT / 4;
size_t ref_point_x = Frame::FRAME_WIDTH / 4;
using namespace game_of_life;
// left square
grid[ref_point_y][ref_point_x] = {CELL_SHAPE, colors.at(CELL_COLOR)};
grid[ref_point_y + 1][ref_point_x] = {CELL_SHAPE, colors.at(CELL_COLOR)};
grid[ref_point_y][ref_point_x + 1] = {CELL_SHAPE, colors.at(CELL_COLOR)};
grid[ref_point_y + 1][ref_point_x + 1] = {CELL_SHAPE, colors.at(CELL_COLOR)};
// left square
// middle part 10 to right
ref_point_x += 10; | {
"domain": "codereview.stackexchange",
"id": 45395,
"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++",
"url": null
} |
electrostatics, electrons, electric-current, charge, conventions
Title: Why do electrons flow in the opposite direction of the electric field? I was taught that the potential decreases in direction of electric field but when we place a positive charge in between it's electric field is too in that same direction but the negative charge has exactly opposite direction of electric field to the parent electric field....so why is it opposite?
why is it opposite? | {
"domain": "physics.stackexchange",
"id": 69246,
"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, electrons, electric-current, charge, conventions",
"url": null
} |
events, Independent and dependent events, Probability of independent and dependent events, Probability lesson plan, 1 exploration identifying independent and dependent events, Independent. 17 The student will identify the domain, range, independent variable, or dependent variable in a given situation. The SOL test in word problems, so this is a great review activity. If the incidence of one event does affect the probability of the other event, then the events are dependent. A customer selects her first topping at random and then selects another one at random from the remaining toppings. For example, the complementary events A and A cannot occur simultaneously. P(B) = 2/5 × 11/29 = 132/870 = 22/145. All right, we were talking about how do you recognize that an event is dependent or independent? [00:00:31] [00:00:31] It is important that the students understand the concept of independent and dependent events as a part of the probability unit which is a very. Worksheets are Independent | {
"domain": "everwoodbiocostruzioni.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9871787883738261,
"lm_q1q2_score": 0.80478022772877,
"lm_q2_score": 0.8152324960856177,
"openwebmath_perplexity": 351.12934814143114,
"openwebmath_score": 0.746311366558075,
"tags": null,
"url": "http://kbjx.everwoodbiocostruzioni.it/dependent-probability.html"
} |
filters, time-frequency
Anything that doesn't require trial and error is suspect, scientific methodology wise. I suggest that you try to be more specific about what filtering out different motions actually means. Some kinds of phenomena are a superposition of features which are often separable, of which some can be "filtered out" and others don't lend themselves to that.
You might want to use a tool known as the Short Time Fourier Transform (STFT) and see if you can eye ball any patterns associated with desired/undesired motion.
Finally, try Google Scholar. | {
"domain": "dsp.stackexchange",
"id": 5404,
"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": "filters, time-frequency",
"url": null
} |
pl.programming-languages, dc.parallel-comp, concurrency
Title: Difference between Strict Consistency and Sequential Consistency I understand strict and sequential consistency independently fairly well.
Strict C basically enforces the actual order in which the instructions ran on the global clock.
Sequential Consistency basically enforces the order only on one processor.
I'm having trouble putting together some literature though.
http://www.cs.nmsu.edu/~pfeiffer/classes/573/notes/consistency.html describes sequential consistency as allowing for memory 'lag'. It may take time for a write to propagate across all processors. But when it does, it reaches all of them at once which is fine. Thus, the following is valid under Sequential Consistency
P1: W(x)1
-----------------------
P2: R(x)0 R(x)1
What concerns me now is the following processes, which is something like Dekker's algorithm.
P1: W(x)1 R(y)0
-----------------
P2: W(y)1 R(x)0 | {
"domain": "cstheory.stackexchange",
"id": 5749,
"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": "pl.programming-languages, dc.parallel-comp, concurrency",
"url": null
} |
programming, qiskit
molecule = Molecule(geometry=[['H', [0., 0., 0.]],
['H', [0., 0., 0.735]]],
charge=0, multiplicity=1)
driver = PySCFDriver(molecule = molecule, unit=UnitsType.ANGSTROM, basis='sto3g')
The electronic Hamiltonian written in term of fermionic operators is:
es_problem = ElectronicStructureProblem(driver)
second_q_op = es_problem.second_q_ops()
print(second_q_op[0])
+-+- * (0.18093119978423158+0j)
+ +--+ * (-0.18093119978423156+0j)
+ -++- * (-0.18093119978423156+0j)
+ -+-+ * (0.18093119978423156+0j)
+ IIIN * (-0.47189600728114073+0j)
+ IINI * (-1.2563390730032507+0j)
+ IINN * (0.48365053047106565+0j)
+ INII * (-0.47189600728114073+0j)
+ ININ * (0.6985737227320187+0j)
+ INNI * (0.6645817302552972+0j)
+ NIII * (-1.2563390730032507+0j)
+ NIIN * (0.6645817302552972+0j)
+ NINI * (0.675710154803517+0j)
+ NNII * (0.48365053047106565+0j) | {
"domain": "quantumcomputing.stackexchange",
"id": 2725,
"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": "programming, qiskit",
"url": null
} |
(I'm referring to the $n$th element of a vector $\vec v$ as $v_n$.)
• This is the best answer here. Feb 8 '18 at 20:36
Every answer here gives the equation $8a+4b-6c=0$. None mentions that this equation represents a plane perpendicular to the given vector. I am sure that the omission was an oversight of each respondent. But it deserves mention and emphasis. In the plane perpendicular to any vector, the set of vectors of unit length forms a circle. So answers will vary. The vectors $(-1,2,0)^t$ and $(2,0,3)^t$ can be chosen to be a basis for the solution space of the plane: solve for a, divide by 8, and let $2b$ and $3c$ be independent variables. You can divide each by its length $\sqrt{5}$ and $\sqrt{13}$ respectively, and take a trigonometric combination of them to get a general solution.
An automated procedure: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109538667758,
"lm_q1q2_score": 0.8141548346962671,
"lm_q2_score": 0.8267117983401363,
"openwebmath_perplexity": 327.30971919962604,
"openwebmath_score": 0.8307218551635742,
"tags": null,
"url": "https://math.stackexchange.com/questions/133177/finding-a-unit-vector-perpendicular-to-another-vector/413235"
} |
scheme, makefile, make
Title: Standalone GNU Makefile tracking `@import` statements in Sass The following is a (working) excerpt from the Makefile I want to use in web projects. I wanted this Makefile to contain all the necessary code and not rely on other self-written files. Partly, because I'm stubborn, partly because I just want to copy it from project to project.
The code uses a simple regexp match to find @import statements in *.scss files recursively and constructs dependency statements for my CSS targets.
I know that I probably should use Wellington for this. But I've been using sassc from before I knew about Wellington. Back then I was using a shell script for finding @import statements and had a Makefile that generated and used -include to generate and include a lot of *.dep files. And again, I felt somewhat stubborn: I wanted to make this work. | {
"domain": "codereview.stackexchange",
"id": 30289,
"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": "scheme, makefile, make",
"url": null
} |
digital-communications, modulation, demodulation
data or more usually, the raw matched-filter/correlator outputs in
the I and Q branches at two successive sampling instants.
Finally, you can apply the same idea to $M$-PSK with $M = 2^n > 4$
with the successive phase shifts being labeled with the Gray-coded representations of the integers $\{0, 1, 2, \ldots, 2^n-1\}$.
Equations $(1)$ and $(2)$ above get modified to be arithmetic modulo
$M$ but the same ideas work. The receivers are more complicated, though. | {
"domain": "dsp.stackexchange",
"id": 3759,
"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": "digital-communications, modulation, demodulation",
"url": null
} |
performance, graphics, hlsl
float4 main(VsOutput IN) : COLOR
{
float4 texColor = tex2D(textureSampler, IN.texCoord);
float3 specular = specularLightIntensity;
float materialPower = 9.0f;
float3 light = normalize(IN.dirLightPosition);
float3 view = normalize(IN.view);
float3 normal = normalize(IN.normal);
float3 halfway = normalize(light + view);
float3 processedSpecular = pow(saturate(dot(normal, halfway)), materialPower)
* specular;
float alphaChannel = texColor.a + filterColor.a;
float4 color = 1.2f * (texColor + filterColor.a * filterColor + float4(processedSpecular, 0.0f));
return float4(color.r, color.g, color.b, filterColor.a + texColor.a);
} Late response to this, but all I can suggest is leveraging the per-component math of HLSL better in your shaders...
Vertex Shader
float xCoordMultiplication : register (c13);
float yCoordMultiplication : register (c14); | {
"domain": "codereview.stackexchange",
"id": 29812,
"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, graphics, hlsl",
"url": null
} |
navigation, spin, spinonce, publisher, ardrone-autonomy
ey=(319-posY)/320.0;
ez=(179-posZ)/180.0;
ex=(40.0-posX)/40.0;
dey=-(ey-eypa)/1.0;
dez=-(ez-ezpa)/1.0;
dex=-(ex-expa)/1.0;
iey=iey+ey;
iez=iez+ez;
iex=iex+ex;
uy=ey+dey;
ux=ex/4+dex;
uz=ez+dez;
if(abs(uy)>1.0)
{
uy=uy/abs(uy);
}
if(abs(ux)>1.0)
{
ux=ux/abs(ux);
}
if(abs(uz)>1.0)
{
uz=uz/abs(uz);
}
twist_msg.angular.z=uy;
twist_msg.linear.x=ux;
//ROS_INFO("Ball Position:[%f,%f,%f,%f]",ex,dex,iex,ux);
pub_twist.publish(twist_msg);
ros::spinOnce();
}
int main(int argc, char **argv)
{
//Initializing ROS
ros::init(argc, argv, "control");
ros::NodeHandle nh;
ros::Rate loop_rate(50); | {
"domain": "robotics.stackexchange",
"id": 22083,
"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, spin, spinonce, publisher, ardrone-autonomy",
"url": null
} |
newtonian-mechanics, work
Without any more context than is given, I'd conclude that the textbook author(s) need remedial physics classes. | {
"domain": "physics.stackexchange",
"id": 8590,
"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": "newtonian-mechanics, work",
"url": null
} |
species-identification, entomology
Title: Camouflage grasshopper identification I came across the following grasshopper this afternoon while walking to my car. It was initially resting amongst some fallen tree leaves, but as I got closer to my car I must have startled it, as it then ran to the tree, and is also how I noticed it.
It was calm enough for me to temporarily hold it in a cut-in-half water bottle, and I was able to take a few more pictures, and record a brief video. Afterwards, I released the grasshopper back into the grass and it promptly flew away. :)
When searching for its species, I was only able to find a dessert grasshopper, Trimerotropis pallidipennis, but I live in KY, and not out west, so I don't think that's it.
Can someone ID this for me please?
Location: Central KY, USA. You've found a Dissosteira carolina or carolina locust.
I'm not completely sure, but I think this is a male.
They are quite common in North America. | {
"domain": "biology.stackexchange",
"id": 7822,
"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",
"url": null
} |
ros, ros2, jointstate
Originally posted by gvdhoorn with karma: 86574 on 2021-09-27
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by ijnek on 2021-09-27:
@gvdhoorn Thank you for your insight on this topic.
I feel that it would have been more natural if the joint_names[] field of JointTrajectory.msg was inside JointTrajectoryPoint.msg, but I think that design decision comes from trying to avoid having the joint_names repeated for every point in time.
Nonetheless, I think it makes sense to have a separate data type such as JointCommand.msg:
string[] names
float64[] positions
float64[] velocities
float64[] accelerations
float64[] effort | {
"domain": "robotics.stackexchange",
"id": 36948,
"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, ros2, jointstate",
"url": null
} |
data. Once we have an estimation of the kernel density funtction we can determine if the distribution is multimodal and identify the maximum values or peaks corresponding to the modes. Kernel density estimation is a method of estimating the probability distribution of a random variable based on a random sample. This video gives a brief, graphical introduction to kernel density estimation. I am using Python 3.8 and sklearn 0.22. JED is a powerful … More info I would like to plot a 2D kernel density estimation. Python; Tags . Kernel density estimation is a way to estimate the probability density function (PDF) of a random variable in a non-parametric way. The estimation works best for a unimodal distribution; bimodal or multi-modal distributions tend to be oversmoothed. The kernel function typically exhibits the following properties: Symmetry such that $$K(u) = K( … As I mentioned before, the default kernel for this package is the Normal (or Gaussian) probability density function (pdf): | {
"domain": "konwakai.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9669140216112958,
"lm_q1q2_score": 0.8057532417643981,
"lm_q2_score": 0.8333246015211008,
"openwebmath_perplexity": 1111.0922776881075,
"openwebmath_score": 0.5756372213363647,
"tags": null,
"url": "http://konwakai.com/guild-wars-phnokqh/kernel-density-estimation-python-c63753"
} |
filters
Initially assume zero bias.
For each extrapolation step, subtract bias from measured $\omega _\psi$
On each new GPS bearing, calculate the change in bias as $\frac{\Delta \psi _{gyro} - \Delta \psi _{GPS}}{t}$
Add this change to the previous bias estimate
Determine the accuracy of the new bias estimate, considering the accuracy of $\psi _{GPS}$, approximate standard deviation of gyroscope output at rest and time elapsed
If we have a previous bias estimate (other than the initial assumption of zero), run the old and new bias estimate through a Kálmán filter; else simply continue with the new bias estimate
Return to step 2.
Results look good so far – this visibly reduces bias without introducing any new artifacts. Responsiveness still needs to be improved, which I can probably tackle by tweaking my accuracy model. | {
"domain": "dsp.stackexchange",
"id": 3630,
"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": "filters",
"url": null
} |
A space $X$ is strongly $\tau$-monolithic if for any $A \subset X$ with $\lvert A \lvert \le \tau$, we have $w(\overline{A}) \le \tau$. A space $X$ is strongly monolithic if it is strongly $\tau$-monolithic for all infinite cardinal $\tau$. It is straightforward to show that $X$ is strongly monolithic if and only if for every subspace $Y$ of $X$, the density of $Y$ equals to the weight of $Y$, i.e., $d(Y)=w(Y)$.
In any monolithic space, the density and the network weight coincide for any subspace, and in particular, any subspace that is separable has a countable network. As a result, any separable monolithic space has a countable network. Thus any separable space with no countable network is not monolithic, e.g., the Sorgenfrey line. On the other hand, any space that has a countable network is monolithic. | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9799765563713599,
"lm_q1q2_score": 0.8405926301302505,
"lm_q2_score": 0.8577681013541611,
"openwebmath_perplexity": 251.470749248413,
"openwebmath_score": 0.999870777130127,
"tags": null,
"url": "https://dantopology.wordpress.com/category/compact-space/"
} |
reinforcement-learning, q-learning
How can I combat it?
This is still an ongoing area of research. Here are a couple of things that have worked for me:
Low learning rates, and defences against sudden large gradients (e.g. gradient clipping).
Regularisation. Sadly dropout seems not to work in RL, but weight decay is still useful to prevent over-fitting, and it also helps combat catastrophic forgetting because it prevents bootstrap estimates of long-unseen state/action combinations from returning radically different Q values to the rest of the system.
Keep some early experience around from when the agent was still performing badly - this allows the agent to still train with some bad cases and prevents the Q function predicting that "everything is awesome" because it still has examples to learn from where this is not the case. | {
"domain": "ai.stackexchange",
"id": 979,
"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": "reinforcement-learning, q-learning",
"url": null
} |
c#, logging, helper, httpclient
throw new ApplicationException(fullErrorMessage);
}
}
}
Its use would look like this:
var response = await httpClient.SendAsync(message);
await response.CheckResponseAndThrowIfIsError("My Error Message Here", _logger); Here are my observations:
if (response.IsSuccessStatusCode == false)
I would rather suggest to have an early exit by inverting the if condition
Having a single giant guard condition is less expressive and maintainable IMHO
string fullErrorMessage = "";
if (!string.IsNullOrEmpty(errorMessage))
{
fullErrorMessage = $"{errorMessage}\r\n";
}
else
{
// Put in something generic so that the log as a value instead of a blank line.
errorMessage = "Call Failed";
}
The fullErrorMessage can be constructed in a single step whenever you throw the exception so, I would advice against build it incrementally
The else block is basically a fallback value if the errorMessage parameter is blank
I would suggest a simple ?: structure instead | {
"domain": "codereview.stackexchange",
"id": 44899,
"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#, logging, helper, httpclient",
"url": null
} |
javascript
Composure<span data-attribute-name="composure"></span>
Intelligence<span data-attribute-name="intelligence"></span>
Wits<span data-attribute-name="wits"></span>
Resolve<span data-attribute-name="resolve"></span>
</div> | {
"domain": "codereview.stackexchange",
"id": 32962,
"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",
"url": null
} |
mean of each column from Xval. In [638]: # Create preProcess object Xval = as.data.frame(Xval) preObj <- preProcess(Xval,method="center") # Center the data- subtract the column means from the data points Xval_centered <- predict(preObj,Xval) Then, calculate its variance. In [639]: Xval_centered = as.matrix(Xval_centered) sigma2=diag(var(Xval_centered)) sigma2 = diag(sigma2) sigma2 2.5261 0 0 1.63133 Now, let's calculate pval of the cross-validation data Xval. In [640]: A=(2*pi)^(-ncol(Xval_centered)/2)*det(sigma2)^(-0.5) B = exp(-0.5 *rowSums((Xval_centered%*%ginv(sigma2))*Xval_centered)) pval = A*B For cross-validation, let's use F1 score, which uses precision and recall. Precision and rcall in turn are calculated using true positive, false positive and false negative as defined below. tp is the number of true positives: the ground truth label says it's an anomaly and our algorithm correctly classied it as an anomaly. fp is the number of false positives: the ground truth label says | {
"domain": "datascience-enthusiast.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9808759671623987,
"lm_q1q2_score": 0.8042136753092373,
"lm_q2_score": 0.8198933425148214,
"openwebmath_perplexity": 3841.227988814255,
"openwebmath_score": 0.5578902959823608,
"tags": null,
"url": "https://datascience-enthusiast.com/R/anomaly_detection_R.html"
} |
cosmology, universe, space-expansion
Value of the Hubble parameter over time
Universe Expansion as an absolute time reference
and others like them. | {
"domain": "physics.stackexchange",
"id": 19197,
"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": "cosmology, universe, space-expansion",
"url": null
} |
modulation, complex, quadrature
As another step, I use an Arbitrary Waveform Generator (Rohde & Schwarz SMW200A) used as transmitter and a VSA (Rohde & Schwarz FSW) as a receiver where I see the same issues. Both instruments are calibrated and the transmitter has superior image rejection. For these reasons I assume I made a conceptional or algebraic mistake in my derivations/assumptions. I also attempt to answer my own question here based on my findings in Contradiction between complex baseband and real-valued baseband.
There is indeed a flaw in the model that I described and this is that the model is only valid if the only "nonideality" between TX and RX is the LO phase shift.
However, this breaks as soon as there is any filter in the RF path (which is always the case). In this case, the i output is not a linear combination of the I/Q input any more but a linear combination of filtered versions, each filtered with a different filter.
Hence, the proper model is the first suggested one:
$$ | {
"domain": "dsp.stackexchange",
"id": 6717,
"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": "modulation, complex, quadrature",
"url": null
} |
computability, logic, programming-languages, lambda-calculus, combinatory-logic
$$f = \underbrace{(\lambda r . (\ldots r \ldots r \ldots))}_{M} \underbrace{(\lambda r . (\ldots r \ldots r \ldots))}_{M}$$
However, this is not completely correct. Before, $f$ got substituted for $r$ inside $M$. But now we pass $M$ instead. We have to somehow fix all places where we use $r$ so that they reconstruct $f$ from $M$. Actually, this not difficult at all: Now that we know that $f = M M$, everywhere we use $r$ we simply replace it by $(r r)$.
$$f = \underbrace{(\lambda r . (\ldots (rr) \ldots (rr) \ldots))}_{M'} \underbrace{(\lambda r . (\ldots (rr) \ldots (rr) \ldots))}_{M'}$$
This solution is good, but we had to alter $M$ inside. This is not very convenient. We can do this more elegantly without having to modify $M$ by introducing another $\lambda$ that sends to $M$ its argument applied to itself: By expressing $M'$ as $\lambda x.M(xx)$ we get | {
"domain": "cs.stackexchange",
"id": 21377,
"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": "computability, logic, programming-languages, lambda-calculus, combinatory-logic",
"url": null
} |
css, ecmascript-6, twitter-bootstrap, vue.js, axios
var app = new Vue({
el: '#app',
data: {
users: [],
loading: true,
errored: false,
url: "https://randomuser.me/api/?&results=500&inc=name,location,email,cell,picture",
search: '',
page: 1,
perPage: 25,
pages: [],
},
methods: {
getUsers() {
axios
.get(this.url)
.then(response => {
this.users = response.data.results
})
.catch(error => {
console.log(error)
this.errored = true
})
.finally(() => this.loading = false)
},
setPages(users) {
this.pages.length = 0;
var numberOfPages = Math.ceil(users.length / this.perPage);
for (var index = 1; index <= numberOfPages; index++) {
this.pages.push(index);
}
},
paginate(users) { | {
"domain": "codereview.stackexchange",
"id": 33163,
"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": "css, ecmascript-6, twitter-bootstrap, vue.js, axios",
"url": null
} |
data-structures, hash-tables, java
(Exercise: Under these assumptions, for what value of $\lambda$ is the memory overhead minimised? I will say that it's greater than $\frac{1}{2}$ and less than $1$. It's not $0.75$; if it was, that would be part of my answer!)
So it does seem that under these assumptions, you would get significantly more efficient lookup and only pay a tiny increase in memory overhead. And that's just one of many tradeoffs that you could look at.
My guess is that the Java library implementers performed some back-of-the-envelope calculations similar to this, and some experiments to be certain, and found that this was acceptable. | {
"domain": "cs.stackexchange",
"id": 19662,
"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": "data-structures, hash-tables, java",
"url": null
} |
special-relativity, statistical-mechanics, temperature, kinetic-theory, doppler-effect
Proposed resolutions:
The resolutions that I imagine to this paradox are:
a) Depending on the frame of reference from which I measure the emitted blackbody radiation of the object, the radiation will undergo different Doppler blue/red-shifts. Thus the relativity of the temperature in the context of blackbody radiation, is preserved due to the Doppler effect.
b) I suspect that treating temperature as nothing but an average kinetic energy does not in general hold true, and to resolve this paradox, one should work with a more general definition of temperature (which I admit I do not know how in general temperature ought to be defined, if not in terms of state of motion of a system's particles). | {
"domain": "physics.stackexchange",
"id": 31612,
"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, statistical-mechanics, temperature, kinetic-theory, doppler-effect",
"url": null
} |
c#, api, interface, com, rubberduck
DrawResultTree(results);
}
private void DrawResultTree(IEnumerable<CodeInspectionResultBase> results)
{
var tree = Control.CodeInspectionResultsTree;
tree.Nodes.Clear();
foreach (var result in results.OrderBy(r => r.Severity))
{
var node = new TreeNode(result.Name);
node.ToolTipText = result.Instruction.Content;
node.Tag = result.Instruction;
tree.Nodes.Add(node);
}
}
} | {
"domain": "codereview.stackexchange",
"id": 10844,
"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#, api, interface, com, rubberduck",
"url": null
} |
thermodynamics, definition, conventions, physical-chemistry, degrees-of-freedom
As an example, consider a gas of heteronuclear diatomic molecules (like nitrogen). Such a molecule has three translational degrees of freedom associated with the movement of the center of mass, corresponding to the three terms in the translational kinetic energy, i.e.,
$$
\frac{1}{2}mv_x^2+\frac{1}{2}mv_y^2+\frac{1}{2}mv_z^2\,.
$$
It also has two$^1$ rotational degrees of freedom, corresponding to rotation about two perpendicular axes that are perpendicular to the axis of the molecule; the associated energies are
$$
\frac{1}{2}I_x \Omega_x^2+
\frac{1}{2}I_y \Omega_y^2\,.
$$
Finally, there are two internal vibrational degrees of freedom, as discussed above, associated with the motion of the two atoms in the molecule relative to each other along the axis of the molecule; the associated energy is
$$
\frac{1}{2}mv_z^2 +\frac{1}{2}m\omega^2 z^2\,.
$$
This corresponds to seven degrees of freedom per molecule, resulting in an internal equilibrium energy of
$$ | {
"domain": "physics.stackexchange",
"id": 98044,
"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, definition, conventions, physical-chemistry, degrees-of-freedom",
"url": null
} |
pandas, matplotlib
18,54,HR,Postgraduate,On-Campus,1,5.0,4,0,21668.4,Female,2014-05-07,1
19,25,Sales,Undergraduate,Recruitment Agency,5,4.0,4,0,78075.0,Male,2012-02-15,1
20,35,HR,Undergraduate,On-Campus,2,4.0,4,0,26824.5,Female,2008-01-15,1
21,50,HR,Postgraduate,Referral,5,4.0,0,0,78075.0,Male,2015-04-13,1
22,34,Purchasing,Postgraduate,Referral,4,2.0,7,1,59143.5,Male,2013-07-02,1
23,37,Sales,Undergraduate,Recruitment Agency,5,5.0,0,1,78075.0,Male,2016-03-22,1
24,31,Sales,Postgraduate,Walk-in,4,4.0,3,1,59143.5,Female,2006-09-05,1
25,53,Sales,Postgraduate,Walk-in,4,5.0,8,1,59143.5,Female,2005-10-08,1
26,45,Marketing,Undergraduate,Walk-in,4,3.0,8,0,59143.5,Male,2008-01-08,1
27,40,Purchasing,Undergraduate,Walk-in,4,3.0,4,1,59143.5,Female,2005-11-19,0 | {
"domain": "codereview.stackexchange",
"id": 44868,
"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": "pandas, matplotlib",
"url": null
} |
r, phylogeny
grep("Human",pars.a$tip.label)
length(grep("Human",ml.a.rooted$tip.label)
)
# thus there are 94 tip labels with that are designated TK (not TKL tyrosine kinase like)
# make a vector for each tip.label called tipcol with black on all of these...
#tipcol <- rep('black', length(tree$tip.label))
tipcol <- rep('black',length(pars.a$tip.label))
# make a vector with our list of kinase categories
#kinaseCats <- c("TK/", "TKL", "STE", "CK1", "AGC", "CAMK", "CMGC", "RGC")
kinaseCats <- c("Human","Rat","Murine","Bovine","Canine","Feline","Porcine","Gallus","Bat","Infectious","Transmissible")
# make a vector of color we want:
colorsList <-c("red", "darkolivegreen3", "blue", "orange", "blueviolet", "purple", "pink", "green","brown","navyblue","purple4")
# replace colours where grep gives "TK" as red, etc in a loop
#for(i in 1:length(kinaseCats)){
# tipcol[grep(kinaseCats[i], tree$tip.label)] <- colorsList[i]
#} | {
"domain": "bioinformatics.stackexchange",
"id": 1441,
"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": "r, phylogeny",
"url": null
} |
electricity, electric-circuits, electrons, electric-current, conductors
Title: Why do electrons follow the conductors shape? I'm stuck thinking about this situation. I imagine that there are two oppositely charged objects at short distance $r$, put inside an insulator (Can I say air?). They generate a net elctric field, but since they're apart there's no electrons flowing. Then I connect them with a bizzare conductive wire and electrons start flowing till balance is reached.
I wonder:
How and why the electron flow will follow the shape of the wire?
Is it beacause the net electric field?
Can we say that they prefer to follow a strange path through a
conductor than a straighter ,shorter one thorugh an insulator?
I tried to make a picture of the situation I describe. Since for my understanding it's easier to picture electrons flowing, I drew a reverse electric field so that charge will move from low to to high potential (hope I can do that!). | {
"domain": "physics.stackexchange",
"id": 39598,
"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": "electricity, electric-circuits, electrons, electric-current, conductors",
"url": null
} |
ros, ros-kinetic, multimaster
Obviously we want the different student projects not to interfere with each other.
And it also automatically isolates each robot -- and connected ROS nodes -- from each other.
Nothing prevents anyone from using the namespace of a different robot and mucking things up.
Using a separate master makes this much harder (not impossible, as it's a form of security-through-obscurity, but still).
Comment by pitosalas on 2019-06-22:
Thanks @gvdhoorn. Much better than actual answer. My robots have just a raspberry pi. Would running core on them be a cpu or memory load problem do you think?
Comment by gvdhoorn on 2019-06-22:
A master does not use significant amounts of CPU, it should be fine.
Unless students start using parameters as topics -- which I have seen -- but that would obviously be a no-no in any case. | {
"domain": "robotics.stackexchange",
"id": 33238,
"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, ros-kinetic, multimaster",
"url": null
} |
algorithm-analysis, time-complexity, runtime-analysis, knapsack-problems, pseudo-polynomial
So either I am still not getting what it means to have exponential "length of the input" is or there is some conflict with how people define length of the input. MIT video defines input size similar to how I think of $x$ while many other sources have a different opinion it seems. I see it as the total number of bits needed to represent the whole input, but some analysis just sees it as the number of bits needed to represent a numeric value that is only a part of the whole input. Is running time exponential in the input size if it is exponential in the size of a part of the input or the whole thing?? Please clarify!! First, the size of the input is the number of bits required to represent the input. When talking about complexity, we often assume that our input is represented as some bit-string. | {
"domain": "cs.stackexchange",
"id": 10553,
"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": "algorithm-analysis, time-complexity, runtime-analysis, knapsack-problems, pseudo-polynomial",
"url": null
} |
quantum-mechanics, operators, velocity, differentiation, notation
$$\dot{\hat{x}} = \frac{d\hat{x}}{dt}.$$
The trick is this is happening in the Heisenberg picture, not the Schrodinger picture that textbooks typically start with. There, you set an initial quantum state and then let the operators evolve with time. Hence that $\hat{x}$ acts on a positional wave function by multiplying by the position is only usually so at time zero.
The commutator relation,
$$m [\hat{x}, \dot{\hat{x}}] = i\hbar$$
establishes what $\dot{\hat{x}}$ is at time zero. Namely $-\frac{i\hbar}{m} \frac{\partial}{\partial x}$ when working on a positional wave function and where $\hat{x}$ is as you described (multiplying by position). | {
"domain": "physics.stackexchange",
"id": 89726,
"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, operators, velocity, differentiation, notation",
"url": null
} |
c++, time-limit-exceeded
Title: Handling addition of two binary numbers This code is for handling addition of two binary numbers, which can be as long as 100,000 bits... and up to 500,000 queries are performed.
High-level pseudocode:
First input N: number of bits in binary number A and B.
Second input Q: number of queries to be performed.
Next N inputs: 0/1s ... bits for A
Next N inputs: 0/1s ... bits for B
Next Q inputs are one of the following:
set_a INDEX VALUE: as a result I set a[INDEX] = VALUE
set_b INDEX VALUE: as a result I set b[INDEX] = VALUE
get_c INDEX: as a result I print c[INDEX] where C = A+B (binary addition, like 100 + 101 = 1001)
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <utility> // For pair
#include <iterator> // For iterator, bidirectional_iterator_tag, reverse_iterator
#include <climits> // For CHAR_BIT, ULONG_MAX
using namespace std;
class VanEmdeBoasTree {}; | {
"domain": "codereview.stackexchange",
"id": 1249,
"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++, time-limit-exceeded",
"url": null
} |
java, performance, url, rest, atomic
private static final AtomicReference<Mappings> mappings = new AtomicReference<>();
private static final CountDownLatch hasBeenInitialized = new CountDownLatch(1);
// do I need this extra AtomicReference?
private static final AtomicReference<List<String>> blockListOfHosts = new AtomicReference<List<String>>();
// do I need this extra latch here?
private static final CountDownLatch hasBeenInitializedBlockHostnames = new CountDownLatch(1);
public static Mappings getMappings() {
try {
hasBeenInitialized.await();
return mappings.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
}
} | {
"domain": "codereview.stackexchange",
"id": 7606,
"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, performance, url, rest, atomic",
"url": null
} |
quantum-algorithms, complexity-theory, clifford-group
[Edit: note that the following includes some corrections and improvements on the previous version of the answer. Apologies for the errors.] | {
"domain": "quantumcomputing.stackexchange",
"id": 5347,
"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-algorithms, complexity-theory, clifford-group",
"url": null
} |
python, performance, python-3.x, reinventing-the-wheel, serialization
def represent(obj: Union[dict, frozenset, list, set, tuple], indent: int=4) -> str:
singles = (frozenset, list, set, tuple)
supported = (dict, *singles)
if not isinstance(obj, supported):
raise TypeError('argument `obj` should be an instance of a built-in container data type')
if not isinstance(indent, int):
raise TypeError('argument `indent` should be an `int`')
if indent <= 0:
raise ValueError('argument `indent` should be greater than 0')
if indent % 2:
raise ValueError('argument `indent` should be a multiple of 2')
increment = indent
def worker(obj, indent, add_level=True, not_value=True):
ls = list()
indent_level = ' '*(indent-increment)
open_indent = indent_level * add_level
if not isinstance(obj, supported):
return indent_level * not_value + repr(obj)
enclosures = {
dict: ('{', '}'),
frozenset: ('frozenset({', '})'), | {
"domain": "codereview.stackexchange",
"id": 42248,
"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-3.x, reinventing-the-wheel, serialization",
"url": null
} |
assembly, bacteria
def count_elements(seq):
hist = {}
for i in seq:
hist[i] = hist.get(i, 0) + 1
return hist
def wrapper(func, *args, **kwargs):
def wrapped():
return func(*args, **kwargs)
return wrapped
def main(in_fn, low, high):
"""
Comment below if testing the distribution of fragments
"""
parse_records(in_fn, low, high)
"""
Uncomment to test the distribution of fragments from
running fns on same input 100k times
"""
#wrapped = wrapper(parse_records, in_fn, low, high)
#timeit.timeit(wrapped, number=100000)
#print(count_elements(fragment_lengths))
if __name__ == "__main__":
main(in_fn, low, high) | {
"domain": "bioinformatics.stackexchange",
"id": 1485,
"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": "assembly, bacteria",
"url": null
} |
gazebo
<joint name="frame_joint" type="fixed">
<parent link="base_link"/>
<child link="bottom_frame_link"/>
<origin xyz="0 0 -0.0889"/>
</joint>
<!-- front caster -->
<link name="front_caster_post">
<visual>
<geometry>
<box size="0.0254 0.0254 0.0762"/>
</geometry>
<material name="black"/>
</visual>
<collision>
<geometry>
<box size="0.0254 0.0254 0.0762"/>
</geometry>
</collision>
<inertial>
<mass value="0.453592"/>
<inertia ixx="0.000243866178933" ixy="0.0" ixz="0.0"
iyy="0.000243866178933" iyz="0.0"
izz="4.87732357867e-05"/>
</inertial>
</link> | {
"domain": "robotics.stackexchange",
"id": 36147,
"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
} |
electric-current, electrical-resistance, voltage, si-units, metrology
Are any other electrical units (listed above) affected?
If so, exactly how much will they have changed after the redefinition? Late last century electrical standards based on Josephson junctions became common. A Josephson junction together with an atomic clock can give an exquisitely precise voltage standard in terms of the Josephson constant. Unfortunately, the then-current definition of the volt relied on the definition of the SI kilogram, which introduced substantial uncertainty. So we could provide a very precise voltage standard, but because of the imprecise definition of the volt we were not sure how many volts it was.
Therefore, in 1990 the community came up with the conventional volt, denoted $V_{90}$, based on a fixed value of the Josephson constant, $K_{J-90}$. This conventional unit has served as a more accurate and reproducible standard for voltage since then, however its exact value in terms of SI $V$ was unknown due to the aforementioned lack of precision. | {
"domain": "physics.stackexchange",
"id": 58120,
"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": "electric-current, electrical-resistance, voltage, si-units, metrology",
"url": null
} |
general-relativity, electrostatics, gravity, capacitance, mass-energy
So to be clear, I'm not talking about the gravitational effect FROM the capacitor. The article above makes it clear the charged capacitor would exert more gravitational pull on objects around it. I'm concerned with the charge of the capacitor causing the capacitor to get pulled harder by the gravity of other objects, like earth.
I'm concerned with the charge of the capacitor causing the capacitor to get pulled harder by the gravity of other objects, like earth. | {
"domain": "physics.stackexchange",
"id": 84055,
"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, electrostatics, gravity, capacitance, mass-energy",
"url": null
} |
c++, performance, multithreading, io
Title: Multithreaded O_DIRECT file read-and-process program Here is my code. It reads a file and returns the sum of all the bytes in the file:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <malloc.h>
#include <iostream>
#include <chrono>
#include <thread>
#include <mutex>
#include <condition_variable>
#define BUFSIZE 134217728
// globals
std::mutex mut;
unsigned char* buffers[12]; // global array of pointers to buffers where file will be read
int bytes_read[12] = {0};
std::condition_variable cv;
// write_head is the shared variable associated with cv
int write_head = 0; // index of buffer currently being written to
void producer_thread()
{
int fd;
const char* fname = "1GB.txt";
if ((fd = open(fname, O_RDONLY|O_DIRECT)) < 0) {
printf("%s: cannot open %s\n", fname);
exit(2);
} | {
"domain": "codereview.stackexchange",
"id": 44806,
"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++, performance, multithreading, io",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.