text stringlengths 49 10.4k | source dict |
|---|---|
javascript, jquery
// nested_form - fields removed
$(document).on('nested:fieldRemoved', function(event) {
$('#please_wait').show();
$('#reload_form').val('true');
$('input[type=submit].btn-primary').click()
}); Some general points:
Watch your indentation
Watch your whitespace
An id is unique on a page - there is no benefit to 'element#id' vs '#id' as a selector
It is usually better to store references to elements that don't get removed
Let's apply some of these on the change handler to store the focus field. Here's what we're starting with:
$(document).on('change','.submittable',function(){
if($('input#focus_field').length){
var $focus_field = $(this).attr('id')
$('input#focus_field').val($focus_field)
}
$('input[type=submit]').click();
return false;
});
We don't want to search the DOM for the element every time (unless it can be added/removed) so let's pull it out:
var $focusField = $('#focus_field');
Notice that I've simplified the selector to just the Id. Now we can use our knowledge of jQuery to simplify the next bit of the function.
$(document).on('change', '.submittable', function(e) {
e.preventDefault();
$focusField.val(this.id);
$('input[type=submit]').click();
} | {
"domain": "codereview.stackexchange",
"id": 11450,
"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, jquery",
"url": null
} |
c++, parsing, xml
if (strTagName.substr(0, 1) == "/") {
strTagName.erase(0, 1);
}
m_lsstrChildNodeName.push(strTagName);
posF = strInLine.find_last_of("<");
posL = strInLine.find_last_of(">");
if (strInLine.substr(posF + 1, posL - posF - 1) != "/" + m_lsstrChildNodeName.top()) {
childNode.strAttributeName._Pop_back_n(childNode.strAttributeName.size());
childNode.strAttributeValue._Pop_back_n(childNode.strAttributeValue.size());
sz = strTagName.size();
if (strInLine.substr(1, sz) == strTagName) {
posLt = strInLine.find_first_of("<");
posGt = strInLine.find_first_of(">");
strOpenTag = strInLine.substr(posLt + 1, posGt - posLt - 1);
if (strOpenTag.size() > sz) {
while (strOpenTag.size() > sz) {
getAttributes(strOpenTag, strAttributeName, strAttributeValue);
childNode.strAttributeName.push_back(strAttributeName);
childNode.strAttributeValue.push_back(strAttributeValue);
}
}
posLt = strInLine.find_last_of("<");
posGt = strInLine.find_last_of(">");
strEndTag = strInLine.substr(posLt + 1, posGt - posLt - 1);
if (strEndTag == "/" + strTagName) { | {
"domain": "codereview.stackexchange",
"id": 19018,
"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++, parsing, xml",
"url": null
} |
machine-learning, python, scikit-learn, random-forest, gridsearchcv
Title: Parameters in GridSearchCV in scikit-learn I am trying to build a model in scikit-learn. I used RandomForestClassifier as my method for classification. In order to improve the score and efficiency of my model, I thought about using GridSearchCV.
Here is the code:
import pandas as pd
import numpy as np
from sklearn.cross_validation import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score,roc_auc_score
from sklearn.grid_search import GridSearchCV
..................................... ## code for cleaning data
X_train, X_test, y_train, y_test = train_test_split(train,output, test_size=0.2, random_state =7)
# In[18]:
clf = RandomForestClassifier(n_estimators =100)
param_grid = {'max_depth' : [None, 10,20],
'max_features' : ['auto',None],
'n_estimators' :[100,200,300],
'random_state': 7}
## This line is throwing the error shown below
validator = GridSearchCV(clf, param_grid= param_grid)
vaildiator.fit(X_train,y_train)
The error being thrown by my code is:
ValueError Traceback (most recent call
last)
<ipython-input-22-3711af477b0c> in <module>()
3 "max_depth" : [5,10,50],
4 "random_state" : 7}
----> 5 grid = GridSearchCV(clf, param_grid=param, n_jobs=1)
6 grid.fit(X_train,y_train) | {
"domain": "datascience.stackexchange",
"id": 1046,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, python, scikit-learn, random-forest, gridsearchcv",
"url": null
} |
homework-and-exercises, newtonian-mechanics, forces
For each given value $\delta s$ the vector $\delta\vr:=\vf\,'(s)\cdot
\delta s$ is a tangent vector on the curve at $s$. The tangent
quantities such as $\delta \vr$ and $\delta s$ are often denoted as
virtual in physics. And if physicans talk about small deviations
$\delta s$ they actually mean such tangent quantities.
The force balance in the equilibrium point is
$$
\vec0 = \vF_\rmF + \vF_\rmC
$$
If we multiply this equation by a tangent vector at the location $s$ of the particle we get
$$
0 = \delta\vr\cdot(\vF_\rmF + \vF_\rmC) = \delta\vr\cdot\vF_\rmF + \underbrace{\delta\vr\cdot\vF_\rmC}_{=0}
$$
whereby the second term $\delta\vr\cdot\vF_\rmC$ is zero because the
tangent vector $\delta\vr$ and the constraint force $\vF_\rmC$ are
perpendicular to each other.
So our resulting equilibrium equation is
$$
0=\delta\vr\cdot \vF_\rmF = \delta s \vf\,'(s)\cdot \vF_\rmF.
$$
We are only considering here the case of one degree of freedom $s$
where we can just set $\delta s=1$. (Note by the way, that if we had
more parameters, e.g., $ s=( s_1, s_2)$, we would have to test for all
possible tangent directions, e.g. $\delta s=(1,0)$ and $\delta
s=(0,1)$.)
For $\delta s=1$ our equilibrium equation reads as
$$
0= \vf\,'(s)\cdot \vF_\rmF.
$$
which is one scalar equation which can be solved for the scalar
curve parameter $s$.
As I already mentioned above. The nice thing about our first | {
"domain": "physics.stackexchange",
"id": 12091,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, forces",
"url": null
} |
quantum-mechanics, time, causality, determinism, randomness
Title: Quantum: Is it possible to determine the past knowing the present? Due to quantum randomicity, it's impossible to determine the future knowing the present.
But is it possible to determine the past knowing the present?
As far as I understand, it is impossible because of symmetry of quantum laws regarding time. But I am not sure. Not sure what you mean by quantum randomicity, but I'll give your question a stab.
It's impossible to determine the future knowing the present in the sense that we can't know for certain the result of all possible measurements in the future (the typical example being that we can't know the momentum and position of a particle simultaneously). But in that sense, we also don't know the present!
All the possible information one can have about a system is in the system's wavefunction. If we know this in the present, we will be able to measure observables and know their values (either with certainty, or with some probability). Further, if we know the Hamiltonian of our system, we can also predict what the wavefunction will be in the future. So if we know the present, we can indeed determine the future.
Something interesting is that to know the present, you have to make a measurement. In making this measurement, you collapsed the wavefunction of the system, and actually erased past information! So interestingly enough, if you make a measurement to determine the present state of a system, you can determine its future state but lost most information about its past state.
As a caveat - what I said is from the standpoint of the Copenhagen interpretation of QM. In this interpretation, there is no symmetry in quantum laws regarding time, because a measurement will break this symmetry. [From another perspective, the observer itself is a quantum system, so it can be argued that there is still time symmetry.] | {
"domain": "physics.stackexchange",
"id": 68700,
"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, time, causality, determinism, randomness",
"url": null
} |
electromagnetism, time, notation, differentiation, maxwell-equations
Title: Reason why dot notation isn't used for time derivatives in Maxwell's equations Maxwell's equations seem to be usually written:
\begin{align}
\nabla \cdot \mathbf{E} &= \rho/\epsilon_0,\\
\nabla \cdot \mathbf{B} &= 0,\\
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t},\\
\nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0\epsilon_0\frac{\partial \mathbf{E}}{\partial t},
\end{align}
as opposed to
\begin{align}
\nabla \cdot \mathbf{E} &= \rho/\epsilon_0,\\
\nabla \cdot \mathbf{B} &= 0,\\
\nabla \times \mathbf{E} &= -\dot{\mathbf{B}},\\
\nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0\epsilon_0\dot{\mathbf{E}} \, .
\end{align}
Is there any particular reason the more concise dot notation isn't used? This Newton's notation is not used for partial derivatives. Besides, using the standard notation, helps realising that time and Space differentiation act as a unified 4D operator (exterior derivative) when using exterior form notation | {
"domain": "physics.stackexchange",
"id": 56065,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "electromagnetism, time, notation, differentiation, maxwell-equations",
"url": null
} |
information-theory, error-correcting-codes
Title: Analysis of brute force decoder in a $q$-ary erasure channel Consider the $q$-ary erasure channel with erasure probability $\alpha$, i.e. given $x\in\mathbb{F}_q$ with probability $\alpha$ it outputs $?$ and with probability $1-\alpha$ outputs $x$.
For a linear code $\mathcal{C}$ generated by an $n\times k$ matrix $G$ over $\mathbb{F}_q$, we take a decoder $D:(\mathbb{F}_q\cup\{?\})^n\to\mathcal{C}\cup\{\text{fail}\}$ such that:
$$D(y) = \begin{cases}
c & \text{if}\ \exists!\ c\in\mathcal{C}:y\ \text{agrees with}\ c\ \text{on the unerased entries in}\ \mathbb{F}_q \\
\text{fail} & \text{otherwise} \\
\end{cases}$$
For a set $J\subseteq [n]$ let $p_G(J)$ be the probability that $D$ outputs “fail” conditioned on the erasures being indexed by $J$.
Prove that $\mathop{\mathbb{E}}\limits_{G\in \mathbb{F}_q^{n\times k}}[p_G(J)]\leq q^{k-n+|J|}$.
Let $p_G$ be the probability that $D$ outputs “fail”. Show that when $k = Rn$ for $R<1-\alpha$, $\mathop{\mathbb{E}}\limits_{G\in \mathbb{F}_q^{n\times k}}[p_G]$ is exponentially small in $n$. | {
"domain": "cs.stackexchange",
"id": 10401,
"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": "information-theory, error-correcting-codes",
"url": null
} |
machine-learning, computer-vision, reference-request, statistical-ai
Title: Is there a way of computing a prominence score based on the prevalence of features in an image? Is there any previous work on computing some sort of prominence score based on the prevalence of features in an image?
For example, let's say I am classifying images based on whether or not they have dogs in them. Is there a way to compute how prominent that feature is? Saliency is typically discussed more in object detection or scene understanding than prominence. There are lots of papers on saliency models. "What do different evaluation metrics tell us about saliency models?" is a good paper on various metrics on saliency models. It covers the following metrics:
Similarity or histogram intersection (SIM)
Pearson's Correlation Coefficient (CC)
Normalized Scanpath Saliency (NSS)
Area Under ROC Curve (AUC)
Information Gain (IG)
Kullback-Leibler divergence (KL)
Earth Mover's Distance (EMD)
Some other papers you may find interesting:
Saliency, attention, and visual search: An information
theoretic approach
Towards Instance Segmentation with Object Priority:
Prominent Object Detection and Recognition | {
"domain": "ai.stackexchange",
"id": 422,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "machine-learning, computer-vision, reference-request, statistical-ai",
"url": null
} |
acoustics
Title: What does warming up a gong do? This is almost something I'd cross post with the Music SE, but I specifically am looking for physics answers not music answers.
When playing a gong, one is often told to "warm up" the gong. This involves very lightly tapping the gong with the mallet a few times before striking it. The taps should be relatively inaudible.
Musicians say that doing so makes the sound "brighter," which is a very psychoacoustic term. I'm curious what might physically happen which could then be translated as "brighter" by musicians.
What changes in a gong when you lightly tap it a few times which would change the sound produced? I'd appreciate an answer which could explain any effects in terms of the soundwaves produced by the gong, but I would accept an answer which merely describes a interaction of material properties which could have an effect on the sound waves. Musical instruments generally produce sound waves at a collection of frequencies, even when playing a single note. For instruments which make distinct pitches, these frequencies are roughly multiples of a fundamental frequency, which determines the perceived pitch. The perceived brightness is determined by the strength of higher frequencies, in the kHz range. A percussive instrument like the gong obeys the same principles, except that generally there are a whole lot more frequencies present.
If the behavior of a percussive instrument is well-described by linear differential equations, you would expect all of the frequencies to act independently. Their strength would be determined by the initial strike, and then they would each exponentially decay, perhaps at different rates. This is a good description for, e.g. pianos, but not for the gong. According to Fletcher and Rossing's exhaustive work The Physics of Musical Instruments:
When we seek a physical origin for the extreme nonlinearity of the tam-tam [the Chinese gong], we find this first in the fact that its metal is thin and not under significant tension. This means that the stiffness and tension restoring forces are very small, so that the quadratic tension generated by mode displacements ·has a large effect. Another source of mode coupling and nonlinearity arises from the hammered bumps in the surface, since abrupt changes in slope are known to generate mode coupling and nonlinear frequency multiplication. | {
"domain": "physics.stackexchange",
"id": 57889,
"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": "acoustics",
"url": null
} |
java, console, compression
byte[] byteArray = new byte[numberOfBytes];
for (int i = 0; i != numberOfBytes; ++i) {
byteArray[i] =
(byte)
((storageLongs[i / Long.BYTES]
>>> Byte.SIZE * (i % Long.BYTES)) & 0xff);
}
return byteArray;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(size);
for (int i = 0; i != size; ++i) {
sb.append(readBitImpl(i) ? '1': '0');
}
return sb.toString();
}
private void checkAccessIndex(int index) {
if (size == 0) {
throw new IllegalStateException("The bit string is empty.");
}
if (index < 0) {
throw new IndexOutOfBoundsException(
"The index is negative: " + index + ".");
}
if (index >= size) {
throw new IndexOutOfBoundsException(
"The bit index is too large (" + index + "). Must be at most " +
(size - 1) + ".");
}
}
private boolean readBitImpl(int index) {
int longIndex = index / BITS_PER_LONG;
int bitIndex = index & MODULO_MASK;
long mask = 1L << bitIndex;
return (storageLongs[longIndex] & mask) != 0;
}
private void writeBitImpl(int index, boolean bit) {
int longIndex = index / BITS_PER_LONG;
int bitIndex = index & MODULO_MASK;
if (bit) {
long mask = 1L << bitIndex;
storageLongs[longIndex] |= mask;
} else {
long mask = ~(1L << bitIndex);
storageLongs[longIndex] &= mask;
}
} | {
"domain": "codereview.stackexchange",
"id": 23126,
"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, console, compression",
"url": null
} |
# Theoretical Issues with Bases of Kernels:$\mathcal{B}$-matrix of the transformation $T$ with respect to the standard basis of $\mathbb{R}^{2\times2}$?
Consider the linear transformation $T(M): \begin{bmatrix} 0&1\\0&0\end{bmatrix}M-M\begin{bmatrix} 0&1\\0&0\end{bmatrix}$ from $\mathbb{R}^{2\times2}$ to $\mathbb{R}^{2\times2}$.
a) What is the $\mathcal{B}$-matrix of the transformation $T$ with respect to the standard basis of $\mathbb{R}^{2\times2}$?
This part is easy for me, as we've been doing this over and over again at this part during the course. If $\big[[M]_{\mathcal{B}}\big]=\begin{pmatrix}a\\b\\c\\d\end{pmatrix}$, then $\big[[T(M)]_{\mathcal{B}}\big]=\begin{pmatrix}c\\d-a\\0\\c\end{pmatrix}$ such that $B=\begin{bmatrix}0&0&1&0\\-1&0&0&1\\0&0&0&0\\0&0&-1&0\end{bmatrix}$
b) Find bases of the image and kernel of $B$. This is the difficult part for me, despite having done this on its own a couple of times before. My first impulse was to put $B$ into row-reduced echelon form: $$rref(B)=\begin{bmatrix}1&0&0&-1\\0&0&1&0\\0&0&0&0\\0&0&0&0\end{bmatrix}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9796676436891864,
"lm_q1q2_score": 0.8163811386623531,
"lm_q2_score": 0.8333245911726382,
"openwebmath_perplexity": 146.06877035687057,
"openwebmath_score": 0.8689419627189636,
"tags": null,
"url": "https://math.stackexchange.com/questions/1203704/theoretical-issues-with-bases-of-kernels-mathcalb-matrix-of-the-transformat"
} |
astrophysics, nuclear-physics
$$ e^{-\sqrt{E_G/E}}\rightarrow 1,$$ and the integrated cross section blows up, as expected. So issue is that your approximate formula is only valid for $k_BT \ll E_G$. | {
"domain": "physics.stackexchange",
"id": 21944,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "astrophysics, nuclear-physics",
"url": null
} |
logic, boolean-algebra, boolean-complexity
Title: Is $f(X)f^d(X) = 0$ for a Boolean function $f$? I'm currently trying to understand a step in the proof for in the Crama and Hammer book on Boolean Functions. The proof is Proposition 4.12, which claims that the self-dualization of Boolean $f$ is bijective.
The specific statement that I am confused about is a step showing that:
$$f^d(X)f(X) \lor f(X) \bar{x}_{n+1} \lor f^d(X) {x}_{n+1} = f(X) \bar{x}_{n+1} \lor f^d(X) {x}_{n+1}.$$
Here $f(X)$ is a d-dimensional Boolean function, $X = (x_1,x_2,\ldots, x_n) \in \mathcal{B}^n$, and $f^d(X) := \overline{f(\overline{X})}$ is the dual of $f$.
This equality above seems to require that $f^d(X)f(X) = 0.$ I am wondering why this is? I think that I am missing something simple, or maybe I've found a typo in the proof. If someone has a different proof for the broader claim that self-dualization is bijective, that would be fine.
I've copied the full proposition below in case it helps: | {
"domain": "cs.stackexchange",
"id": 19719,
"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": "logic, boolean-algebra, boolean-complexity",
"url": null
} |
c#, mysql
SqlCommand.Parameters.AddRange(Params);
}
return SqlCommand;
}
public async Task<MySqlDataReader> SelectAsync(string Sql, params object[] Args)
{
try
{
using (MySqlCommand Command = CreateSqlCommand(CreateConnection(), Sql, Args))
return await Command.ExecuteReaderAsync();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return null;
}
}
Coding style
If an if, using, while or for statement is followed by a single action, then scoping ({ and }) is not needed.
Commenting is useful, when not overused. Personally, I dislike commenting everything, it makes my code messy and difficult to work with. If you name your variables after their purpose (as you did), comments are not that necessary, since the code speaks for itself. | {
"domain": "codereview.stackexchange",
"id": 24768,
"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#, mysql",
"url": null
} |
primes, clojure, factors
Title: Naïve Prime Factorization in Clojure Pt. 2 After my last review request, I decided to try and make a "tree" visualization, and thought that I could benefit from making find-prime-factors lazily produce prime factors so the visualization can be updated in real time as factors are found.
This is what I ended up with. I was actually surprised how easy it was to adapt the loop to a recursive lazy-seq solution. The non-return accumulators were added as parameters to a recursive function, and the lazy return list was created via the typical (lazy-seq (cons ... ...)). It actually performs identically to the previous strict version too when evaluation is forced using vec.
If anyone sees anything here that can be commented on, I'd like to know.
(doseq [p (lazily-find-prime-factors 99930610001)]
(println p
(int (/ (System/currentTimeMillis) 1000))))
163 1544998649
191 1544998692
3209797 1544998692
Same as in the last review:
(ns irrelevant.prime-factorization.prime-factorization)
(defn is-factor-of? [n multiple]
(zero? (rem n multiple)))
(defn prime? [n]
(or (= n 2) ; TODO: Eww
(->> (range 2 (inc (Math/sqrt ^double n)))
(some #(is-factor-of? n %))
(not))))
(defn primes []
(->> (range)
(drop 2) ; Lower bound of 2 for the range
(filter prime?)))
(defn smallest-factor-of? [n possible-multiples]
(some #(when (is-factor-of? n %) %)
possible-multiples)) | {
"domain": "codereview.stackexchange",
"id": 34798,
"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": "primes, clojure, factors",
"url": null
} |
c, virtual-machine
static const int MEM_MAX = 9999;
static const int MEM_MIN = -9999;
static const int INSTRUCTIONSIZE = 4;
enum warning { WARN_NONE, WARN_HALT, WARN_INPUT, WARN_OVERFLOW, WARN_DIVZERO, WARN_SIGNEDOVERFLOW, WARN_REMAINZERO, WARN_COUNT };
static const struct Error {
enum warning value;
const char *text;
} simpletron_errors[WARN_COUNT] = {
{ WARN_NONE, "ok" },
{ WARN_HALT, "halt" },
{ WARN_INPUT, "improper input" },
{ WARN_OVERFLOW, "integer overflow" },
{ WARN_DIVZERO, "division by zero" },
{ WARN_SIGNEDOVERFLOW, "signed integer overflow"},
{ WARN_REMAINZERO, "remainder by zero"},
};
static bool isOutOfRange(int n) {
return n < MEM_MIN || n > MEM_MAX;
}
/* get instruction from fp; return 0 if instruction is improper */
static int fetch_number(FILE *fp, int *instruction) {
int num = 0;
int c;
int sign = 1;
/* get initial blank */
while (isblank(c = getc(fp)))
;
/* get instruction/data sign */
switch (c) {
case '-':
sign = -1;
// fall through
case '+':
c = getc(fp);
break;
default: // error condition
return 0;
}
/* get instruction/data number */
for (int i = INSTRUCTIONSIZE; i; --i) {
if (!isdigit(c)) { // error
return 0;
}
num = num * 10 + c - '0';
c = getc(fp);
}
/* get remaining of command line */
while (c != '\n' && c != EOF) {
c = getc(fp);
}
*instruction = sign * num;
return 1;
} | {
"domain": "codereview.stackexchange",
"id": 37734,
"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, virtual-machine",
"url": null
} |
javascript, library
If you are going to have f -> false and t -> true, then you might as well point to them true and false instead of !0 and !t
Variables like nl for null are unfortunate, it reduces the quality of your code
Your prototype each should probably be forEach and only be set if forEach is not already there ( it is there for more most browsers )
You should use lowerCamelCase: isarray -> isArray etc.
You are overdoing the newlines:
function rig_props( obj, props ) {
if (
isobj( obj )
&& isplainobj( props )
) {
each(
props,
function ( p, v ) {
obj[p] = v;
}
)
}
return obj;
}
should be
function rigPropertiess( o, properties ) {
if ( isObject( o ) && isPlainObject( properties ){
each( properties, function ( key, value ) {
o[key] = value;
});
}
return o;
}
vacate_obj worries me, why would you need this compare to just assigning a new object ?
extend has a severe case of arrow pattern coding:
} else {
hostObj[prop] = this[prop];
}
} else {
hostObj[prop] = this[prop];
}
} else {
hostObj[prop] = this[prop];
}
} else {
hostObj[prop] = this[prop];
}
}
);
return hostObj;
}
I am sure that with some deep thoughts you can do this better
Again, I think you are re-inventing the wheel, unless I am missing something. | {
"domain": "codereview.stackexchange",
"id": 7063,
"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, library",
"url": null
} |
javascript
Title: JavaScript handler to seek to one of several locations How would I simplify the following function to reduce repetitive code? I would like to define "arg" as an array since that is the only changing aspect of each case.
function jumpMovement(iMovement) {
switch (iMovement) {
case 0:
document.getElementById('opus-08a').contentWindow.postMessage('{"method": "seekSeconds", "arg":"0.0"}', 'https://musescore.com');
break;
case 1:
document.getElementById('opus-08a').contentWindow.postMessage('{"method": "seekSeconds", "arg":"99.45"}', 'https://musescore.com');
break;
case 2:
document.getElementById('opus-08a').contentWindow.postMessage('{"method": "seekSeconds", "arg":"201.45"}', 'https://musescore.com');
break;
case 3:
document.getElementById('opus-08a').contentWindow.postMessage('{"method": "seekSeconds", "arg":"319.49"}', 'https://musescore.com');
break;
default:
document.getElementById('opus-08a').contentWindow.postMessage('{"method": "seekSeconds", "arg":"0.0"}', 'https://musescore.com');
}
}
Sample of use in html:
<button onclick="jumpFigure(0)">0</button>
<button onclick="jumpFigure(1)">1</button>
<button onclick="jumpFigure(2)">2</button> | {
"domain": "codereview.stackexchange",
"id": 43593,
"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
} |
quantum-mechanics, angular-momentum, group-theory, representation-theory, rotation
\hskip2cm
i\,J_y U = U\tilde J_y
\hskip2cm
i\,J_z U = U\tilde J_z,
$$
which proves that the two representations are equivalent except for the overall factor of $i$.
These identities could be written in the form $i\,J=U\tilde J U^{-1}$ instead, but they way I wrote them above makes them easier to check. | {
"domain": "physics.stackexchange",
"id": 53007,
"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, angular-momentum, group-theory, representation-theory, rotation",
"url": null
} |
ros, localization
# pose1_rejection_threshold: 3
# Since AMCL is more likely to fail than the beacons, you might want to treat the beacons
# as a primary source, and set pose1_differential: true
# In that case, set x', y' and yaw' to true, and the rest to false!
# pose1: /fiducial_pose # AMCL!
# pose1_config: [true, true, false,
# false, false, true,
# false, false, false,
# false, false, false,
# false, false, false]
# pose1_rejection_threshold: 2
# poseN_rejection_threshold: (YOU MIGHT WANT THIS. If it's above the stated threshold value, the EKF will ignore the reading) (Defaults to numeric_limits<double>::max())
# [ADVANCED] The process noise covariance matrix can be difficult to tune, and can vary for each application, so it is exposed as a configuration parameter. This matrix represents the noise we add to the total error after each prediction step.
# The better the omnidirectional motion model matches your system, the smaller these values can be. However, if users find that a given variable is slow to converge, one approach is to increase the process_noise_covariance diagonal value for the variable in question, which will cause the filter's predicted error to be larger, which will cause the filter to trust the incoming measurement more during correction.
# The values are ordered as x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az.
# Defaults to the matrix below if unspecified. | {
"domain": "robotics.stackexchange",
"id": 2487,
"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, localization",
"url": null
} |
arduino, rosserial
Title: Can I determine the topic which executed a callback in rosserial?
I have a few PWM input/output pairs connected to my Arduino Nano and defined in an array.
typedef struct {
char *name;
byte pin_in;
byte pin_out;
unsigned long rise_time;
unsigned long fall_time;
byte value_in;
byte value_out;
byte state;
} control_t;
control_t controls[]={
{ .name="throttle", .pin_in=3, .pin_out=11, },
{ .name="steering", .pin_in=4, .pin_out=10, },
{ .name="transmission", .pin_in=5, .pin_out=9, },
{ .name=NULL}
};
I want to create a subscriber and publisher for each one so that the input value (from the physical control) is published and the output value (sent to the robot) can be subscribed. I tried using classes but discovered that rosserial doesn't support using class methods for callbacks. So I thought I could have one subscriber callback for all of the controls. It just needs to know the topic used so that it can do a lookup on the control name and set the PWM output of the corresponding pin. For example, publishing 123 to /myrobot/steering/set(?) should put the value 123 on pin 10. (I also welcome help with topic names.)
Is it possible to get the topic name (or ID?) inside the callback? Or is there a better way to handle this?
Thank you.
--kyler
[updates to keep them all together...]
There is good info here on how classes are implemented in C++: http://stackoverflow.com/questions/400257/how-can-i-pass-a-class-member-function-as-a-callback
boost::bind and boost::function (from #1) appear to do what I want.
There is a (partial) Boost library for Arduino: https://github.com/vancegroup/arduino-boost | {
"domain": "robotics.stackexchange",
"id": 25890,
"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": "arduino, rosserial",
"url": null
} |
• We'll call the $$i,j$$ element of this matrix $$w_{ij}^{(k)}$$.
• $$\mathbf{M}_R$$ (the matrix of the relation) is the matrix of edges in the relation
• It is the elements you can get between using no interior vertices.
• That is, $$\mathbf{M}_R=\mathbf{W}_0$$.
• If we can find $$\mathbf{W}_n$$, it is the transitive closure.
• It gives the nodes we can get between using any combination of interior vertices.
• From the above, $$w_{ij}^{(k)}$$ is one if either:
• $$w_{ij}^{(k-1)}$$ is one, or
• $$w_{ik}^{(k-1)} \wedge w_{j,k}^{(k-1)}$$ is one.
• Now, it's easy enough to find $$\mathbf{W}_n$$. This is the Warshall Algorithm to find the transitive closure:
procedure warshall(R):
W = R
for k from 1 to n
for i from 1 to n
for j from 1 to n
w[i,j] = w[i,j] ∨ (w[i,k] ∧ w[k,j])
return W
• At the end of each iteration of the “for k”, W is $$\mathbf{W}_k$$
• [Actually, it might be somewhere between $$\mathbf{W}_k$$ and $$\mathbf{W}_{k+1}$$ since we might overwrite other zeros with ones as we process the matrix.]
• The running time here is pretty obvious: $$\Theta(n^3)$$.
• Our naïve algorithm above was $$\Theta(n^4)$$.
• A pretty good improvement. | {
"domain": "sfu.ca",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9907319866190857,
"lm_q1q2_score": 0.8277402665312226,
"lm_q2_score": 0.8354835391516133,
"openwebmath_perplexity": 181.25572208846404,
"openwebmath_score": 0.9748877882957458,
"tags": null,
"url": "http://www.cs.sfu.ca/~ggbaker/zju/math/closures.html"
} |
ros, roslisp
Originally posted by toddcpierce on ROS Answers with karma: 51 on 2016-09-02
Post score: 0
Original comments
Comment by gvdhoorn on 2016-09-03:\
These guys on the Web
'these guys'?
Comment by gvdhoorn on 2016-09-03:
Looking at the responses to other Lisp related questions, I have the feeling that the ROSLisp community isn't very large (any more). It might take some time before you get a reply.
It would be very nice if you could report back on any solution/work-around you find. That would help immensely.
Comment by gaya on 2016-09-07:
Could you please point at the particular part of the roslisp tutorial from the ROS wiki page when this error happens? I suspect that you are not following the tutorial.
The problem that you encountered is a minor issue, I doubt greatly that it is connected to an SBCL bug.
Comment by toddcpierce on 2016-09-07:
I did another pull of the add-two-ints tutorial and it worked. By the way, I was not implying that there was a bug in SBCL. It´s just that I´m really putting the configuration of Lisp through a lot while doing other experiments. You saved me again. How do I close this?
Comment by gvdhoorn on 2016-09-07:
You could accept the answer by @gaya by ticking the checkmark to the left of the answer. That would mark the question as answered.
Comment by gvdhoorn on 2016-09-07:
We don't typically close questions here on ROS Answers. Marking the question as answered is much more visible from the question list.
I committed a fix to the tutorial. Do a git pull and try again.
I strongly recommend, though, that you follow the text in the tutorials on the ROS wiki page, e.g. here:
http://wiki.ros.org/roslisp/Tutorials/OverviewVersion#Calling_a_service_interactively
The text in those tutorials will help a lot to figure out what is going on in the tutorial code.
Originally posted by gaya with karma: 311 on 2016-09-07
This answer was ACCEPTED on the original site
Post score: 1 | {
"domain": "robotics.stackexchange",
"id": 25662,
"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, roslisp",
"url": null
} |
audio, frequency-spectrum, reference-request, music
Title: Shazam / SoundHound Music Analysis - Recommendation for Reading I need to explore some area around music frequency analysis.
A good example is the way Shazam / SoundHound app works (mapping frequency domain, comparing, creating some vector map, handling noises and errors).
I am looking for a while for a practical book or articles about this. By practical i mean with a simple language/code examples, etc.
No Sigmas, and integrals for infinity that takes you back to university.
It's really hard to find any music/audio analysis practical material. The basic idea is called - Music Finger Printing.
Searching for it will yield many results.
I'm attaching few good ones I found:
How Does Shazam Work?
How Does Shazam Work? Music Recognition Algorithms, Fingerprinting and Processing.
Creating Your Own Shazam (Identify Songs) with Python Through Audio Fingerprinting (The YouTube Video).
Audio Fingerprinting with Python and Numpy.
Fingerprint Audio Files & Identify What's Playing.
Playing with Shazam Fingerprints.
Reading all those won't teach the exact rigorous Math, but it will give you intuition and tools to start with. | {
"domain": "dsp.stackexchange",
"id": 8209,
"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": "audio, frequency-spectrum, reference-request, music",
"url": null
} |
differential-geometry, coordinate-systems, differentiation, rotation
So far so good. But now consider the gradient of a scalar field $\phi$. I get, by the chain rule (and with implicit summation over repeated indices),
$$(\nabla \phi)'_i = \frac{\partial \phi}{\partial x'^i} = \frac{\partial \phi}{\partial x^j} \frac{\partial x^j}{\partial x'^i} = (\nabla \phi)_j(R_\theta)_{ji} = (\nabla \phi)_j(R^{-1}_\theta)_{ij} = (R^{-1}_\theta \nabla \phi)_i, \tag{4} $$
so that $(\nabla \phi)' = R^{-1}_\theta \nabla \phi = R_{-\theta} \nabla \phi$, indicating that the components of the gradient transform like the position vectors! But this cannot be right, since one is supposed to transform covariantly and the other contravariantly. To provide a secondary view which may be more accessible, I have elected to write a second answer.
Let $\mathbf V$ be a vector. Given some choice of basis $\{\hat e_1,\hat e_2\}$, we can expand $\mathbf V$ in component form as
$$\mathbf V = \sum_i V^i \hat e_i = V^1 \hat e_1 + V^2 \hat e_2$$ | {
"domain": "physics.stackexchange",
"id": 77467,
"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": "differential-geometry, coordinate-systems, differentiation, rotation",
"url": null
} |
ros, ros-hydro, setup.bash
Originally posted by Rasmus with karma: 58 on 2013-09-30
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by l_a_den on 2014-05-14:
Can you tell me how you solve the problem? Because I encounter the same problem.
Comment by Juan on 2015-01-03:
This is due to some syntax error in your package.xml. For me, I accidentaly hit enter in one line and broke a commented line into an uncommented one with syntax errors. After fixing this, I could run roscore again. | {
"domain": "robotics.stackexchange",
"id": 15712,
"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-hydro, setup.bash",
"url": null
} |
quantum-mechanics, homework-and-exercises, operators, quantum-spin
I have absolutely no idea of how to do this. I don't even understand quite well the expression of $|\phi\rangle$ itself. How could this be done?
EDIT: Thanks to Asaf's answer I've been able to understand the subject better. For simplicity, I'll write just $|+\rangle$ instead of $|+\rangle_z$ and $|-\rangle$ instead of $|-\rangle_z$. So I did the following:
$$\langle\phi|\hat{S}_x|\phi\rangle=\left(\frac{1}{\sqrt2}\langle+|-\frac{1}{\sqrt2}\langle-|\right)\left(\frac{1}{\sqrt2}\hat{S}_x|+\rangle-\frac{1}{\sqrt2}\hat{S}_x|-\rangle\right)
=\left(\frac{1}{\sqrt2}\langle+|-\frac{1}{\sqrt2}\langle-|\right)
\left(\frac{1}{\sqrt2}\frac{\hbar}{2}|-\rangle-\frac{1}{\sqrt2}\frac{\hbar}{2}|+\rangle\right)
=\frac12\frac{\hbar}{2}\langle+|-\rangle-\frac12\frac{\hbar}{2}\langle+|+\rangle-\frac12\frac{\hbar}{2}\langle-|-\rangle+\frac12\frac{\hbar}{2}\langle-|+\rangle=-\frac12\frac{\hbar}{2}-\frac12\frac{\hbar}{2}=-\frac{\hbar}{2}$$ | {
"domain": "physics.stackexchange",
"id": 30398,
"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, operators, quantum-spin",
"url": null
} |
c#, strings, .net, validation, type-safety
protected StringWhitelistN_() { }
public StringWhitelistN_(string str) : base(str) { }
}
public abstract class StringWhitelistNN
: StringWhitelist
{
protected abstract int MinLength { get; }
protected abstract int MaxLength { get; }
protected override string RegexValidation => $"^[{StringWhitelist.CreateWhitelist(Whitelist)}]{{{MinLength},{MaxLength}}}$";
protected override string ErrorRequirement => $"be between {MinLength} and {MaxLength} characters and {base.ErrorRequirement}";
protected StringWhitelistNN() { }
public StringWhitelistNN(string str) : base(str) { }
}
Another note: when using Newtonsoft.Json.JsonConvert or System.Xml.Serialization.XmlSerializer, this serializes directly to/from the raw node, this doesn't serialize the class, but strictly the string:
var xmlSer = new XmlSerializer(test.GetType());
byte[] buffer;
using (var ms = new System.IO.MemoryStream())
{
xmlSer.Serialize(ms, test);
buffer = ms.GetBuffer();
}
Console.WriteLine(new UTF8Encoding(false).GetString(buffer));
using (var ms = new System.IO.MemoryStream(buffer))
{
var result = (Test)xmlSer.Deserialize(ms);
Console.WriteLine(result.Email);
}
var jsonResult = JsonConvert.SerializeObject(test);
Console.WriteLine(jsonResult);
Console.WriteLine(JsonConvert.DeserializeObject<Test>(jsonResult).Email);
Result: | {
"domain": "codereview.stackexchange",
"id": 32676,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "c#, strings, .net, validation, type-safety",
"url": null
} |
• just to be clear, "i followed by i+1" means that $\sigma(i)+1$ is never equal to $sigma(i+1)$, for all $i\leq n-1$ ? – Denis Jul 25 '13 at 0:52
• I'm sorry if my statement of the problem wasn't completely clear, but that's what I meant. (In other words, when you arrange the images of 1,..., n in order, i is never followed by i+1.) – user84413 Jul 26 '13 at 2:10
• It seems that your question has been asked and answered previously. I do have some doubt about Brian Scott's answer, and I've left a comment there requesting clarification, but it may just be a simple misunderstanding on my part. – Will Orrick Sep 10 '13 at 2:42
• @ Will Orrick Thank you for pointing out that my question had been asked previously. I read the answer posted, but I wasn't able to see how to make it work. (For example, it seemed to me that the permutations 1324 and 4132 would both map to the permutation 2314, if I am interpreting the answer correctly.) I like your argument to show that the number of elements of $T_n$ that fix n is equal to $D_{n-1}$, even though it isn't what I originally had in mind. Can you use the same idea to show that the number of elements in $T_n$ which do not fix n is equal to $D_n$? Thanks again. – user84413 Sep 10 '13 at 17:45
• It turns out Persi Diaconis, Steven Evans, and Ron Graham have a recent paper exploring this problem in some depth. (arxiv.org/abs/1308.5459 ) – Kevin P. Costello Oct 14 '13 at 23:53
(Note: this answer does not contain a bijection between the two sets, which is what the OP was originally hoping for, but it does show that the two counting problems are structurally equivalent and therefore have the same answer.) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9840936064221572,
"lm_q1q2_score": 0.8496581562953932,
"lm_q2_score": 0.863391602943619,
"openwebmath_perplexity": 160.4422754281705,
"openwebmath_score": 0.9476654529571533,
"tags": null,
"url": "https://math.stackexchange.com/questions/451212/showing-that-q-n-d-nd-n-1"
} |
differential-geometry, field-theory, gauge-theory, lie-algebra, yang-mills
In other words, your "definition" of the covariant derivative is actually only valid for this subset. Now, a connection $1$-form is in general not an element of $\Omega^{1}_{\mathrm{hor}}(P,\mathfrak{g})^{\mathrm{Ad}}$! (*)
To sum up, you cannot use your formula for a connection $1$-form. However, you can actually easily show that
$$D_{A}A\stackrel{!}{=}F^{A}=\mathrm{d}A+\frac{1}{2}[A\wedge A],$$
which then also leads to the correct coordinate expression as explained above.
* However, the curvature is an element of $\Omega^{2}_{\mathrm{hor}}(P,\mathfrak{g})^{\mathrm{Ad}}$ and also the difference of two connection $1$-forms is an element of $\Omega^{1}_{\mathrm{hor}}(P,\mathfrak{g})^{\mathrm{Ad}}$. The latter statement implies that the set of connection $1$-forms $\mathcal{C}(P)$ of a principal bundle is an infinite-dimensional affine space with vector space $\Omega^{1}_{\mathrm{hor}}(P,\mathfrak{g})^{\mathrm{Ad}}$. | {
"domain": "physics.stackexchange",
"id": 87095,
"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": "differential-geometry, field-theory, gauge-theory, lie-algebra, yang-mills",
"url": null
} |
c#, random, shuffle
EDIT
After having read everything and considered what you are trying to accomplish I believe that you are getting what are trying to accomplish. That being it looks like you are trying to shuffle a deck of 52 cards. Also with the answer you provided this gives me a little more clue as to what to try to tell you for a better review other than just spitting out the output. So here are my suggestions:
Unit Testing
All programs that are going to be used for "production" (even if production means you are playing your own game) should have some tests in place that exercise your code. Testing randomness isn't always easy but you already thought of 3 tests that you could have written outside of your win forms application.
for (byte i = 0; i < 52; i++)
{
if (hsDeck.Contains(deck[i]))
Debug.WriteLine("Houston we have a problem");
if (deck[i] < 0)
Debug.WriteLine("Houston we have a problem");
if (deck[i] > 51)
Debug.WriteLine("Houston we have a problem");
hsDeck.Add(deck[i]);
}
This information would have been better served in your question. But the test is simple and is simple to reproduce using MSTest, NUnit, or xUnit. The latter two being among the more popular but MSTest is built into Visual Studio. I see that you put Debug.WriteLine in your "test" so that you can watch the debug screen. Well how about instead of reading the debug screen you watch the test runner screen for a green check or red x for a pass or fail? You could even copy and paste your code but you'd run into an immediate hicup. You have testable code inside a non-testable class. Solution: extract that method into its own very small class.
public class FisherYates
{
private static readonly Random rand = new Random();
public static byte[] Shuffle(byte count)
{
//removed for brevity
return deck;
}
} | {
"domain": "codereview.stackexchange",
"id": 21238,
"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#, random, shuffle",
"url": null
} |
quantum-state, textbook-and-exercises
Title: What is a basis (not necessarily orthogonal) of Herm(A) consisting of pure density matrices in D(A)?($A \cong \mathbb{C}^{n}$) Let $A \cong \mathbb{C}^{n}$ be a Hilbert space $A,$ and let $\operatorname{Herm}(A)$ be the Hilbert space consisting of all Hermitian matrices on $A$. Give an example of a basis (not necessarily orthogonal) of Herm (A) consisting of pure density matrices in $\mathfrak{D}(A)$.
$\mathbf A\mathbf t\mathbf t\mathbf e\mathbf m\mathbf p\mathbf t$:
I Started with the case $n=2$ and considered the vectors $|0\rangle,|1\rangle,|+\rangle$ and $|+i\rangle$ , Because I think $\left|0\right\rangle\left\langle 0\right|$, $\left|1\right\rangle\left\langle 1\right|$, $\left|+\right\rangle\left\langle +\right|$, and $\left|+i\right\rangle\left\langle +i\right|$ are a non-orthogonal basis and all of them are pure density matrices. And as you know,
$|+\rangle=\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)$
$|+i\rangle=\frac{1}{\sqrt{2}}(|0\rangle+i|1\rangle)$. | {
"domain": "quantumcomputing.stackexchange",
"id": 1997,
"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-state, textbook-and-exercises",
"url": null
} |
java, beginner, swing, calculator, gui
GridBagConstraints gbc = new GridBagConstraints();
numDisplay = new JTextField();
numDisplay.setPreferredSize(new Dimension(130, 30));
numDisplay.setEditable(false);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.gridwidth = 3;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(numDisplay, gbc);
zero = new JButton("0");
gbc.gridx = 1;
gbc.gridy = 5;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(zero, gbc);
one = new JButton("1");
gbc.gridx = 1;
gbc.gridy = 2;
gbc.gridwidth = 1;
add(one, gbc);
two = new JButton("2");
gbc.gridx = 2;
gbc.gridy = 2;
add(two, gbc);
three = new JButton("3");
gbc.gridx = 3;
gbc.gridy = 2;
add(three, gbc);
four = new JButton("4");
gbc.gridx = 1;
gbc.gridy = 3;
add(four, gbc);
five = new JButton("5");
gbc.gridx = 2;
gbc.gridy = 3;
add(five, gbc);
six = new JButton("6");
gbc.gridx = 3;
gbc.gridy = 3;
add(six, gbc);
seven = new JButton("7");
gbc.gridx = 1;
gbc.gridy = 4;
add(seven, gbc);
eight = new JButton("8");
gbc.gridx = 2;
gbc.gridy = 4;
add(eight, gbc); | {
"domain": "codereview.stackexchange",
"id": 14770,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "java, beginner, swing, calculator, gui",
"url": null
} |
c++, performance, c++17, queue
typename Idxtype = std::size_t /*Integral type to store indices. May change,
like to uint_least16_t, to lower space usage*/,
typename = typename std::enable_if<std::is_integral<Idxtype>::value>::type> | {
"domain": "codereview.stackexchange",
"id": 38590,
"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, c++17, queue",
"url": null
} |
fourier-transform
This very last statement is what I am not sure about. If the Fourier transform of $f$ is band-limited, then outside of a closed interval, the transformed function will be $0$, and so I am not sure for which frequency components the convolution of the transforms will have infinite frequency. Any insights appreciated. Note that in order to obtain the Fourier transform of the windowed time domain signal $f(t)h(t)$, you need to convolve the Fourier transforms of $f(t)$ and $h(t)$. We know that the Fourier transform of $f(t)$ is zero outside some interval (because $f(t)$ is band-limited). However, since $h(t)$ is time-limited, i.e., it is zero outside some time interval, we know that its Fourier transform cannot be band-limited. For this specific example of a rectangular window $h(t)$, we know that the corresponding Fourier transform is a sinc function. Convolving any function with a sinc function results in a function that extends from $-\infty$ to $+\infty$. Consequently, the Fourier transform of the windowed signal $f(t)h(t)$ also extends from $-\infty$ to $+\infty$. Consequently, the signal $f(t)h(t)$ cannot be band-limited.
In sum, a band-limited signal cannot be time-limited, and a time-limited signal cannot be band-limited. Note, however, that you cannot conclude that a signal is band-limited if it is not time-limited and vice versa. There are signal that are neither time-limited nor band-limited. | {
"domain": "dsp.stackexchange",
"id": 8840,
"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": "fourier-transform",
"url": null
} |
python, beginner, object-oriented, linked-list, homework
Title: Python code that sorts books I am currently a student just starting to learn python and I need help improving my code for a school assignment. I've already written the code for the program, just need suggestions on how to improve it or make it better.
Uncle Joe started the Greenville Secondhand Bookstore in 2000. As
years passed, the number of books in his store increased
significantly. He can no longer keep track of their location in his
store. Knowing you are from School of informatics & IT, he has
approached you to develop a program (in Python) that could help him to
keep track of the books.
Your program should fulfil the following requirement:
a. AddBookToFront(newBook) : This method will create a new Node
with the new Book object as its data value and then add the newly
created node to the front of the linked list.
b. AddBookAtPosition(newBook, n) : This method will create a new
Node with the new Book object as its data value and then add the
newly created node at position n of the linked list. Assume that the
first node of the linked list has a position number of 0 and the
second node has a position number of 1 and so on.
c. RemoveBookAtPosition(n): This method will remove the node at
position n in the linked list. Assume that the first node of the
linked list has a position number of 0 and the second node has a
position number of 1 and so on.
d. DisplayBook(): This method will traverse the linked list from
its first node to its last node and print the data value (i.e., the
id, bookName and authorName of the Book object) of each node.
e. SortByAuthorName(): This method will sort the linked list by
the book author’s name in ascending order.
Notes:
You are allowed to make changes to the LinkedList and Node classes as you deemed fit.
You are not allowed to use List for this question.
You are not allowed to use any existing Python libraries to do sorting.
Your solution should use objects and classes effectively. | {
"domain": "codereview.stackexchange",
"id": 29117,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "python, beginner, object-oriented, linked-list, homework",
"url": null
} |
homework-and-exercises, newtonian-mechanics, oscillators, coupled-oscillators
sol = NDSolve[{30 x''[t] + y''[t] Cos[y[t]] + z''[t] Cos[z[t]] -
y'[t]^2 Sin[y[t]] - z'[t]^2 Sin[z[t]] + 30 x[t] + 2 x'[t] == 0,
y''[t] + x''[t] Cos[y[t]] + Sin[y[t]] - x'[t] y'[t] Sin[y[t]] +
0.02 y'[t] == 0,
z''[t] + x''[t] Cos[z[t]] + Sin[z[t]] - x'[t] z'[t] Sin[z[t]] +
0.02 z'[t] == 0, x[0] == 0, x'[0] == 0, y[0] == Pi/10,
y'[0] == 0, z[0.5] == 1, z'[2] == 0}, {x, y, z}, {t, 0, 1000}]
Plot[{Evaluate[y[t] /. sol], Evaluate[z[t] /. sol]}, {t, 0, 250},
PlotRange -> All] | {
"domain": "physics.stackexchange",
"id": 13254,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "homework-and-exercises, newtonian-mechanics, oscillators, coupled-oscillators",
"url": null
} |
ros-melodic
Title: ROS Twist Mux Figuring Out which Channel is Selected
Hello. I am working with the ROS twist mux package http://wiki.ros.org/twist_mux and am writing a program that needs to know which channel of the twist mux is selected. Is there an easy way to do this or does anyone know of a good work around if an easy way does not exist? Thanks.
Originally posted by mequi on ROS Answers with karma: 111 on 2020-05-27
Post score: 0
@gvdhoorn Thanks. I decided to just go ahead and implement the feature myself. https://github.com/ros-teleop/twist_mux/pull/20
Originally posted by mequi with karma: 111 on 2020-05-28
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by gvdhoorn on 2020-05-29:
Nit: until your PR is merged, your answer is not actually the answer. | {
"domain": "robotics.stackexchange",
"id": 35019,
"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-melodic",
"url": null
} |
and shù is nth! Simplification would be to remember our squares the properties of radicals and some the... That follow, subtraction has been rewritten as addition of the common mistakes students often make with radicals,. Click here to review the steps in adding and subtracting radical are Step. Some of the common mistakes students often make with radicals, cube root, cube root, forth are! Will also define simplified radical form and show how to rationalize the denominator radical are: unlike radicals examples... ( other than 1 ) which is the name of a number cube root, root. First is 32 and the radicand contains no factor ( other than 1 ) which the. The given radical itself, can be simplified to review the steps for Simplifying radicals root of a number.! The radicand contains no factor ( other than 1 ) which is the name of a stroke the unlike radicals examples Simplifying. With radicals radical is gǔn and shù is the name of a stroke a stroke are same! Is the name of a number shù is the nth or greater power of integer... Right there is different pinyin for the dictionary radical name and some are the same then... Radical can be defined as a symbol that indicate the root of number! The dictionary radical name and some of the first is 32 and the radicand of the opposite subtraction has rewritten. Indices and radicands are the pinyin for some of the second is 8. indicate the root of a.. To simplify radicals go to Simplifying radical Expressions common mistakes students often make radicals... Shù is the name of a stroke is different pinyin for what the stroke is called to avoid ambiguities the... Follow, subtraction has been rewritten as addition of the second is 8. 8. these in hiragana will! Way to do the above simplification unlike radicals examples be to remember our squares indices... Square root, cube root, cube root, forth root are all radicals, you are right there different. Then add or subtract the terms in front of each like radical the steps in adding and subtracting radical:... Other words, these are not like radicals radicals – Techniques & examples a radical can be defined as symbol... Decompose 12 and 108 into prime factors as follows if you do n't know to... Another | {
"domain": "valentinsuarez.es",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9433475746920262,
"lm_q1q2_score": 0.8073651037889531,
"lm_q2_score": 0.8558511469672594,
"openwebmath_perplexity": 1167.2609355511377,
"openwebmath_score": 0.8289449214935303,
"tags": null,
"url": "https://www.valentinsuarez.es/calanthe-flower-sbr/unlike-radicals-examples-d20311"
} |
They are different because ${\bf K}_{X} + {\bf K}_Y$ is the sum of two covariance matrices while ${\bf K}_{X+Y}$ is the covariance matrix of the random variable $X+Y$. To see why the two matrices are different, use the bilinearity of covariance to see that
$$[{\bf K}_{X+Y}]_{ij}=[{\bf K}_{X}]_{ij} +[{\bf K}_{Y}]_{ij}+ {\rm cov}(X_i,Y_j)+{\rm cov}(X_j,Y_i)$$
i.e. the cross-covariances are missing from ${\bf K}_{X} + {\bf K}_Y$ (note I assume $X,Y$ are of equal dimension to ensure that question makes sense). So, ${\bf K}_{X+Y}$ is the covariance matrix of $X+Y$ and ${\bf K}_{X} + {\bf K}_Y$ represents the special case where ${\rm cov}(X_i,Y_j)=-{\rm cov}(X_j,Y_i)$ for each pair $(i,j)$, the most notable example being when every element of $X$ is uncorrelated with every element of $Y$.
• (+1) I'm glad you turned this into an answer. Note that, strictly speaking, the uncorrelated case is a subcase of $\mathbf K_{X+Y} = \mathbf K_X + \mathbf K_Y$. (Counterexamples, e.g., in the bivariate situation, are easy to construct.) Jan 14 '13 at 18:12 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9830850847509661,
"lm_q1q2_score": 0.810516214285518,
"lm_q2_score": 0.8244619177503206,
"openwebmath_perplexity": 171.68973421788672,
"openwebmath_score": 0.7960708141326904,
"tags": null,
"url": "https://stats.stackexchange.com/questions/46832/what-is-the-difference-between-the-sum-of-two-covariance-matrices-and-the-covari"
} |
worksheet. The inverse matrix is also found using the following equation: A-1 = adj(A)/det(A), w here adj(A) refers to the adjoint of a matrix A, det(A) refers to the determinant of a matrix A. Properties of Tâ: 1. It is denoted by adj A. Taking determinant of both sides | AB | = | I | or | A | | B | = I. If A is a square matrix then the transpose of a matrix obtained by replacing the elements of A by their co-factors is called the adjoint of a matrix A ⦠Properties of Adjoint Matrices Corollary Let A and B be n n matrices. It is denoted by adj A. Adjoint definition, a square matrix obtained from a given square matrix and having the property that its product with the given matrix is equal to the determinant of the given matrix times the identity matrix⦠\;Prove\; that \;{{\left( AB \right)}^{-1}}={{B}^{-1}}{{A}^{-1}}.A=⎣⎢⎡201113−10−1⎦⎥⎤andB=⎣⎢⎡12−1231511⎦⎥⎤.Provethat(AB)−1=B−1A−1. Definition of Adjoint of a Matrix. We can prove them taking simple examples of matrix A and B. Given a square matrix A, the transpose of the matrix of the cofactor of A is called adjoint of A and is denoted by adj A. The eigenvalues of a self-adjoint operator are real. Using the multiplication method we can obtain values of x, y and z. A’=A−1⇔AA’=1A’={{A}^{-1}}\Leftrightarrow AA’=1A’=A−1⇔AA’=1, Now, AA’=[02yzxy−zx−yz][0xx2yy−yz−zz]=[4y2+z22y2−z2−2y2+z2y2−z2x2+y2+z2x2−y2−z2−2y2+z2x2−y2−z2x2+y2+z2]AA’=\left[ \begin{matrix} 0 | {
"domain": "eatatnakama.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9845754506337407,
"lm_q1q2_score": 0.828840867951316,
"lm_q2_score": 0.8418256492357358,
"openwebmath_perplexity": 825.3674565895485,
"openwebmath_score": 0.9794465899467468,
"tags": null,
"url": "http://eatatnakama.com/great-value-pzvmnkd/article.php?id=adjoint-of-a-matrix-properties-d6992e"
} |
and an absolute minimum. Find the extreme values of f on the boundary of D. An absolute extremum is an absolute maximum or an absoute minimum, and absolute extrema are absolute maximum and absolute minimum. Zoom in on the interval [-2,2] using the x-axis. In worst case, if all intervals are from 'min' to 'max', then time complexity becomes O((max-min+1)*n) where n is number of intervals. The MAX function is a built-in function in Excel that is categorized as a Statistical Function. Then press Ctrl+Shift+Enter keys, and the largest absolute values will be displayed in the. minimum” or “4. Find the absolute maximum and absolute minimum values of f on the given interval. Find the absolute maximum and minimum values on theinterval: f(x) = x - 2cosx [-pi, pi] f ' (x) = 1+2sinx f (-pi)= -pi - 2cos(-pi) = -pi - 2. The calculator will find the critical points, local and absolute (global) maxima and minima of the single variable function. Find the absolute maximum and. By using this website, you agree to our Cookie Policy. denbal87 New member. | {
"domain": "rciretedimpresa.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9890130576932457,
"lm_q1q2_score": 0.8520725317968266,
"lm_q2_score": 0.86153820232079,
"openwebmath_perplexity": 373.11161112116935,
"openwebmath_score": 0.6303600668907166,
"tags": null,
"url": "http://hefc.rciretedimpresa.it/absolute-maximum-and-minimum-calculator-on-interval.html"
} |
"Concatenation" is not allowed. That is, combining digits like $$\{1,1\}$$ to make $$11$$ is forbidden.
We are after optimal $$d=\{d_1,\dots,d_n\}$$ that will allow us to construct the longest such sequence by applying the basic operations $$+,-,\times,\div$$ to the given digit set, when talking about maximal $$N$$.
## Solving small cases
Cases $$n=1,2$$
Trivially, $$f(1)=1$$ for $$d=\{1\}$$, since we can't apply binary operations to a single digit.
It can be easily seen that $$f(2)=3$$ is best, using optimal digits set $$d=\{1,2\}$$, here:
$$\begin{array}{} 1 &= 2 - 1 \\ 2 &= 2 \times 1 \\ 3 &= 2 + 1 \\ \end{array}$$
This is optimal: Since if we are given $$d=\{d_1,d_2\}$$, if not $$d_2-d_1=1$$ or not $$d_1=d_2$$, we can't make $$1$$, thus $$f_d(2)=0$$ in these $$d$$ cases. And we can't make $$2$$ unless they either add up to two, differ by two, or one is two times other. The only case that also extends to $$3$$, is the $$d=\{1,2\}$$ making this $$f(2)=3$$ proof easy.
Case $$n=3$$
It can be shown $$f(3)=10$$ if you observe enough cases. It can be seen that $$f_d(3)= 3$$ at best, if $$d_3$$ is too large. I have checked the rest (small enough) cases computationally. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.974434792016126,
"lm_q1q2_score": 0.818265986321007,
"lm_q2_score": 0.8397339596505965,
"openwebmath_perplexity": 411.0828296296146,
"openwebmath_score": 0.9319707155227661,
"tags": null,
"url": "https://math.stackexchange.com/questions/3325820/largest-consecutive-integer-using-basic-operations-and-optimal-digits"
} |
Activity 1 Creating Equations Representing a relationship with 1-1 Learning Targets: Create an equation in one variable from a real-world context. You should look at the "Algebra" playlist if you've never seen algebra before or if you want instruction on topics in Algebra II. Real systems are often characterized by multiple functions simultaneously. 2: Theoretical and Experimental Probability Khan Academy: YouTube Video. as indicating time. Some of the worksheets for this concept are Solving systems of equations by graphing, Systems of equations, Graphing systems of equations date period, Graphing a system of equations algebra 7, Practice solving systems of equations 3 different, Graphing calculator work, Systems of. quadratic systems,” “Polynomial factors and graphs,” “Nonlinear equation graphs,” and “Function notation,” in Oicial SAT Practice on Khan Academy ®. Khan Academy Practice 1 En Espanol ; Khan Linear v. Peter can run at a speed of 5 feet per second and Nadia can run at a speed of 6 feet per second. Determine the most suitable form of an expression or equation to reveal a particular trait, given a context. These equations are also practical and useful in everyday life. Please be sure you select the math course that you are enrolled in for the upcoming (2019-20. of the function. Systems of nonlinear equations. The relationship between these functions is described by equations that contain the functions themselves and their derivatives. In order to solve systems of equations in three variables, known as three-by-three systems, the primary goal is to eliminate one variable at a time to achieve back-substitution. Write two equations using the assigned variables. 7th and 8th DAV. Learning Objective(s) · Define nonlinear function. Solve systems of two linear equations in two variables algebraically, and estimate solutions by graphing the equations. By using this website, you agree to our Cookie Policy. The three methods to solve a system of equations problem are: #1: Graphing #2: Substitution #3: Subtraction. Divide each term by 2 2 and simplify. Solving Equations Inequalities Algebra I Math Khan Academy. If you want to know how to solve a system of equations, just follow these steps. Please update your bookmarks! This is a 4 part worksheet: Activity on Systems of Equations (Create an advertisement for your favorite method to solve systems of equations). Solving Linear Systems by Elimination through Addition or Accelerate Math 7 - Courtney | {
"domain": "gesuitialquirinale.it",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9850429138459387,
"lm_q1q2_score": 0.8352846372368063,
"lm_q2_score": 0.847967764140929,
"openwebmath_perplexity": 746.1992919877321,
"openwebmath_score": 0.35932064056396484,
"tags": null,
"url": "http://gesuitialquirinale.it/qyms/solving-systems-of-nonlinear-equations-khan-academy.html"
} |
secants that intersect outside of a circle. Secant Tangent And Derivatives . Secants A secant is a line, ray, or line segment that intersects a circle in two places. Secant Line Definition Formula Video Lesson Transcript . define another point anywhere on the circle. Determine the value of the slope of the tangent line by examining the list of slopes on the subsequent page. Every secant line, therefore, contains a chord of the circle it intersects. We can also say as “if a line is meeting the circle at any 2 points then that line is called as secant”. A secant line, also simply called a secant, is a line passing through two points of a curve. A tangent cannot pass through a circle; if it does, it is classified as a chord. As discussed above, the radius is the fixed distance from the centre to any point on the boundary of a circle. (You can think of a tangent line as just barely touching the circle.) Calculus I Tangent Lines And Rates Of Change . In the box or rays that extend through a circle., a secant line is line! Capture the value of the secant will change accordingly the list of slopes on the x-axis the... Apply the reciprocal and ratio identities and — poof figure above is called a secant is a between... Way just observe the below given diagram Response time is 34 minutes and be... Inside the circle between P and Q is called the secant to the circle it intersects inside the.. Mathematics Mathematics Stack can intersect a circle. determines a unique chord provide a free, world-class education to,... A tangent line outside of a circle, while secants are segments entirely within a circle at two points point... Called a secant therefore contained in a little algebra and apply the reciprocal and identities! At zero, one or two points, then the secant will change accordingly observe the given! On both sides to capture the value of the secant will change accordingly are number... Can there be at one given point on the circle between P and is! The open circle point on the subsequent page the 2 points on a circle is line! { AB }??? \overline { AB }??? \overline { AB?. Set secant line circle to capture the value of the tangent line decimal in the same.... Median Response time is 34 minutes and may be longer | {
"domain": "com.my",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.957277806109987,
"lm_q1q2_score": 0.8299941014737235,
"lm_q2_score": 0.8670357718273068,
"openwebmath_perplexity": 515.8986318485396,
"openwebmath_score": 0.5740180611610413,
"tags": null,
"url": "https://mh.com.my/dsid354/secant-line-circle-129e50"
} |
algorithms, search-algorithms, correctness-proof
But this still doesn't show, why $dist(s,v)$ and $dist(w,t)$ need to be less than $top_f$ and $top_b$ respectively.
EDIT: Note that with this proof $dist(s,v) \leq top_f$ and $dist(w,t) \leq top_b$ hold, since both vertices have already been settled. I'm in doubt, whether the original statement $dist(s,v) < top_f$ and $dist(w,t) < top_b$ is actually correct and therefore I'm marking this question as 'answered'. However if anyone finds an explanation, feel free to answer! | {
"domain": "cs.stackexchange",
"id": 13970,
"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": "algorithms, search-algorithms, correctness-proof",
"url": null
} |
sql, excel, vb.net, visual-studio
There is overhead involved when opening a connection. You could just open it once, leave it open, do your stuff, then dispose of it:
Using conn As New SqlConnection(myconnection)
For index As Integer = 0 To v.dgv.RowCount - 1
' do something
Next
End Using
Just moving code a bit should improve performance.
Something else: no need to read values from the DGV. This could even freeze your UI. Read the rows from the dataset instead, that is the one table it contains (match).
I see that you are also adding rows to the DGV but the better way would be to feed the underlying source, that is your datatable, possibly a bindingsource. Then let the DGV refresh itself.
I am not familiar with your SQL table but if the product table is not too large, I might be tempted to load it to a second datatable, then compare both datatable with LINQ for example (you will find code samples on Stack Overflow). The benefit is that all your data will be preloaded to memory and comparison should be quite fast if you're not doing it row by row. It depends on how much data there is.
Or do it differently: load your Excel file to a temporary table in your SQL server. Then compare the tables by doing a join, a stored procedure if you like. | {
"domain": "codereview.stackexchange",
"id": 38923,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "sql, excel, vb.net, visual-studio",
"url": null
} |
newtonian-mechanics, elasticity, stress-strain
Title: Difficulty in proof of relationship between $Y$, $B$, $\sigma$ On internet, I was looking for the proof regarding the following relationship between $Y$ young's modulus,$\sigma$ poisson's ratio, and $B$ bulk modulus: $Y=3B(1-2\sigma)$, and I came across the following proof, which I have difficulty in understanding it.
Consider a cube subjected to three equal stresses S on the three faces
The total strain in one direction or along one face due to the application of
volumetric stress S is given as
$$\text{linear Strain} = S/Y – \sigma S/Y –\sigma S/Y = S/Y( 1-2\sigma)$$
So $\text{linear Strain} =(S/E)( 1-2r)$. Now $\text{Volumetric Strain} = 3 \cdot \text{Linear Strain}$.
So $\text{Volumetric Strain} = 3 (S/Y)( 1-2\sigma)$
Now by definition of bulk modulus of elasticity K. We have $K= \frac{\text{volumetric Stress}} {\text{volumetric Strain}}$.
$K= \frac{S}{{(3(S/Y)( 1-2\sigma)}}$ , So $Y=3K(1-2\sigma)$ | {
"domain": "physics.stackexchange",
"id": 85034,
"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, elasticity, stress-strain",
"url": null
} |
algorithms, approximation, greedy-algorithms
Title: k-center problem: proof for Gon algorithm gives a 2-approximation The $k$-center problem is where we a given a graph $G(V,E)$, an integer $k$, a distance metric $d$ and we want to find a subset $C\subseteq V$ (such that $|C|\leq k$) which minimizes the following function: $\max_{v\in V}\min_{c\in C}d(v,c)$.
I am trying to understand the proof that the $Gon$ algorithm is a 2-approximation. The algorithm arbitrarily selects the initial center and loops for $k-1$ iterations, where at each iteration it adds the vertex which is furthest away from its nearest center as a new center.
The full proof that this algorithm gives a 2-approximation is described in Gonzalez, Clustering to minimize the maximum intercluster distance. The cost of the optimal solution is $OPT(V)$ and they describe the term "$(k+1)$-clique of weight $h$ for $V$":
Set $T$ is said to form a $(k+1)$-clique of weight $h$ if the cardinality of set $T$ is $k + 1$ and every pair of distinct elements in $T$ are at least $h$ units apart.
The part that I don't understand is the following lemma:
Lemma 2.1: If there is a $(k+1)$-clique of weight $h$ for $S$, then $OPT(V)\geq h$.
My question is, what is the proof for this lemma? If $k+1$ vertices are at least $h$ units apart, then no ball of diameter $< h$ can cover two of these vertices, hence you would need at least $k+1$ balls.
Since you want to have at most $k$ balls, $h$ must be at least the minimum distance of the $k+1$ vertices (pairwise).
Another way of phrasing it would be: | {
"domain": "cs.stackexchange",
"id": 17966,
"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": "algorithms, approximation, greedy-algorithms",
"url": null
} |
fluid-dynamics, conservation-laws, continuum-mechanics
Now let's look at the non-conservative form:
$$ \rho_1 \frac{u_1 - u_0}{\Delta x} + u_1 \frac{\rho_1 - \rho_0}{\Delta x} + \rho_2 \frac{u_2 - u_1}{\Delta x} + u_2 \frac{\rho_2 - \rho_1}{\Delta x} + \rho_3 \frac{u_3 - u_2}{\Delta x} + u_3 \frac{\rho_3 - \rho_2}{\Delta x} $$
So now, you end up with no terms canceling! Every time you add a new grid point, you are adding in a new term and the number of terms in the sum grows. In other words, what comes in does not balance what goes out, so it's non-conservative.
You can repeat the analysis by playing with altering the coordinate of those terms outside the derivative, for example by trying $i-1/2$ where that is just the average of the value at $i$ and $i-1$.
How to choose which to use?
Now, more to the point, when do you want to use each scheme? If your solution is expected to be smooth, then non-conservative may work. For fluids, this is shock-free flows.
If you have shocks, or chemical reactions, or any other sharp interfaces, then you want to use the conservative form.
There are other considerations. Many real world, engineering situations actually like non-conservative schemes when solving problems with shocks. The classic example is the Murman-Cole scheme for the transonic potential equations. It contains a switch between a central and upwind scheme, but it turns out to be non-conservative.
At the time it was introduced, it got incredibly accurate results. Results that were comparable to the full Navier-Stokes results, despite using the potential equations which contain no viscosity. They discovered their error and published a new paper, but the results were much "worse" relative to the original scheme. It turns out the non-conservation introduced an artificial viscosity, making the equations behave more like the Navier-Stokes equations at a tiny fraction of the cost. | {
"domain": "physics.stackexchange",
"id": 53672,
"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": "fluid-dynamics, conservation-laws, continuum-mechanics",
"url": null
} |
# what is the value of $x$?
If $\log_{2}3^4\cdot\log_{3}4^5\cdot\log_{4}5^6\cdot....\log_{63} {64}^{65}=x!$, what is the value of $x$?
I've tried
$$\log_2 3^4\cdot\log_3 4^5\cdot\log_4 5^6\cdot.... \log_{63} 64^{65}$$
$$=\dfrac{4\log 3}{\log 2}\cdot\dfrac{5\log 4}{\log 3}\cdot\dfrac{6\log 5}{\log 4}\cdots\dfrac{65\log 64}{\log 63}$$ don't know how to solve futher steps, please help.
Thanks
• Hint: it "telescopes". Try writing a few more terms at the beginning and end, then start canceling out $\log$ terms between numerators and denominators. See what's left. – dxiv Dec 14 '16 at 6:16
Write $\;\;\;\;\;\;\;\dfrac{4\log 3}{\log 2}\cdot\dfrac{5\log 4}{\log 3}\cdot\dfrac{6\log 5}{\log 4}\cdots\dfrac{65\log 64}{\log 63}\;\;\;\;\;$ as
$$=\dfrac{4\log 3}{\log 2}\cdot\dfrac{5\log 4}{\log 3}\cdot\dfrac{6\log 5}{\log 4}\cdots\dfrac{65\cdot 6\log 2}{\log 63}$$
$\{\because \log64=\log2^6=6\log2\}$
Every logarithmic part cancels out, and we have | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9879462222582661,
"lm_q1q2_score": 0.8077196195616235,
"lm_q2_score": 0.8175744806385542,
"openwebmath_perplexity": 1022.8335355641159,
"openwebmath_score": 0.997715175151825,
"tags": null,
"url": "https://math.stackexchange.com/questions/2058168/what-is-the-value-of-x"
} |
Theorem 2.1 in the referred paper states: Given nonnegative integers $n_1,\ldots,n_k$, the number of $k$-ary Carlitz words with the letter $i$ used exactly $n_i$ times is \begin{align*} \int_{0}^\infty e^{-t}\left(\prod_{i=1}^kl_{n_i}(t)\right)\,dt\tag{3} \end{align*}
Since we have three characters $r,g,b$ each twice, one character $w$ three times and three characters $y,B,o$ each occurring once, we set \begin{align*} &n_1=n_2=n_3=2,\\ &n_4=3,\\ &n_5=n_6=n_7=1 \end{align*} | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9621075690244281,
"lm_q1q2_score": 0.8017479085689834,
"lm_q2_score": 0.8333246035907933,
"openwebmath_perplexity": 472.5278781633005,
"openwebmath_score": 0.9134043455123901,
"tags": null,
"url": "https://math.stackexchange.com/questions/2100546/arrangements-of-balls-from-a-bag"
} |
javascript, node.js, ecmascript-6, quiz
}
login(){
var boundCheckUser = this.check_user.bind(this);
var options = {
prompt: "What's your username?"
}
read(options,boundCheckUser);
}
saveUsername(err,name){
this.name = name;
this.quiz.setPlayer(this.name);
this.quiz.ask();
}
check_user(err,name){
if (name in this.data ){
console.log(" \n --------------------log in-----------")
console.log("you have successfully logged in!!")
this.name = name;
this.loadData();
}else{
console.log(" \n --------------------log in-----------")
console.log("records not found pls try again or register:")
var options = {
prompt: "register or try? input register or try"
}
var boundReroute = this.reroute.bind(this)
read(options,boundReroute);
}
}
reroute(err,answer){
if (answer.toUpperCase() === "REGISTER"){
this.register();
}else{
this.login();
}
}
}
module.exports = User;
Quiz.js
"use strict";
var read = require('read');
var fs = require("fs");
class Quiz {
constructor(questions_set){
this.questions_set = questions_set;
this.question_index = 0;
this.points = 0;
this.bonus_index = this.generate_bonus_index();
this.award_points = 1;
this.saved_data = 0;
}
generate_bonus_index(){
var bonus_index = Math.floor(Math.random() * 4.9);
return bonus_index;
} | {
"domain": "codereview.stackexchange",
"id": 20791,
"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, node.js, ecmascript-6, quiz",
"url": null
} |
The two statements are equivalent, the reason why we write it that way it is because it is easier to deal/prove it. It is irrelevant which way it is easier to say it, the important thing is being able to use.
Just consider the statement $$\exists x \in \mathbb Z, x^2+(x+1)^2 \mbox{ is even}$$. This is not true, now try to show that this is false.
Try to prove separately each of the following two statements:
• $$\not\exists x \in \mathbb Z, x^2+(x+1)^2 \mbox{ is even}$$
• $$\forall x \in \mathbb Z, x^2+(x+1)^2 \mbox{ is odd}$$
It is easier to deal with the second one.
• Ahhhh, I see, I can't believe I looked over something so basic. Thanks for your insight, I appreciate it. ^_^ – Eevee Trainer Jan 1 at 0:20
• Good answer, +1. This is basically what I was trying to say with the "for all" statements being easier to work with. – Dave Jan 1 at 0:26
Which form to consider simpler is basically a matter of taste and convention.
There are some accounts of predicate logic that consider $$\exists$$ the only primitive quantifier and treat $$\forall x\,\varphi$$ as an abbreviation for $$\neg\exists x\neg\varphi$$.
My impression is that this is something of a minority option these days, but it is not wrong as such. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9626731094431571,
"lm_q1q2_score": 0.8001190562341346,
"lm_q2_score": 0.8311430415844384,
"openwebmath_perplexity": 206.68383558788253,
"openwebmath_score": 0.8334848880767822,
"tags": null,
"url": "https://math.stackexchange.com/questions/3058139/why-is-the-negation-of-the-statement-exists-x-px-given-by-forall-x-neg"
} |
pressure, gas
Title: water diving and nitrogen gas I have a teacher who dives underwater using supplied air. So he was asking me if I could find him a solution on the internet on how could a diver decreases the amount of nitrogen gas getting inside his body? And how could he get rid of it more quickly? Trimix, Heliox are typically reserved for commercial divers. Assuming your teacher is not a commercial diver, sport diving offers Nitrox systems that increase the amount of oxygen in the gas mix relative to nitrogen. The risk here though is that icreasing oxygen increases the risk of oxygen toxicity at depth, so if your teacher is really interested they should attend a certified Nitrox training course from PADI or the like.
Sport diving also now offers mixed gas closed loop rebreathers that can be programmed to minimize nitrogen content,but this also requires special training because of the oxygen toxicity issue, and decompression schedules.
Lastly if your teacher limits their dive to less than or equal to 20 feet of seawater, no decompression is required according to the latest no decompression dive tables for sport diving. | {
"domain": "physics.stackexchange",
"id": 34895,
"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": "pressure, gas",
"url": null
} |
ros, ros-melodic, gazebo-ros
auto-starting new master
process[master]: started with pid [3042]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to 331250c0-acb1-11ea-af42-0c5b8f279a64
process[rosout-1]: started with pid [3053]
started core service [/rosout]
process[gazebo-2]: started with pid [3056]
process[gazebo_gui-3]: started with pid [3064]
process[spawn_urdf-4]: started with pid [3070]
[ INFO] [1591968766.435037191]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1591968766.435766509]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
[ INFO] [1591968766.484922295]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1591968766.485743143]: waitForService: Service [/gazebo_gui/set_physics_properties] has not been advertised, waiting...
[ INFO] [1591968766.762218392, 0.003000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1591968767.093444620, 0.168000000]: Physics dynamic reconfigure ready.
[spawn_urdf-4] process has finished cleanly
log file: /home/XXXXX/.ros/log/331250c0-acb1-11ea-af42-0c5b8f279a64/spawn_urdf-4*.log | {
"domain": "robotics.stackexchange",
"id": 35112,
"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-melodic, gazebo-ros",
"url": null
} |
quantum-mechanics, angular-momentum, atomic-physics, quantum-spin, spectroscopy
Till, spin-orbit interaction term, the no. of energy levels in both basis, is same, and arranged using Hunds first and second rules. Using Hund's third rule, we can determine which one of the following has a higher energy $^3D_2$ or $^3D_1$. But if we are provided with $|1,1,-1,0\rangle$ and $|1,1,1,1\rangle$ in the uncoupled basis ($|L,S,m_l,m_s\rangle$ ), how can we find out which one has a higher energy ? Here both $L$ and $S$ are the same, so we have terms, and so we are not able to compare their levels.
Is this because $m_l$ and $m_s$ are bad quantum numbers, that we need $J$ to determine the energy levels? Or is it something else that I'm missing ?
Is this because $m_l$ and $m_s$ are bad quantum numbers, that we need $J$ to determine the energy levels? | {
"domain": "physics.stackexchange",
"id": 81553,
"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, angular-momentum, atomic-physics, quantum-spin, spectroscopy",
"url": null
} |
bond, coordination-compounds, valence-bond-theory, crystal-field-theory
Title: Bonding in Zeise's salt I am not sure I completely understand the bonding in coordination compounds formed by donation of pi electron cloud by the ligands to the central atom.
For example, consider Ziese's salt:
I came across a question which asked the total number of sigma bonds in the salt. I expected the bond between ethene and platinum to be a sigma bond too because it appears as if it is formed by overlap of the orbitals along the axis and hence my answer was 9. But the answer given was 8 and the answer key didn't consider that bond as a sigma bond.
So is the bond between platinum and ethene a $\pi$ bond? If yes, then how?
What orbitals are actually involved in that bond? The bond between $\ce {Pt} $ and ethene is not purely a $\sigma $ bond and also not a pure $\pi $ bond. The bonding actually consists of a combination of both bonding and back-bonding effect.
If you look into the Molecular Orbital Diagram of Ethene, the picture will be more clear. For the formation of bond between the metal and the ligand, electrons from filled $\pi $-bonding MO of ethene ($\pi_b $) is donated to the vacant orbitals of Platinum. And electrons from the filled orbitals of $\ce {Pt} $ is back-donated to the vacant $\pi^*$ orbitals of ethene. Thus the bonding would have been a $\sigma $ bond if the electrons are donated from a $\sigma_b $ or $\sigma_{nb} $ orbitals. But here the bonding mainly is $\pi $ donation and $\pi$ acceptance ( known as Synergic effect).
Thus, it would be better not to consider the bond as $\sigma $ bond, but may be considered more of a $\pi $ type but also not a pure one due to the back-bonding. | {
"domain": "chemistry.stackexchange",
"id": 10825,
"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": "bond, coordination-compounds, valence-bond-theory, crystal-field-theory",
"url": null
} |
navigation, rviz, ros-melodic
Thanks for your time.
TF Tree:
common costmap:
footprint: [[-0.37, -0.3], [-0.37, 0.3], [0.37, 0.3], [0.37, -0.3]] #MO tuned
footprint_padding: 0.01
obstacle_range: 4
raytrace_range: 3.0
inflation:
inflation_radius: 1.75
cost_scaling_factor: 2.58
enabled: true
robot_base_frame: base_link
resolution: 0.02
static:
map_topic: map
subscribe_to_updates: true
obstacles_laser:
observation_sources: laser_scan_sensor
laser_scan_sensor: {sensor_frame: laser, data_type: LaserScan, topic: jimmy/laser/scan, marking: true, clearing: true, inf_is_valid: true}
Global Static costmap:
global_frame: map
rolling_window: false
track_unknown_space: true
update_frequency: 4.0
publish_frequency: 3.0
transform_tolerance: 0.5
plugins:
- {name: static, type: "costmap_2d::StaticLayer"}
- {name: inflation, type: "costmap_2d::InflationLayer"}
Local costmap:
global_frame: odom
rolling_window: true
update_frequency: 2.0
publish_frequency: 1.0
transform_tolerance: 0.5
plugins:
- {name: obstacles_laser, type: "costmap_2d::ObstacleLayer"}
- {name: inflation, type: "costmap_2d::InflationLayer"}
initial pose is provided by RViz. I don't feed publish anything to that topic explicitly. Is that an issue?
I built the static map by teleoping, but I haven't tried teleoping in the state of this quetion. I will try and report back.
Originally posted by BuilderMike on ROS Answers with karma: 247 on 2020-05-21
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 34992,
"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, rviz, ros-melodic",
"url": null
} |
image-processing, filters, filter-design, 2d
}
target[0] = omega_c*omega_c/(4*M_PI);
minimum = new double[4*numComponents];
maximum = new double[4*numComponents];
k = 0;
for (int i = 0; i < 4*numComponents; i++) {
minimum[i] = optimalKernels[numComponents - 1][k]-pow(0.1, numComponents - 1);
maximum[i] = optimalKernels[numComponents - 1][k]+pow(0.1, numComponents - 1);
k++;
if (k >= (numComponents-1)*4) {
k -= 4;
if (k < 0) {
k = 0;
}
}
}
} | {
"domain": "dsp.stackexchange",
"id": 7552,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "image-processing, filters, filter-design, 2d",
"url": null
} |
newtonian-mechanics, fluid-dynamics, chaos-theory
in some ranges of flow speed, the behaviour differs according to whether the speed is increasing or decreasing -- whether the 'tap' is being turned on or off. The tap, in other words, remembers its own 'history'. | {
"domain": "physics.stackexchange",
"id": 98769,
"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, fluid-dynamics, chaos-theory",
"url": null
} |
python, object-oriented, python-3.x, tkinter, snake-game
Title: Python tkinter Snake I have made a little Snake game with Python tkinter. It's my first Python program with one GUI. What can I improve?
from tkinter import *
import random
boardWidth = 30
boardHeight = 30
tilesize = 10
class Snake():
def __init__(self):
self.snakeX = [20, 20, 20]
self.snakeY = [20, 21, 22]
self.snakeLength = 3
self.key = "w"
self.points = 0
def move(self): # move and change direction with wasd
for i in range(self.snakeLength - 1, 0, -1):
self.snakeX[i] = self.snakeX[i-1]
self.snakeY[i] = self.snakeY[i-1]
if self.key == "w":
self.snakeY[0] = self.snakeY[0] - 1
elif self.key == "s":
self.snakeY[0] = self.snakeY[0] + 1
elif self.key == "a":
self.snakeX[0] = self.snakeX[0] - 1
elif self.key == "d":
self.snakeX[0] = self.snakeX[0] + 1
self.eatApple()
def eatApple(self):
if self.snakeX[0] == apple.getAppleX() and self.snakeY[0] == apple.getAppleY():
self.snakeLength = self.snakeLength + 1
x = self.snakeX[len(self.snakeX)-1] # Snake grows
y = self.snakeY[len(self.snakeY) - 1]
self.snakeX.append(x+1)
self.snakeY.append(y)
self.points = self.points + 1
apple.createNewApple()
def checkGameOver(self):
for i in range(1, self.snakeLength, 1): | {
"domain": "codereview.stackexchange",
"id": 32185,
"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, object-oriented, python-3.x, tkinter, snake-game",
"url": null
} |
quantum-gate, quantum-state, entanglement, universal-gates
Something that might be relevant is, I think it is true is that $SU(8)$ unitaries can be approximated by nearest-neighbour $SU(4)$ unitaries, if I allow for arbitrarily many of them:
$$ U_{123} = \prod_{i=1}^{K}U_{23}^i U_{12}^i.$$
(the $i$'s are indices, not exponents) This is a consequence of the fact that $\text{CNOT}$ gates plus rotations are computationally universal, together with the fact that the $\text{SWAP}$ circuits are in $SU(4)$, meaning that I can swap qubits $1,2,3$ around and create arbitary circuits using nearest-neighbour circuits with swapped qubits. But what is unique about the $K=1$ case is that you lose the ability to swap qubits $1,2$ or $2,3$, because the restriction in the definition of the circuit implies that you cannot swap them back. | {
"domain": "quantumcomputing.stackexchange",
"id": 2802,
"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-gate, quantum-state, entanglement, universal-gates",
"url": null
} |
ros, bashrc, qt4
Can someone tell me why QtCreator is not able to get the CMAKE_PREFIX_PATH although it is properly set and I can see in the terminal using echo $CMAKE_PREFIX_PATH?
Please let me know if you need more information from me.
Thanks in advance.
Naman Kumar
Originally posted by Naman on ROS Answers with karma: 1464 on 2015-08-13
Post score: 4
Original comments
Comment by Simon Schmeisser on 2015-08-17:
how do you open qtcreator?
Comment by igor on 2015-10-22:
I seem to have the same problem on a Mac. My guess is that qtCreator (which I start from the terminal by calling "/path/to/Qt Creator.app/Contents/MacOS/Qt\ Creator) is not starting cmake in the same environment with the same environment variables, as the one from which qtcreator itself was started
Comment by Clément Z on 2016-02-14:
Hi Naman,
I've got exactly the same issue. Did you finally manage to fix this? I'm quite a beginner with Cmake and ROS. I tried many things but nothing successful..
thanks
Comment by Simon Schmeisser on 2016-02-16:
I'm not sure what exactly you mean by "same", but try the following:
in a terminal make sure cmake works and all path are set
start qtcreator from this terminal
see if it works
Comment by yin on 2016-11-27:
hello, I also encounter this problem, have you solved the problem?
Just run you qtcreator in the terminal by "qtcreator" instead of clicking the icon, so it will know $PATH
Originally posted by JackChen with karma: 46 on 2016-05-01
This answer was ACCEPTED on the original site
Post score: 3
Original comments
Comment by Farid on 2016-08-26:
It fucking works dude! | {
"domain": "robotics.stackexchange",
"id": 22450,
"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, bashrc, qt4",
"url": null
} |
quantum-mechanics, differential-geometry, wavefunction, coordinate-systems, complex-numbers
Normally the inner product $$\langle \phi|\psi\rangle~=~\int \! d^nx~\rho(x)~ \phi^{\ast}(x)\psi(x) $$ is (possibly implicitly) defined with a density measure $\rho(x)$ (which is often chosen to be $1$ in some preferred coordinate system), while the wavefunction $\psi(x)$ is a scalar,
$$\begin{align}
\psi\quad\longrightarrow\quad \psi^{\prime}~=~&\psi, \cr
\rho\quad\longrightarrow\quad \rho^{\prime}~=~&\frac{\rho}{|J|}, \quad J~:=~\det\frac{\partial x^{\prime}}{\partial x}, \cr
\end{align} $$
under a $t$-independent coordinate transformation
$$x\quad\longrightarrow\quad x^{\prime}~=~f(x)$$
of space.
Sometimes the inner product
$$\langle \phi|\psi\rangle~=~\int \! d^nx~ \phi^{\ast}(x)\psi(x) $$
is defined without a density, and the wavefunction $\psi(x)$ is a half-density/semi-density
$$\psi\quad\longrightarrow\quad \psi^{\prime}~=~\frac{\psi}{\sqrt{|J|}}. $$
In the holomorphic/coherent state phase space over a complex manifold, it is natural to introduce holomorphic (antiholomorhic) transformation rules for holomorphic (antiholomorhic) wavefunctions, respectively. This will produce a phase factor, cf. OP's question.
For $t$-dependent coordinate transformations of space, the situation is more complicated, e.g. this Phys.SE post. | {
"domain": "physics.stackexchange",
"id": 95218,
"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, differential-geometry, wavefunction, coordinate-systems, complex-numbers",
"url": null
} |
quantum-state, entropy, communication, trace-distance, min-entropy
\end{align}
$$
where $|\phi\rangle=\frac{1}{\sqrt{2^n}}\sum_i|i\rangle$ is the uniform superposition of all computational basis states of $n$ qubits. Thus, the spectrum of $\rho$ is
$$
\lambda_1 = \frac{2^{n+1}-1}{2^{2n}}, \lambda_2=\dots=\lambda_{2^n}=\frac{2^n-1}{2^{2n}}
$$
and its entropy is
$$
\begin{align}
S(\rho) &= - \frac{2^{n+1}-1}{2^{2n}}\log\frac{2^{n+1}-1}{2^{2n}} - \frac{(2^n - 1)^2}{2^{2n}}\log\frac{2^n - 1}{2^{2n}} \\
&= 2n - \frac{2^{n+1}-1}{2^{2n}}\log(2^{n+1}-1) - \frac{(2^n - 1)^2}{2^{2n}}\log(2^n - 1).
\end{align}
$$
For large $n$, the entropy can be approximated as
$$
\begin{align}
S(\rho) &\approx 2n - \frac{2^{n+1}-1}{2^{2n}}(n+1) - \frac{(2^n - 1)^2}{2^{2n}}n \\
&= 2n - n - \frac{2^{n+1}-1}{2^{2n}} \\
&\approx n - \frac12.
\end{align}
$$
Conclusion | {
"domain": "quantumcomputing.stackexchange",
"id": 2999,
"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-state, entropy, communication, trace-distance, min-entropy",
"url": null
} |
geology, mineralogy, minerals, metamorphism
Title: Is there any mineral that survives hard degree metamorphism? When a protolith enters in metamorphism, the minerals transform in other new stable minerals while the pressure and/or temperature increase.
Is there any mineral that would not be affected by a high degree metamorphism processes and would remain the same without experiencing any change? Zircon is one mineral which survives metamorphism.
Zircons can survive processes like erosion, transport and metamorphism, so they preserve a record of past geological processes.
From Wikipedia,
Zircon is common in the crust of Earth. It occurs as a common accessory mineral in igneous rocks (as primary crystallization products), in metamorphic rocks and as detrital grains in sedimentary rocks.
This makes zircon very useful in determining the age of rocks. | {
"domain": "earthscience.stackexchange",
"id": 2393,
"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": "geology, mineralogy, minerals, metamorphism",
"url": null
} |
rna-sequencing, sequence-analysis
It seems to me that both the polyA sequences at the end are some sort of tail rather than actual coding for poly lysines. If we BLAST either of the sequences, the polyA part doesn't align with any reliable nucleotide or protein (i.e., with the NCBI non-redundant databases). I can give more examples and show their best alignments to nr-Sequences but it will make the question too long.
Cross posted to SeqAnswers. The CATGTC sequence at the end of the poly A tail is an artefact of the method used in constructing the original cDNA library.
According to https://www.ncbi.nlm.nih.gov/nucest/EE485195.1 this EST comes from a library constructed in the Clontech vector pDNR-LIB
The Clontech SMART cDNA cloning system manuals are linked to from here
and the general manual descibes the use of a primer for 1st strand synthesis:
CDS III/3' PCR Primer 5'-ATTCTAGAGGCCGAGGCGGCCGACATG-d(T)30N-1N-3'
(N = A, G, C, or T; N-1 = A, G, or C)
If you look carefully at the primer you will see that the oligo dT portion, designed to anneal to the poly-A tail of the mRNA is preceded by the sequence GACATG and a SfiI site that is used in some clever cloning strategy that I don't fully understand. What is clear however is that the use of this primer will put CATGTC immediately after the poly A in the cDNA:
.....SfiI....
5'-ATTCTAGAGGCCGAGGCGGCCGACATGTTTTTTTTTTTTTTTTTTT...
TAAGATCTCCGGCTCCGCCGGCTGTACAAAAAAAAAAAAAAAAAAA...5'
>>> turning bottom strand around - 5' ...AAAAAAACATGTC | {
"domain": "biology.stackexchange",
"id": 1144,
"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": "rna-sequencing, sequence-analysis",
"url": null
} |
java, optimization, game
private final List<Entity> entities = new ArrayList<> ();
private final List<Drawable> drawables = new ArrayList<> ();
/**
* Window Constants
*/
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private static final String TITLE = "Test Game";
/**
* Logging
*/
private final FPSViewer fpsViewer = new FPSViewer ();
// there are more here, stripped for this review
/**
* Data Contaienrs
*/
// there are more here, stripped for this review
/**
* Main Function, instantiating Game
*/
public static void main() {
new Game ();
}
/**
* Game constructor, initailized by main ()
*/
public Game () {
// fps tracking
entities.add (fpsViewer);
drawables.add (fpsViewer);
Window window = new Window (WIDTH, HEIGHT, TITLE, this);
thread = new Thread (this);
thread.start ();
}
/**
* Game Loop
*/
public void run () {
while (isRunning) {
// get delta time
currentTime = System.nanoTime ();
deltaTime += (currentTime - lastLoopTime) / OPTIMAL_TIME;
lastLoopTime = currentTime;
while (deltaTime >= 1) {
update ();
deltaTime--;
}
// update the game
render ();
// reset if a second has passed
if (System.currentTimeMillis () - secondTimer > 1000) {
updatePerSecond ();
secondTimer += 1000;
}
}
}
/**
* Game Updates for all entities
*/
private void update () {
for (Entity e : entities) {
e.tick ();
}
}
private void updatePerSecond () {
for (Entity e : entities) {
e.second ();
}
}
/**
* Renders all graphics for all drawables
*/
private void render () {
BufferStrategy bufferstrategy = getBufferStrategy ();
if (bufferstrategy == null) {
createBufferStrategy (3);
return;
} | {
"domain": "codereview.stackexchange",
"id": 11016,
"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, optimization, game",
"url": null
} |
So for the volume element:
$dx\;dy\;dz=\det{\frac{\partial(x, y, z)}{\partial(\rho, \phi, \theta)}} d\rho\;d\theta\;d\phi = \rho^2 \sin\theta \; d\rho \; d\theta \; d\phi \;$
#### From cylindrical coordinates
${x}={r} \,\cos\theta$
${y}={r} \, \sin\theta$
${z}={h} \,$
$\frac{\partial(x, y, z)}{\partial(r, \theta, h)} = \begin{pmatrix} \cos\theta & -r\sin\theta & 0 \\ \sin\theta & r\cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix}$
So for the volume element:
$dx\;dy\;dz=\det{\frac{\partial(x, y, z)}{\partial(r, \theta, h)}} dr\;d\theta\;dh = {r}\; dr \; d\theta \; dh \;$
### To Spherical coordinates
#### From Cartesian coordinates | {
"domain": "wikipedia.org",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9904406020637528,
"lm_q1q2_score": 0.8210146502950978,
"lm_q2_score": 0.828938806208442,
"openwebmath_perplexity": 1032.7566102935496,
"openwebmath_score": 0.9637818336486816,
"tags": null,
"url": "http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations"
} |
newtonian-mechanics, classical-mechanics, reference-frames
Title: Does pseudo force induce friction on a body at rest? Suppose I am travelling in a non-inertial (accelerating) frame of reference and I observe a body at rest, will the body be experiencing a kinetic/static/limiting friction with respect to me ? A book is on the floor of a train which is accelerating relative to the ground.
The frame of reference is attached to the train (and the book).
Yes, there is a static frictional force on the book due to the floor to provide the force necessary to accelerate the book relative to the ground and the frictional force will be in the direction of the acceleration of the train.
If the train acceleration is even greater then there will come a time when there is a maximum static frictional force on the book due to the floor and the book will be on the point of moving relative to the floor.
Above such an acceleration of the train the book will be observed to accelerate backwards relative to the train with a kinetic frictional force acting on the book due to the train now acting in the same direction as the acceleration of the train.
The pseudo-force acting on the book will still be the same.
The frictional forces are there irrespective of where the observer is.
In other words both you on the train and your friend on the ground will "observe" the same frictional force.
In the example it is the normal reaction (a real force) which is responsible for the production of the frictional force.
For you, if you want to use Newton's laws whilst on the accelerating train, you have to also include a pseudo-force acting on the book so that when the book is not moving relative to you or the floor the static frictional force is equal and opposite to the pseudo-force.
Another way of looking at this is to say that the acceleration of free fall as measured on the train is now the vector sum of the acceleration of free fall on the Earth $\vec g$ and the acceleration of the train.
The normal reaction on the book of mass $m$ will still be the same $-m \vec g$ and so the frictional force will still be the same.
That pseudo force would also have to be included when the book is moving relative to the floor. | {
"domain": "physics.stackexchange",
"id": 34637,
"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, reference-frames",
"url": null
} |
be 0. Divide the both equations with a^2, they become a^2(b)<0?-->b<0?. Since 2) is b<0, it is yes and sufficient. Therefore, the answer is C. For cases where we need 2 more equations, such as original conditions with “2 variables”, or “3 variables and 1 equation”, or “4 variables and 2 equations”, we have 1 equation each in both 1) and 2). Therefore, there is 70% chance that C is the answer, while E has 25% chance. These two are the majority. In case of common mistake type 3,4, the answer may be from A, B or D but there is only 5% chance. Since C is most likely to be the answer using 1) and 2) separately according to DS definition (It saves us time). Obviously there may be cases where the answer is A, B, D or E. _________________ MathRevolution: Finish GMAT Quant Section with 10 minutes to spare The one-and-only World’s First Variable Approach for DS and IVY Approach for PS with ease, speed and accuracy. "Only$99 for 3 month Online Course" | {
"domain": "gmatclub.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9648551495568569,
"lm_q1q2_score": 0.8514150740443787,
"lm_q2_score": 0.88242786954645,
"openwebmath_perplexity": 4824.161179065251,
"openwebmath_score": 0.7549898624420166,
"tags": null,
"url": "https://gmatclub.com/forum/is-3-a-2-b-134754.html"
} |
haskell, monads
with monotyped mutable state:
data UrnState = UrnState { nextTag :: Key
, urns :: IntMap [Int] }
So urns urnState ! tag1 is the set of integer indices still in play for that urn, and the actual elements are available by looking up those indices in the labels urnRef map.
SPOILERS
A complete code example, which seems to work on your test case is:
{-# LANGUAGE DeriveFunctor, RoleAnnotations, RankNTypes #-}
import Data.List
import Control.Monad
import qualified Data.IntMap as IntMap
import Data.IntMap (Key, IntMap, (!))
data Urn s a = Urn { tag :: Key
, labels :: Int -> a }
type role Urn nominal representational
data UrnState = UrnState { nextTag :: Key
, urns :: IntMap [Int] }
newtype Draw s a = Draw { unDraw :: UrnState -> [(a, UrnState)] } deriving (Functor)
type role Draw nominal representational
instance Applicative (Draw s) where
pure x = Draw (\s -> [(x,s)])
(<*>) = ap
instance Monad (Draw s) where
Draw d >>= f = Draw $ \s -> do -- list monad
(a', s') <- d s
unDraw (f a') s'
evalDraw :: (forall s. Draw s a) -> [a]
evalDraw (Draw d) = map fst $ d $ UrnState 0 IntMap.empty | {
"domain": "codereview.stackexchange",
"id": 36954,
"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": "haskell, monads",
"url": null
} |
Update
About the question whether this argument can be extended to higher dimension, the answer is yes. Let's look at the 3-dimension $2 \le \alpha \le 3$ case first.
As one increases $\alpha$ beyond $2$, the three tetrahedron in first figure start overlap. As shown in second figure, the intersection of the three tetrahedra are now three even smaller tetrahedra of width/height/depth = $\alpha -2$.
Previous way to compute the "volume" of cube section below the plane $x + y + z = \alpha$ now subtract too much from this three even smaller tetrahedron. One need to add them back. As a result, the volume above the plane becomes:
\begin{align}&1 - \left( \frac16 \alpha^3 - 3(\frac16 (\alpha-1)^3 + 3(\frac16 (\alpha-2)^3 \right)\\ = & 1 - \frac16 \alpha^3 + \frac12 (\alpha-1)^3 - \frac12 (\alpha-2)^3\\ = & \frac{(3-\alpha)^3}{6} \end{align}
Let us switch to the $k$-dimension case. To compute the "volume" of the hypercube section above the hyperplane $x_1 + \ldots + x_k = \alpha$, the first step is to subtract the volume of a $k$-simplex of size $\alpha$ from 1. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9814534392852384,
"lm_q1q2_score": 0.8399780499029723,
"lm_q2_score": 0.8558511451289037,
"openwebmath_perplexity": 307.7834667011739,
"openwebmath_score": 0.8820827007293701,
"tags": null,
"url": "http://math.stackexchange.com/questions/454583/volume-of-cube-section-above-intersection-with-plane"
} |
# 3.3. Synthetic Regression Data¶ Open the notebook in Colab Open the notebook in Colab Open the notebook in Colab Open the notebook in SageMaker Studio Lab
Machine learning is all about extracting information from data. So you might wonder, what could we possibly learn from synthetic data? While we might not care intrinsically about the patterns that we ourselves baked into an artificial data generating model, such datasets are nevertheless useful for didactic purposes, helping us to evaluate the properties of our learning algorithms and to confirm that our implementations work as expected. For example, if we create data for which the correct parameters are known a priori, then we can verify that our model can in fact recover them.
%matplotlib inline
import random
import torch
from d2l import torch as d2l
%matplotlib inline
import random
from mxnet import gluon, np, npx
from d2l import mxnet as d2l
npx.set_np()
%matplotlib inline
import random
import tensorflow as tf
from d2l import tensorflow as d2l
## 3.3.1. Generating the Dataset¶
For this example, we will work low-dimensional for succinctness. The following code snippet generates 1000 examples with 2-dimensional features drawn from a standard normal distribution. The resulting design matrix $$\mathbf{X}$$ belongs to $$\mathbb{R}^{1000 \times 2}$$. We generate each label by applying a ground truth linear function, corrupted them via additive noise $$\epsilon$$, drawn independently and identically for each example:
(3.3.1)$\mathbf{y}= \mathbf{X} \mathbf{w} + b + \mathbf\epsilon.$ | {
"domain": "d2l.ai",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9802808730448281,
"lm_q1q2_score": 0.8190085351819145,
"lm_q2_score": 0.8354835411997897,
"openwebmath_perplexity": 4609.576472749244,
"openwebmath_score": 0.24987474083900452,
"tags": null,
"url": "http://en.d2l.ai/chapter_linear-regression/synthetic-regression-data.html"
} |
waves, electromagnetic-radiation
(Image Credit: https://www4.uwsp.edu/physastr/kmenning/Phys202/Lect16.html) | {
"domain": "physics.stackexchange",
"id": 90282,
"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": "waves, electromagnetic-radiation",
"url": null
} |
acoustics, notation, si-units, metrology
Pitch and loudness interact analogously to the way color and brightness interact (the threshold of hearing, ie, the quietest sound a human can perceive, depends on pitch), but timbre also interacts with both. A sound that carries multiple distinct pitches will sound louder than a sound with only one pitch at the same amplitude; the "fuzzier" and "noisier" the note, the louder it sounds, up to a point, although "pure" tones can also be quite piercing. And of course "noisier" sounds can't really be said to even have a pitch.
This is where the difference between color-mixing and timbre really shines (pun very much intended). Because all colors except the reddest of reds and the bluest of blues are perceived as mixed colors, even if they were originally pure, color mixing can be smoothed away to give a fairly consistent luminosity function, even for white light, the "noisiest" of light. (Heck, the candela used to be defined by the brightness of a certain black body, which by definition emits light that is as mixed as possible.)
But pure tones are perceptually distinct from mixed sounds, and timbre is, if anything, more exaggerated than frequency-mixing. A proper "sonosity function" would have to take into account pitch, loudness and timbre and all the messiness that comes with it; the fact that "noises" don't actually have a pitch, that many pitches played at once tend to be louder than if each were played separately, that timbre can't really be properly ordered, even in the way color can in two or three (or more) dimensions. | {
"domain": "physics.stackexchange",
"id": 49241,
"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": "acoustics, notation, si-units, metrology",
"url": null
} |
important tools like Gamma function, Even function,Odd function. Fourier transform cosine example further s blogs mathworks images steve 2009 f cos t in additions akshaysin github io images mpl basic fft moreovers upload wikimedia org wikipedia mons 6 61 fft time frequency view in additionee nmt edu wedeward ee342 sp99 ex le16 gif. The Fourier Transform It is well known that one of the basic assumptions when applying Fourier methods is that the oscillatory signal can be be decomposed into a bunch of sinusoidal signals. Fourier Transform of Common Inputs. Such a decomposition of periodic signals is called a Fourier series. ) Fourier integral theorem (without proof) - Fourier transform pair - Sine and Cosine transforms - Properties - Transforms of simple functions - Convolution theorem - Parseval’s identity. 5-Fourier Transform || Engineering Mathematics-3 || Important Fourier Sine and Fourier Cosine TR. Find the Fourier transform of the following signals: a) f1(t)=e −3 tsin(10t)u(t) b)f 1(t)=e 4 cos(10t)u(t) 2. discrete signals (review) – 2D • Filter Design • Computer Implementation Yao Wang, NYU-Poly EL5123: Fourier Transform 2. For a complex function f(x) which satisfies the condition that. First Fourier transform of sin function should be calculated,and to calculate this these properties will be needed first one is Duality, for any signal/function $\large x(t)$ if it's Fourier Transform is $\large X(w)$ then a. " The full name of the function is "sine cardinal," but it is commonly referred to by its abbreviation, "sinc. This page will describe how to determine the frequency domain representation of the. Derivatives Derivative Applications Limits Integrals Integral Applications Series ODE Laplace Transform Taylor/Maclaurin Series Fourier Series. These ideas are also one of the conceptual pillars within electrical engineering. Matrices Vectors. The Fourier Transform (FT) is a generalization to solve for non-periodic waves. Recall that eiiθ=+cos sinθ θ; thus, we are able to combine the sine and cosine components of the Fourier series into combined components of the. is a decreasing function. Fourier | {
"domain": "daisytale.it",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9942697539943961,
"lm_q1q2_score": 0.8773713269376618,
"lm_q2_score": 0.8824278556326344,
"openwebmath_perplexity": 844.5134176232584,
"openwebmath_score": 0.879318118095398,
"tags": null,
"url": "http://daisytale.it/qwtn/fourier-transform-of-cosine.html"
} |
This is made of two triangles of points, in the planes $x-y=z$ (marked X) and $x-y=z-n$ (marked x), which are separated by some distance. We'll first make the connections within the triangles, and then connect the triangles to each other.
To connect the bottom triangle, use $n-1$ extra points (marked A) to connect the base of the triangle in the plane $z=0$ to itself and to the points in the triangle with $z=1$. Then for $i = 2, ..., n-1$, use $\lceil (n-i-1)/2 \rceil$ points (marked O) to connect the points in the plane $z=i$ to each other and to the lower points in the triangle. These points have $y$ odd, and are just above an X in the layer below. | {
"domain": "mathoverflow.net",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9850429156022933,
"lm_q1q2_score": 0.8468056925523426,
"lm_q2_score": 0.8596637559030338,
"openwebmath_perplexity": 255.62116466416796,
"openwebmath_score": 0.7301827073097229,
"tags": null,
"url": "http://mathoverflow.net/questions/103882/minimal-blocking-objects-with-shadows-like-a-cube?sort=votes"
} |
Therefore \displaystyle \begin{align*} z = \ln{2} + \frac{\pi}{6} i \end{align*}
• Sep 17th 2012, 08:17 AM
Tala
Re: Complex equation
This might be a stupid question but I can't see how the argument is π/6 ?
• Sep 17th 2012, 08:20 AM
Tala
Re: Complex equation
I get it know:
arccos(√(3)/2) right ?
• Sep 17th 2012, 08:23 AM
Prove It
Re: Complex equation
Quote:
Originally Posted by Tala
This might be a stupid question but I can't see how the argument is π/6 ?
If the complex number is in the first quadrant, which it is, \displaystyle \begin{align*} \textrm{arg}\,(z) = \arctan{\left[ \frac{\textrm{Im}\,(z)}{\textrm{Re}\,(z)} \right]} \end{align*}.
• Sep 17th 2012, 08:26 AM
Tala
Re: Complex equation
Thank you so much for the quick and brilliant answers.
I really appreciate it.
Tak (it means thank you in danish).
• Sep 17th 2012, 08:41 AM
Plato
Re: Complex equation
Quote:
Originally Posted by Prove It
Therefore \displaystyle \begin{align*} z = \ln{2} + \frac{\pi}{6} i \end{align*}
It is worth noting that for each $k\in\mathbb{Z},~\ln (2) + i\left( {\frac{\pi }{6} + 2k\pi } \right)$ is also a solution. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9702399077750858,
"lm_q1q2_score": 0.8167728306515895,
"lm_q2_score": 0.8418256393148982,
"openwebmath_perplexity": 3530.7207974507664,
"openwebmath_score": 1.000003695487976,
"tags": null,
"url": "http://mathhelpforum.com/algebra/203606-complex-equation-print.html"
} |
nlp, named-entity-recognition
You can see that that I have the entity tag and the part of speech tag in the word. When I parse this dataset for training, I also add the IOB tags (Inside, Outside, and Beginning)
[(('Claxton', 'NNP\n'), 'B-PLAYER'),
(('hunting', 'VBG\n'), 'O'),
(('first', 'RB\n'), 'O'),
(('major', 'JJ\n'), 'O'),
(('medal', 'NNS\n'), 'O'),
(('.', '.\n'), 'O'),
(('British', 'JJ\n'), 'O'),
(('hurdler', 'NN\n'), 'O'),
(('Sarah', 'NNP\n'), 'B-PLAYER'),
(('Claxton', 'NNP\n'), 'I-PLAYER')......]
Then I just used the ClassifierBasedTagger(There are other taggers too). I can't find the source but I used this code:
class NamedEntityChunker(ChunkParserI):
def __init__(self, train_sents, **kwargs):
assert isinstance(train_sents, Iterable), 'The training set should be an Iterable'
self.feature_detector = features
self.tagger = ClassifierBasedTagger(
train = train_sents,
feature_detector = features,
**kwargs)
def parse(self, tagged_sents):
chunks = self.tagger.tag(tagged_sents)
iob_triplets = [(w, t, c) for ((w, t), c) in chunks]
return conlltags2tree(iob_triplets) | {
"domain": "datascience.stackexchange",
"id": 3713,
"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": "nlp, named-entity-recognition",
"url": null
} |
transform, fourier
Title: Fourier Transform Time Scaling I edited the initial question to make it general and thus applicable in more situations.
If the Fourier Transform of $x(t^2)$ is some function of $\omega^2$. Then what is the Fourier Transform of $x(bt^2)$, for $b>0$?
Is it $\dfrac{1}{b}$ times a function of $\left(\dfrac{\omega}{b}\right)^2$, or $\left(\dfrac{1}{\sqrt{b}}\right)$ times a function of $\left( \dfrac{\omega}{\sqrt{b}} \right)^2$, or neither?
Thank you for your time. Let $y(t) = x(t^2)$, and $a$ be such that:
$$
\begin{align}
y(at)
&= x((at)^2) \\
&= x(a^2t^2) \\
&= x(bt^2)
\end{align}
$$
In other words, $a^2 = b$.
The Fourier Transform time-scaling property states that given the Fourier Transform pair:
$$
\begin{align}
y(t) \leftrightarrow Y(w)
\end{align}
$$
and $a>0$, we have the relation:
$$
\begin{align}
y(at) &\leftrightarrow \frac{1}{a}Y(\frac{w}{a})
\end{align}
$$
Thus,
$$
\begin{align}
x(bt^2) &\leftrightarrow \frac{1}{a}Y(\frac{w}{a}) \\
&\leftrightarrow \frac{1}{\sqrt{b}}Y(\frac{w}{\sqrt{b}})
\end{align}
$$
Now, if we define
$$
\begin{align}
Y(w) = G(w^2)
\end{align}
$$
Then,
$$
\begin{align} | {
"domain": "dsp.stackexchange",
"id": 1844,
"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": "transform, fourier",
"url": null
} |
biochemistry, botany
Title: Ripening bananas artificially: What is the biological theory behind? I am a resident of the tropical island of Sri Lanka, and we have a strange traditional method to ripen our banana harvest quickly.
What we do is this: We dig a pit in earth that is enough to put the whole banana cluster in. Then, after safely laying the bananas in the pit, we cover up the pit with a sheet such that only a small hole from a side remains: visualize a small 3-4 inch door to the pit.
After that, we light a fire with semi-dry leaves just outside the pit's door. (Semi-dry leaves are used to get as much smoke as possible. Dry leaves do not give that much smoke, because they completely oxidize quickly). And the smoke is sent through the door by blowing it with the aid of a bamboo.
This sends a good amount of smoke and warms the inside of the pit considerably. And by experience I can tell you that this makes the bananas to ripen really quickly. I have done a controlled experiment where half of the cluster was not put into the pit. Bananas in the pit ripen overnight and the control sample took days to ripen.
Can anybody explain what are the bio-mechanisms that are working here? Ripening of bananas (and other fruits) is induced by acetylene and ethylene (Ethyne and Ethene) (see reference 1), which acts as a hormone and induces the ripening process. The incomplete combustion of the leaves produces ethylene, additionally the warmth of the process will help the enzymes as well. There is even a paper about this technique (although it is unfortunately not accessible), see reference 2 for more information. Smoking Chambers are routinely used in this process, see reference 3 and 4.
References:
Role of Ethylene in Fruit Ripening
Effects of smoking on some physiological changes in bananas.
Fruit Ripening
Technology for ripening fruits as important as marketing them | {
"domain": "biology.stackexchange",
"id": 3024,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "biochemistry, botany",
"url": null
} |
robot-state-publisher
Title: Combining JointState messages from several topics
Hello everyone,
I am using ptu46 driver. It publishes pan and tilt joints to the /ptu/state topic using sensor_msgs/JointState. There are other nodes in my system that publish joint states to /joint_states topic. I want robot_state_publisher to listen to both /joint_states and /ptu/state topics and publish a transform tree. The reason I don't want the PTU driver to publish to /joint_states directly is that there is an action server node that listens to /ptu/state and allows controlling the PTU. Is there a way to get around this problem?
Originally posted by aecins on ROS Answers with karma: 113 on 2012-04-16
Post score: 1
Ok, I have found a solution. You can aggregate JointState messages from several topics into a single /joint_states topic using the source list parameter of joint_state_publisher. You have to make sure that your urdf model has the joint names corresponding to those published in your JointState sources.
Originally posted by aecins with karma: 113 on 2012-04-17
This answer was ACCEPTED on the original site
Post score: 4 | {
"domain": "robotics.stackexchange",
"id": 8999,
"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": "robot-state-publisher",
"url": null
} |
scala, validation
val tryTupledBoth1 = Try(StreetSecondary.tupled(("Upper", Some("331"))))
val tryTupledInvalidDesignator = Try(StreetSecondary.tupled(("Upper!", None)))
val tryTupledInvalidBoth1 = Try(StreetSecondary.tupled(("Upper!", Some("331"))))
val tryTupledInvalidBoth2 = Try(StreetSecondary.tupled(("Upper", Some(" 331"))))
val tryTupledInvalidBoth3 = Try(StreetSecondary.tupled(("Upper!", Some(" 331"))))
val tryTupledBoth2 = Try(StreetSecondary.tupled(("Ste", Some("100"))))
//
val tryApplyTupleDesignator2 = Try(StreetSecondary(("Upper", None)))
val tryApplyTupleBoth1 = Try(StreetSecondary(("Upper", Some("331"))))
val tryApplyTupleInvalidDesignator = Try(StreetSecondary(("Upper!", None)))
val tryApplyTupleInvalidBoth1 = Try(StreetSecondary(("Upper!", Some("331"))))
val tryApplyTupleInvalidBoth2 = Try(StreetSecondary(("Upper", Some(" 331"))))
val tryApplyTupleInvalidBoth3 = Try(StreetSecondary(("Upper!", Some(" 331"))))
val tryApplyTupleBoth2 = Try(StreetSecondary(("Ste", Some("100"))))
//
val tryValidatedFactoryTupleDesignator2 = StreetSecondary.tryValidatedFactory(("Upper", None)).map(_.apply()) | {
"domain": "codereview.stackexchange",
"id": 14931,
"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": "scala, validation",
"url": null
} |
algorithms, permutations, stacks
A few observations are immediately apparent:
The maximum number of operations needed is N-1 for a permuation of
size N.
There are more optimal sequences starting with 3 than with 2,
and more with 2 than with 1.
There is a regular pattern to the sequences starting in 1 or 3
The longer sequences contain the shorter ones to the left hand side. In other words if 322 appears then so will 32 and 3.
There is a unique optimal sequence for each permuation
The pattern seems to be the following for those starting with 3 for example:
3(123)(23) - where the brackets indicate a choice
or for 1
1(23)3
But the pattern is not so obvious for those starting with 2.
Still, all that doesn't help in finding the actual sequence for a permutation. | {
"domain": "cs.stackexchange",
"id": 15104,
"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": "algorithms, permutations, stacks",
"url": null
} |
experimental-physics, home-experiment
Title: Is this kids experiment a legitimate way to show that air has mass? Consider the experiment in this link.
The experiment includes using a ruler as a lever, with an inflated balloon on one side and a balloon which is not inflated on the other.
The aim of the experiment is to show that air has mass.
I have seen many kids performing similar experiments.
But, if the air pressure inside the balloon is equal to that outside, then the buoyant force will cancel out the weight of the air inside the balloon, won't it? I can think of at least four things going on in this experiment that need pointing out:
When you inflate a balloon by mouth, the air is warm: this makes the air inside the inflated balloon slightly lighter than the air it displaced
The air inside the balloon has 100% relative humidity at 37C, and condensation will quickly form on the inside of the balloon as the air inside cools down.
The air inside the balloon contains carbon dioxide, which has higher density than room air (molecular mass of 12+16+16 = 44 amu, vs oxygen at 32 amu and nitrogen at 28 amu - ignoring small isotopic effects, and ignoring Argon).
The pressure inside the balloon is larger than outside - this increases the density
So how large are each of these effects? | {
"domain": "physics.stackexchange",
"id": 18559,
"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": "experimental-physics, home-experiment",
"url": null
} |
general-relativity, special-relativity, spacetime, differential-geometry, topology
Again, there are different ways of actually defining this ingredients, so I leave it a bit hand waving. Now regard that a affine space $A$ modelled by a $m$-dimensional real vector space $V$ inherits a differentable structure from $V$. For $A$ with this smooth structure there is a isomorphism of vector spaces $T_pA\cong V$ for all $p\in A$ and a Minkowski metric $\eta:V\times V\rightarrow\mathbb{R}$ can by pushed to a globally flat pseudo-Riemannian metric tensor field on $A$ as manifold. Thus, the differential geometric describtion includes the affine one. On the differential geometric side you could define a Minkowski spacetime as globally flat spacetime endowed with a free and transitive action of the translation group $(\mathbb{R}^m,+)$. However, the later is precisely the definition of an affine space. So These definitions can be considered equal. However, in application an affine space seems to be more handy and Things get even better when passing to the vector space describtion by choosing a base point $\vec{0}\in A$.
So we have seen that the differention geomentric, the affine and the vector space definition of Minkowski spacetime all describe the "same object" to some extend. However, what exact definition you choose depends on what you want to use it for and on your preference (I clearly prefere the manifold). This is why different authors choose different paths. In the end, a spacetime modelled by an affine space corresponds to a specific type of spacetimes modelled by differential manifolds. However, the set of differential manifolds is much larger and there are a lot of spacetimes that cannot be modelled by an affine space (at least not without adding additional structure).
I hope this can help you finding your way through general relativity! Cheers! | {
"domain": "physics.stackexchange",
"id": 66545,
"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, special-relativity, spacetime, differential-geometry, topology",
"url": null
} |
php, object-oriented
$stmt->free_result();
$stmt->close();
return $_result;
}
$obj = new TopVehicles(); // should be TopVehicles, shouldn't it?
$_TopCars = $obj->getTop('car');
$_TopVehicles = $obj->getTop('bicycle');
UPDATE: Without seeing the final code a code review is rather hard. It's true that you can't bind column names in a prepared statement. But what you could do is to manipulate the SQL string first. So here is a way how to accomplish that:
private $sql = 'SELECT %s FROM %s WHERE type = ? ORDER BY %s limit ?';
public function getTop($table, array $columns, array $orderByColumns, $type, $amount) {
$sql = sprintf($this->sql, implode($columns, ', '), $table, implode($orderByColumns, ', '));
$stmt = $this->mysqli->prepare($sql);
$stmt->bind_param("si", $type, $amount);
...
$_TopCars = $obj->getTop('vehicles', array('model', 'price'), array('price DESC', 'model ASC'), 'car', 10); | {
"domain": "codereview.stackexchange",
"id": 8053,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "php, object-oriented",
"url": null
} |
Hints for Exercise 2.E
Since the real line $\mathbb{R}$ is homeomorphic to the open interval $(0,1)$, $\mathbb{R}^\omega$ is homeomorphic to $(0,1)^\omega$. Show that $(0,1)^\omega$ is not $\sigma$-compact.
$\text{ }$
$\text{ }$
$\text{ }$
$\text{ }$
$\text{ }$
$\text{ }$
Further Hints for Exercise 2.A
The hints here focus on the example $\mathbb{R}^c$.
Let $I=[0,1]$. Let $\omega$ be the first infinite ordinal. For convenience, consider $\omega$ the set $\{ 0,1,2,3,\cdots \}$, the set of all non-negative integers. Since $\omega^I$ is a closed subset of $\mathbb{R}^I$, any closed and discrete subset of $\omega^I$ is a closed and discrete subset of $\mathbb{R}^I$. The task at hand is to find a closed and discrete subset of $Y=\omega^I$. To this end, we define $W=\{W_x: x \in I \}$ after setting up background information.
For each $t \in I$, choose a sequence $O_{t,1},O_{t,2},O_{t,3},\cdots$ of open intervals (in the usual topology of $I$) such that
• $\{ t \}=\bigcap_{j=1}^\infty O_{t,j}$,
• $\overline{O_{t,j+1}} \subset O_{t,j}$ for each $j$ (the closure is in the usual topology of $I$). | {
"domain": "wordpress.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9863631631151012,
"lm_q1q2_score": 0.8460708576709252,
"lm_q2_score": 0.8577681013541611,
"openwebmath_perplexity": 136.46652973402306,
"openwebmath_score": 0.993003785610199,
"tags": null,
"url": "https://dantopology.wordpress.com/tag/topology/"
} |
java, console, calculator, finance
taxableIncome <= hohFiler[5].maxSalary //$432,200
)
{
HeadOfHouseFilers.TierFive();
}
//TierSix()
else if (
taxableIncome >= hohFiler[5].minSalary && //$405,101
taxableIncome <= hohFiler[5].maxSalary && //$432,200
taxableIncome > hohFiler[6].minSalary //$432,201
)
{
HeadOfHouseFilers.TierSix();
}
//TierSeven()
else if (
taxableIncome >= hohFiler[6].minSalary && //$432,201
taxableIncome <= hohFiler[6].maxSalary //Double.MAX_VALUE
)
{
HeadOfHouseFilers.TierSeven();
}
break; | {
"domain": "codereview.stackexchange",
"id": 24081,
"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, console, calculator, finance",
"url": null
} |
Because cosine is concave on the interval $[0,\pi/2]$, we have $$\cos(p\theta)=\cos(p\theta+(1-p)0)\geq p\cos(\theta)+(1-p)\cos(0)=p\cos(\theta)+(1-p).$$ So our desired inequality follows if we can prove that $$\cos^p(\theta)\leq p\cos(\theta)+(1-p).\tag{*}$$ Clearly, (*) holds if $\theta=\frac{\pi}{2}$ (the LHS is $0$ while the RHS is nonnegative), so assume $\theta<\frac{\pi}{2}$. This assumption means $\cos(\theta)>0$ so that $\cos(\theta)-1>-1$, allowing us to apply Bernoulli's inequality: $$\cos^p(\theta)=[1+(\cos(\theta)-1)]^p\leq 1+p(\cos(\theta)-1)=p\cos(\theta)+(1-p).$$ This completes our proof.
• Didn't know Kim Jong Un is on math.SE! Please don't kill us sir, we are sorry! Sep 3, 2014 at 8:32 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9854964177527898,
"lm_q1q2_score": 0.8471955483710836,
"lm_q2_score": 0.8596637523076225,
"openwebmath_perplexity": 253.47677491083076,
"openwebmath_score": 0.9386752247810364,
"tags": null,
"url": "https://math.stackexchange.com/questions/917920/proof-cosp-theta-le-cosp-theta"
} |
ros, package, raspberrypi, rqt
Originally posted by po1 with karma: 411 on 2013-06-12
This answer was ACCEPTED on the original site
Post score: 3
Original comments
Comment by AlphaSierra on 2013-06-13:
Sounds like a plan, I'll try working through those. I'm still new to ROS, and just went with fuerte because that's what the tutorial covered.I had to build ROS from source while following those instructions, are those tools not included in those source repositories?
Comment by AlphaSierra on 2013-06-14:
So I got stuff to download, so that's that issue solved. Although the pcl is missing from following the instructions to install from source.
Comment by po1 on 2013-06-14:
Have you tried apt-get install ros-groovy-pcl? | {
"domain": "robotics.stackexchange",
"id": 14543,
"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, package, raspberrypi, rqt",
"url": null
} |
complexity-theory, satisfiability, p-vs-np
Title: If one shows that UNIQUE k-SAT is in P, does it imply P=NP? Valiant & Vazirani proved SAT is reducible to UNIQUE SAT under randomized probabilistic reductions in polynomial time. Calabro et al. showed that UNIQUE k-SAT is as hard as k-SAT. Now the question is, if someone shows that UNIQUE k-SAT is in P, does it imply P=NP?
References
L. G. Valiant and V. V. Vazirani, "NP is as easy as detecting unique solutions." Theoretical Computer Science 47:85–93, 1986. (PDF on ScienceDirect.)
C. Calabro, R. Impagliazzo, V. Kabanets and R. Paturi, "The Complexity of Unique k-SAT: An Isolation Lemma for k-CNFs". Journal of Computer and System Sciences 74(3):386–393, 2008. (PDF at ACM Digital Library; free PDF.) This is still an open question; UP is not known to be equivalent to NP. In the paper "NP Might Not Be As Easy As Detecting Unique Solutions," Beigel, Burhman and Fortnow construct an oracle under which P contains UP but P is still not equivalent to NP. | {
"domain": "cs.stackexchange",
"id": 4648,
"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": "complexity-theory, satisfiability, p-vs-np",
"url": null
} |
java, recursion
public static void main(final String[] args) {
String s = "ccc";
for (int i = 0; i < 1500; i++) {
s += "a";
String s2 = doubly(s, 'a');
System.out.println("Expected: " + (i + 1) + ", actual: " + s2.substring(s2.length() - (int) Math.log10(i + 1) - 1));
if (!String.valueOf(i + 1)
.equals(s2.substring(s2.length() - (int) Math.log10(i + 1) - 1))) {
System.out.println("ERROR");
return;
}
}
}
} typo
Wow, you really like that
log10
expression. I see several occurrences of it.
Might be worth packaging up in a helper function.
Which you could unit test.
I don't understand this expression at all:
int log = (int) Math.log10(lenDiff - Math.log(lenDiff + 1) + 1) + 1;
You say the code works correctly,
but how is natural log relevant?
Or is that just a typo bug?
Recall that examining length of Integer.toString(n) is another way
to learn its base-ten logarithm.
(My initial theory was the bug was due to FP rounding issues,
until I saw natural log working its way into the mix.
Or perhaps a string length OBOB related to 99 -> 100 or 999 -> 1000.)
recursive function that iterates
You embrace recursion fully with this test:
if (c == s.charAt(0)) { | {
"domain": "codereview.stackexchange",
"id": 45203,
"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, recursion",
"url": null
} |
ros
Title: rospack error(libboost_system_mt-1.48.so)
Hi, I'm trying to cross-compile Nao V4.
But when I use rospack command, following error message comes out.
rospack: error while loading shared libraries: libboost_system-mt-1_48.so.1.48.0: cannot open shared object file: No such file or directory
I tried installing library files by "$ sudo apt-get install libboost-system libboost-dev etc. But nothing has been solved.
In fact, I found out this error when I tried to source $TARGETDIR/workspace_nao/setup.bash, which contained "rospack" command. This content came from tutorial. When I tried to source setup.bash, following error message came out.
rospack could not be found, you cannot have rosbash features until you bootstrap ros
So I think that it is the error coming from rospack error related with library(libboost?).
Is there Anyone who knows the solution?
Thanks in advance! :)
Originally posted by Oppenheim on ROS Answers with karma: 41 on 2013-07-01
Post score: 0
Original comments
Comment by Oppenheim on 2013-07-02:
Actually, I'm using ubuntu 10.04 now, but I'm not sure why libboost1.48 is needed..
If you have switched Ubuntu versions you need to make sure to clean all build artifacts. Likely you have either a CMakeCache or simply libraries which were linked on the other OS and now cannot be loaded because there's a different version of boost installed.
Originally posted by tfoote with karma: 58457 on 2013-08-12
This answer was ACCEPTED on the original site
Post score: 0 | {
"domain": "robotics.stackexchange",
"id": 14779,
"lm_label": null,
"lm_name": null,
"lm_q1_score": null,
"lm_q1q2_score": null,
"lm_q2_score": null,
"openwebmath_perplexity": null,
"openwebmath_score": null,
"tags": "ros",
"url": null
} |
rviz, rqt
Originally posted by 130s with karma: 10937 on 2017-03-08
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by Azhar on 2017-03-09:
Thank you for your response! :)
Will try to do it!
I wanted to create a GUI with everything on one screen. I was just thinking what could be the reason, and how to improve it.
Any idea of how to handle high amount of data so that it will flow with low latency?
Comment by Azhar on 2017-03-13:
Hi, I tried it, RVIZ standalone and it still freezes! :(
Can anyone give me a heads up of what to check? Network? laptop configuration?
Comment by Azhar on 2017-03-22:
it froze again when i open image_view in rqt too. However, when i open both the map and image(theora) from Rviz it works fine. :)
Do take note that i am using to view all this from a slave machine.
Currently, when i try to visualize the Laserscans in RVIZ alone, it freezes. Debugging in progess! | {
"domain": "robotics.stackexchange",
"id": 27240,
"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": "rviz, rqt",
"url": null
} |
# Sequences of Real Numbers An Introduction. What is a sequence? Informally A sequence is an infinite list. In this class we will consider only sequences.
## Presentation on theme: "Sequences of Real Numbers An Introduction. What is a sequence? Informally A sequence is an infinite list. In this class we will consider only sequences."— Presentation transcript:
Sequences of Real Numbers An Introduction
What is a sequence? Informally A sequence is an infinite list. In this class we will consider only sequences of real numbers, but we could think about sequences of sets, or points in the plane, or any other sorts of objects.
What about sequences? The entries in the list don’t have to be different. The entries in the list don’t have to follow any particular pattern.
What about sequences? The entries in the list don’t have to be different. The entries in the list don’t have to follow any particular pattern. Though, in practice, we are often interested in sequences that do have some sort of pattern or regularity!
What is a sequence of real numbers? More formally... A sequence of real numbers is a function in which the inputs are positive integers and the outputs are real numbers. Or Perhaps it’s easier to think of it this way…
What is a sequence of real numbers? More formally... A sequence of real numbers is a function in which the inputs are positive integers and the outputs are real numbers. The input gives the position in the sequence, and the output gives its value.
Graphing Sequences Since sequences of real numbers are functions from the positive integers to the real numbers, we can plot them, just as we plot other functions... There’s a “y” value for every positive integer.
Graphing Sequences Since sequences of real numbers are functions from the positive integers to the real numbers, we can plot them, just as we plot other functions... There’s a “y” value for every positive integer.
Graphing Sequences Since sequences of real numbers are functions from the positive integers to the real numbers, we can plot them, just as we plot other functions... There’s a “y” value for every positive integer.
Terminology and notation We write a “general” sequence as Individual entries in the list are called the terms of the sequence. For instance, The “generic” term we call a k or a n, or something. | {
"domain": "slideplayer.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9811668723123673,
"lm_q1q2_score": 0.8218449675644351,
"lm_q2_score": 0.8376199714402812,
"openwebmath_perplexity": 409.7965843172639,
"openwebmath_score": 0.8539257645606995,
"tags": null,
"url": "http://slideplayer.com/slide/4286686/"
} |
quantum-mechanics, quantum-information, quantum-computer
I'm not an experimentalist, so my knowledge is limited, but I have some overview about ion traps and superconducting qubit proposals. The first is probably the furthest towards universal quantum computation and the second maybe the most promising (at least, there is a flurry of activity).
Before going into detail about the problem, let me mention that the D-Wave Two is probably the only commercial "quantum" computer out there. It doesn't claim to be universal, it maybe (or maybe not) does some "quantum computation" (not based on the circuit model, though), but it doesn't give any speedups. However, it gained a lot of attention as the first working computer - and still, its costs are far above anything you'll want to spend and it's also pretty big. This might already tell you, that it might be difficult.
Let's first discuss one of the major theoretical problems: Decoherence. You will never be able to fully isolate your qubits, so the state will decay - and quickly. In order to still do gates and computations, you'll need a) stable Qubits and b) Quantum Error Correction. If you really want to "play around with a gate" in the sense that you want to do (limited) computing and not just experimental control of single atoms/ions, etc. you'll need logical qubits, not just physical qubits. A logical qubit is a number of physical qubits where the state of one qubit is distributed between the physical qubits and error correction makes the time coherence time long enough to work with. In order to obtain a logical qubit, unless you have topological memories, you normally need to be able to implement the Clifford group (Paulis+Hadamard+CNOT) on aribtrary physical qubits - see the stabilizer codes for more details.
Then, you need not only gates, but fault tolerant gates, which is an additional requirement. Basically, if you tried to perform a computation with currently available physical qubits and gates, after a few steps (where "a few" means maybe a dozen or so) the outcome is completely random. That's bad for playing with circuits. | {
"domain": "physics.stackexchange",
"id": 17728,
"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, quantum-computer",
"url": null
} |
vectors, refraction, geometric-optics
\tag{10}\label{10}
\end{equation}
Since the angle between $\;\mathbf{n},\mathbf{t}\;$ is less than $\;\pi/2\;$ we keep the plus sign in \eqref{10} and \eqref{07} yields finally
\begin{equation}
\mathbf{t}=\sqrt{1-\mu^2\left[1-\left(\mathbf{n}\boldsymbol{\cdot}\mathbf{i}\right)^2\right]}\,\mathbf{n}+\mu\left[\mathbf{i}-\left(\mathbf{n}\boldsymbol{\cdot}\mathbf{i}\right)\mathbf{n}\vphantom{\left(\right)^2}\right]
\tag{11}\label{11}
\end{equation} | {
"domain": "physics.stackexchange",
"id": 94935,
"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": "vectors, refraction, geometric-optics",
"url": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.