sql server – What does Nested Loops join operator has to do with a Scalar?

As far as I understand the docs, the Nested Loops operator is a join operator, i.e., it requires two tables as input.

If that’s correct, then why the Nested Loops operator is used with a Scalar input?

For example, take the following query (from Paul White’s website) and its execution plan.
You can see that the inputs for the Nested Loops operator are (1) a Scalar, and (2) a table (the result of the Index Seek).

I know that a scalar can’t be joined with a table, then what that actually means? What’s actually being joined?

USE AdventureWorks2019;
DECLARE @Like nvarchar(50) = N'D%';
SELECT p.(Name)
FROM   Production.Product AS p
WHERE  p.(Name) LIKE @Like;

enter image description here

BTW, I presume that it’s a pretty basic question, but I couldn’t find a good resource that goes through such basics methodologically, so a recommendation would be much appreciated.

Is my custom operator for sorting in python correct?

  1. Python has a style guide PEP 8 which explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

    For instance shortesJobFirst(id, arrival, burst) appears (it is hard to know) to be a function, but functions in python are – according to PEP 8 – written in lowercase seperated by underscores. E.g shortesJobFirst -> shortest_job_first. However if shortesJobFirst is a class, you are good =)

  2. You should use the if __name__ == "__main__": module in your answer.

  3. Your naming practices are somewhat lacking, what does Pair mean? A better name would perhaps have been Job.

  4. It is tough suggesting better names, as you lack a short explanation of what your code does. This is done by using docstrings

  5. The printing could be improved by using pythons awesome formating options

  6. Why use a class at all when a namedtuple() can do the same job?

  7. Why implement a sorting function when you can use attrgetter from operators?

  8. Use a basic linter for your code, this ensures you have correct spacings and indents. As mentioned it is common to have two spaces between classes and functions.

from collections import namedtuple
from operator import attrgetter


def sort_jobs_by_attributes(jobs, attributes):
    """
    This functions sorts the jobs (namedtuples) according to the attribute_lst. If

             attribute_lst = ("arrival_time", "burst_time", "id")

    We then first sort by arrival_time, on tie we
                  sort by burst_time, on tie we
                  sort by id
    """
    for attribute in reversed(attributes):
        jobs.sort(key=attrgetter(attribute))
    return jobs


JOB_ATTRIBUTES = ("arrival_time", "burst_time", "id")
Job = namedtuple("Job", JOB_ATTRIBUTES)


if __name__ == "__main__":

    job_ids = (1, 2, 3, 4)
    arrival_times = (4, 1, 4, 1)
    burst_times = (3, 4, 2, 4)

    jobs = (
        Job(*job_details) for job_details in zip(arrival_times, burst_times, job_ids)
    )

    sort_jobs_by_attributes(jobs, JOB_ATTRIBUTES)

    for job in jobs:
        print(job)

Side note: you don’t need to provide any key function. The default behavior of tuples (and by extension, namedtuples, since they are a subclass) is to sort element-wise. That means that the first elements of the two tuples are compared, and if there’s a tie then the second elements are compared, and so on. Since the name is the first element, all you need is sorted(jobs).

from collections import namedtuple

JOB_ATTRIBUTES = ("arrival_time", "burst_time", "id")
Job = namedtuple("Job", JOB_ATTRIBUTES)


if __name__ == "__main__":

    job_ids = (1, 2, 3, 4)
    arrival_times = (4, 1, 4, 1)
    burst_times = (3, 4, 2, 4)

    jobs = sorted(
        Job(*job_details) for job_details in zip(arrival_times, burst_times, job_ids)
    )

    for job in jobs:
        print(job)

Note that implicitly sorting the tuple can be a bit spooky if you later decide the change around the order. In addition to make it harder to see exactly what is being sorted. I will leave it up to you to make the final call on which version is the best.

linear algebra – Singular value decompostion and operator norm

Suppose that for $A$ $in mathbb{R}^{mtimes n}$ the singular value decomposition of A is $UBV^T$ where $U$ $in mathbb{R}^{mtimes t}$ and $B$ $in mathbb{R}^{ttimes t}$ and $V$ $in mathbb{R}^{ntimes t}$. If $W$ is a matrix in $in mathbb{R}^{mtimes n}$ with $||W||_{op}$ $leq 1$, $U^{T}W =0$ and $WV =0$ then, we have $||UV^{T}+W||_{op} leq 1$.

I consider $U_1B_1V_1$, the singular value decomposition of $UV^{T}+W$ and I found two relation:

$UU^T +WW^T = U_1B_1^2U_1^T$ and $VV^T +W^TW = V_1B_1^2V_1^T$. But I think these relations just gives me $||UV^{T}+W||_{op} leq sqrt{2}$.

boundary value problem – Green’s function for a differential operator

I am having a hard time with the following problem:

$$
ymapsto Ly=-frac{d}{dx}(xfrac{d}{dx}y)
$$

with boundary conditions $y(1)=0$ and $y^prime(2)=0$.

There are 2 things to do here:

  1. I have to determine a fundamental matrix for the differential equation $Ly=0$.
  2. I have to determine the green’s function of L for these given boundary conditions and the intervall (1,2).

I have exam in this subject and our professor is bringing stuff to the exam, which we did not have done in the lectures. I would be very grateful if someone could help me out.

analysis – Max norm and uniformly continuous operator

Let $E = C(a,b)$ and consider the max norm. I must prove that the operator $T:(E,|f|_0) rightarrow (E,|f|_0)$ defined by $$T(f)(x) = int_a^x f(t) ,dt$$ is uniformly continuous. My attempt was to show that this is a contraction. I’ve tryed to do something like

begin{equation}
begin{split}
|T(f)(x)-T(f)(y)| &= left|int_a^x f(t),dt – int_a^y f(t) ,dt right| \
& leq int_y^x |f(t)| , dt \
& leq max_{xin(a,b)} f(x) |x-y|
end{split}
end{equation}

But I don’t know if this is right. Any help is welcome!

javascript – Comma Operator, Arrow Functions and Single Line Auto Returns

I am a self-taught hobby programmer and want to improve. I spent the morning reading as much hints and tips of the trade and have read about functional programming and array functions in javascript. I have never really used array functions before except things like indexOf. This looks fun, so I have tried (and succeeded) in rewriting one of my functions that produces a random string of alpha-numeric characters in the form:

A4b-c56-7de

Ie, 9 upper and lower letters/numbers, separated in groups of 3 with a ‘-‘ in between. However, since I need this for other generic stuff later on, the function accepts as arguments, the number of letters (eg 9) and the number in the group (eg 3).

I am reasonably happy, but not quite. I would also like any constructive criticism, so I can become better.

I generate an array of the permissible characters, excluding ‘o’, ‘O’ and ‘0’, because the user has to type this code in and these letters are hard to determine on a phone.

Here is how I generate my array of permissible characters:

// (0-9a-zA-Z) but excluding o, 0 and O that look the same
var myChars = (... Array(10+2*26))
            .map((_, idx) => {
                var bl, ret;
                return (bl = idx >= 36, ret = (idx - (bl ? 26 : 0)).toString(36), bl && (ret = ret.toUpperCase()), ret);
            })
            .filter(val => !("o","O","0").includes(val));

I do not like the map here. I wanted the auto-return, ie where there is only one statement, so you do not need to write the return. I tried to use the comma operator I had read about this morning. The last thing will be the thing returned. However, you cannot appear to declare variables, bl and ret within the comma operator. That means you have to write a second line, which means you do not get the auto return. :(.

You can obviously introduce a second map into the code to do the upper case. Is this good, is this bad? As a hobby programmer, I do not have anyone to say which is better.

I could do:

// (0-9a-zA-Z) but excluding o, 0 and O that look the same
var myChars = (... Array(10+2*26))
            .map((_, idx) => (idx - (idx >= 36 ? 26 : 0)).toString(36))
            .map((val, idx) => idx >= 36 ? val.toUpperCase() : val)
            .filter(val => !("o","O","0").includes(val));

This obviously looks a million times nicer and is easy for a third-party to read and understand. But is it as fast, is it better code?

As for the random string generator, I found that a lot easier to write, again using the comma operator I discovered this morning so I can get the auto return:

function CreateMyRandomId(numLetters, numInGroup) {
    return (... Array(numLetters))
            .map(() => myChars((Math.random() * myChars.length) | 0))
            .reduce((endArr, curVal, curIdx /*, arr not needed*/) =>
                // Left most thing in (, ) is what is returned
                (endArr((curIdx / numInGroup) | 0).push(curVal), endArr),
            //(... Array(Math.ceil(numLetters / numInGroup))).fill(()))
            (... Array(Math.ceil(numLetters / numInGroup))).map(() => ()))
            .map(curMiniArr => curMiniArr.join(''))
            .join('-');
}

I am not happy having to use Math.ceil. Math.floor can be replicated for (max bitwise safe range) floats by doing myFloat | 0. There must be something that can be done for ceil. (I have had an idea, maybe -(~myFloat), or something on those lines. I am going to try to think of something later.

I had to create the mini arrays holding 3 letters each. I set those up at the start, and have left my mistake in (hashed out to remind me later). When I did (... Array(Math.ceil(numLetters / numInGroup))).fill(()) that used the same array for each of the mini arrays, which was wrong. I had to do (... Array(Math.ceil(numLetters / numInGroup))).map(() => ()) instead to get unique mini arrays.

The function is run with:

var str = CreateMyRandomId(9, 3);

Again, any criticism of this would be much appreciated. I want to get better. I aspire to be as good as all the people on here who answer these type of questions. I aspire to be a guy who answers these questions for others.

I’m a professional data entry operator for $1

I’m a professional data entry operator

I’m a professional data entry operator and I have some experience in data entry , copy paste , pdf to excel , pdf to word and many others and I will charge only $1 for one page and I will finish your work within the time.

.

Evaluating a scalar product of a vector and a differential operator vector

I created a scalar product of a vector $in mathbb{R}^2$ and of a vector consisting of a differential operators

op(t_) = (D(#, {t, 2}) - 3 D(#, t) + 2 #) &;   (1)
delop = {op(t), op(z)}; X = {1, -2};

I would like to apply this scalar product to a function and tried the following (not working solutions)

(X.delop)@Sin(t+z)    (2)
(X.delop) Sin(t+z)

leading to

((D(#1, {t, 2}) - 3 D(#1, t) + 2 #1 & ) - 2 (D(#1, {z, 2}) - 3 D(#1, z) + 2 #1 & ))(Sin(t + z))
((D(#1, {t, 2}) - 3 D(#1, t) + 2 #1 & ) - 2 (D(#1, {z, 2}) - 3 D(#1, z) + 2 #1 & )) Sin(t + z)

How can I evaluate those expressions or directly obtain an evaluated expression in formula (2)?

adjoint functors – Consider the T operator, H^1(0,1) is the Sobolev space, Determine the adjunct T^*

Consider the T operator
Tf = df/dx
in L (0, 1) with the domain :

enter image description hstrong textere

H^1 (0,1) is the Sobolev space.

Determine the adjunct T^* (action and domain). Make the conclusion
about properties of the operator T:

a) Is T self-adjoint ?; b) Is T symmetrical?

differential geometry – Is rank of a linear operator on manifold always constant?

This may sound like a dumb question and I don’t know whether this is a pure Linear Algebraic question or it is a valid Differential geometry question.

Suppose $(M,g)$ is a closed Riemannian manifold and $L_g:V to V$ a linear operator defined on a vector bundle $V$. I want to know whether the rank of $L$ is always constant or it may vary by changing $pin M$? is it changes by changing basis of $V$? and $L_g$ needs more assumption for being of constant rank?