## 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;
``````

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.

## lie groups – Metric of \$SO(3)\$ : Why is there \$frac{1}{8}\$ in front of this scalar product?

I’m considering the rotation group, as described by $$SO(3)$$ (i.e the set of $$3 times 3$$ orthogonal matrices $$R$$ of determinant 1, with real components) and $$SU(2)$$ (the set of $$2 times 2$$ complex matrices $$U$$ of determinant 1). The elements of these two groups could be represented like this (the unit matrix is implied implicitely):
begin{align} R(alpha, n_k) &= 1 cos alpha + sum_{k = 1}^3 lambda_k , n_k sin alpha + n , n^{top} (1 – cos alpha) quad in SO(3), tag{1} \ U(alpha, n_k) &= e^{i vec{sigma} , cdot , vec{n} , alpha / 2} = 1 cos (alpha/2) + i sum_{k = 1}^3 sigma_k , n_k sin (alpha/2) quad in SU(2), tag{2} end{align}
where $$lambda_k$$ ($$k = 1, 2, 3$$) are three $$3 times 3$$ skew-symetrical matrices that generate the rotations, and $$sigma_k$$ are the three $$2 times 2$$ Pauli matrices. The components $$n_k$$ are three real numbers defining the rotation axis. We could write these components as this:
$$n_k = { sinvartheta cos varphi, : sin vartheta sin varphi, : cos vartheta }. tag{3}$$
Of course, $$alpha$$ is the rotation angle.

Now, I define a scalar product in $$SU(2)$$ as a trace:
$$langle , U_1, , U_2 rangle = frac{1}{2} , mathrm{Tr}(U_1^{dagger} , U_2), qquad U_1, , U_2 , in , SU(2).tag{4}$$
Calculating the differential $$dU$$ gives us a metric on $$SU(2)$$ (I set $$chi equiv alpha / 2$$ to simplify things):
$$ds^2 = frac{1}{2} , mathrm{Tr}(dU^{dagger} , dU) = dchi^2 + sin^2 chi , (dvartheta^2 + sin^2 vartheta , dvarphi^2).tag{5}$$
This is a well known metric on $$mathcal{S}_3$$, the 3-sphere. This is fine, since $$SU(2)$$ is a compact Lie group, which have the topology of that sphere.

But then I tried to do the same with $$SO(3)$$ (the calculations are very messy in this case). I got this:
$$frac{1}{8} , mathrm{Tr}(dR^{top} , dR) = dchi^2 + sin^2 chi , (dvartheta^2 + sin^2 vartheta , dvarphi^2).tag{6}$$
The fraction $$frac{1}{8}$$ on the left part puzzles me. Why this factor, instead of $$frac{1}{3}$$? This trace of $$3 times 3$$ matrices doesn’t look like a scalar product. My interpretation of (6) is lacking. How can we define a proper scalar product and Riemanian metric on $$SO(3)$$ that would show the 3-sphere hidden in it?

## linear algebra – Why we can’t subtract scalar product?

We have scalar product property “Distributive over vector addition”: $$(a+b) cdot c=a cdot c space + space b cdot c$$
Now let’s look at this system (we will call it “system-1”):
$$begin{cases} a cdot x leq 1 \ b cdot x leq -1 end{cases}$$
Now if we sum to the second line the first line of the “system-1” we will get (we will call it “system-2”):
$$begin{cases} a cdot x leq 1 \ (a+b) cdot x leq 0 end{cases}$$
So, for the “system-2” we have a solution x=0, but for “system-1” x=0 is not a solution.
Why, if we can subtract and sum lines in the system?

## riemannian geometry – Positive scalar curvature on the double of a manifold (assuming mean convexity of the boundary)

This question is related to a previous one.

Let $$(M^n,g)$$ be a compact Riemannian manifold with boundary. Assume it has positive scalar curvature and $$partial M$$ is mean convex (positive mean curvature).

Question: Is it true that $$DM$$, the double of $$M$$, admits a metric of positive scalar curvature?

## magento2 – Where do scalar extension attributes save to?

Been reading the doc from Magento and i have been using extension attributes for more complex data structures but i’m basically wanting to add a simple scalar attribute

``````  <extension_attributes for="MagentoSalesApiDataShipmentTrackInterface">
<attribute code="track_url" type="string"/>
</extension_attributes>
``````

And i thought for scalar attributes, i pretty much don’t need to do anything else such as adding plugins, just need to set the value correctly and use repository to save

``````        \$shipment = \$this->shipmentRepository->get(\$shipmentId);

\$track = \$this->trackFactory->create()
->setTrackNumber('123')
->setCarrierCode('abc')
->setTitle('super delivery');

\$extensionAttributes = \$track->getExtensionAttributes()->setTrackUrl(
'http://www.trackme.com/abcdef'
);
\$track->setExtensionAttributes(\$extensionAttributes);

\$this->shipmentRepository->save(\$shipment);
``````

Codes are generated correctly, no errors, but when i try to retrieve it, it doesn’t actually return anything

``````\$track->getExtensionAttributes()->getTrackUrl()
``````

Am i misunderstanding extension attributes then? Does it mean i will always need to add something new to the database, even for scalar types?

## sql server – Need Ideas on how to eliminate this scalar funciton or make it faster?

I’m working on pretty lengthy view and one of SQL statements calls a scalar function, which really degrades the performance. The following is the function that is called in a select statement. (sql server 2016)

Really not sure the best ways to modify this process.

Simplified select statement.

``````Select vendorpartid,
dbo.ufn_StockUomQuantityToOrder(vpp.priorityLevel, vpp.monthlyUsageRate, vpp.minimumPurchaseUomOrderQuantity, vpp.purchaseUomConversionFactor, vpp.orderFrequencyDays, vpp.boxQuantity) stockUomQuantityToOrder
FROM vendorpartpriority vpp

ALTER FUNCTION (dbo).(ufn_StockUomQuantityToOrder) (
@priorityLevel decimal(38, 10),
@monthlyUsageRate decimal(38,10),
@minimumPurchaseUomOrderQuantity decimal(38, 10),
@purchaseUomConversion decimal(38, 10),
@orderFrequencyDays decimal(38,10),
@boxQuantity int
)
RETURNS int
WITH SCHEMABINDING
AS
-- Calculate the quantity that needs to be ordered
BEGIN
DECLARE @quantityToOrderDecimal decimal(38, 10) = NULL;
DECLARE @quantityToOrderInt int = NULL;
DECLARE @orderFrequencyMinimumQuantity decimal(38, 10) = NULL;
DECLARE @minimumStockUomOrderQuantity decimal(38,10) = NULL;

--set the default order quantity
SELECT @quantityToOrderDecimal = (-1.0 * @monthlyUsageRate * @priorityLevel);

--get the minimum order quantity in stock UOM
SELECT @minimumStockUomOrderQuantity = (@minimumPurchaseUomOrderQuantity * @purchaseUomConversion);

--calculate the order frequency minimum
IF(@orderFrequencyDays IS NOT NULL AND @monthlyUsageRate IS NOT NULL)
SELECT @orderFrequencyMinimumQuantity = (@monthlyUsageRate * @orderFrequencyDays / 30.0);

--do we need to meet a vendor minimum
IF (@quantityToOrderDecimal IS NULL OR @quantityToOrderDecimal < @minimumStockUomOrderQuantity)
SELECT @quantityToOrderDecimal = @minimumStockUomOrderQuantity;

--do we need to meet an order frequency minimum
IF (@quantityToOrderDecimal IS NULL OR @quantityToOrderDecimal < @orderFrequencyMinimumQuantity)
SELECT @quantityToOrderDecimal = @orderFrequencyMinimumQuantity;

--convert to the int
SELECT @quantityToOrderInt = CAST(CEILING(@quantityToOrderDecimal) AS int);

--did we come up with a number that needs to be an increment of boxQuantity
IF(@quantityToOrderInt IS NOT NULL AND @boxQuantity > 0)
BEGIN
--get the partial box quantity if any
DECLARE @partialBox int = @quantityToOrderInt % @boxQuantity;

--remove the partial box and add a full one (if we are not of box increments)
IF(@partialBox <> 0)
BEGIN
SELECT @quantityToOrderInt = (@quantityToOrderInt - @partialBox + @boxQuantity);
END
END

RETURN @quantityToOrderInt;
END;

GO
``````

2019 isn’t an option now. I have dabbled with the in-line table value, but I’m not quite sure how to get rid of the declares.

I’m not 100% sure on the nulls. My gut says I shouldn’t be passing any values that are nulls, but looks like input table has quite a few in different columns.

Right now I’m trying to make some glaring performance changes until we get time to dismantle the whole process.

## statistics – Derivative of term that involving vectors, transposes, and matrices, with respect to a scalar

I have to differentiate the following expression with respect to $$k$$ and equate it to $$0$$,
$$L=frac{n}{2}mathrm{tr}left(Sigma^{-1}left{S+left({overline{X}}-kmu_0right)left({overline{X}}-kmu_0right)’right}right)$$
where, $$n,Sigma_{ptimes p},{mu_0}_{(ptimes1)},{overline{X}}_{(ptimes1)},S_{(ptimes p)}$$ are known.

The final expression is given as
$$nmu_0Sigma^{-1}left({overline{X}}-kmu_0right)=0.$$

I am not very familiar with differentiation when matrices and vectors are involved. Could I get a basic/general explanation to how to final expression is obtained?

## physics – The Weyl Scalar: does anyone here knows a code to calculate it?

From pure differential geometry we have an important tensor called Weyl Tensor. Its components are given by:

$$C_{ijkl} = R_{ijkl} – frac{2}{n-2}(g_{ik}R_{jl} + g_{jl}R_{ik} – g_{il}R_{jk} – g_{jk}R_{il} ) – frac{2}{(n-1)(n-2)}R(g_{il}g_{jk} – g_{ik}g_{jl}).tag{1}$$

I would like to calculate via a mathematica code the scalar given by:

$$W = C_{ijkl}C^{ijkl} tag{2}$$

Does anyone knows a code for this one calculation $$(2)$$ (given, of course, a metric tensor matrix)?

## python – How to prevent scalar multiplication by odd numbers?

I have a script that does scalar multiplication of points on an Elliptic Curve.

``````class Point(object):
def __init__(self, _x, _y, _order = None): self.x, self.y, self.order = _x, _y, _order
def calc(self, top, bottom, other_x):
l = (top * inverse_mod(bottom)) % p
x3 = (l * l - self.x - other_x) % p
return Point(x3, (l * (self.x - x3) - self.y) % p)
def double(self):
if self == INFINITY: return INFINITY
return self.calc(3 * self.x * self.x, 2 * self.y, self.x)
if other == INFINITY: return self
if self == INFINITY: return other
if self.x == other.x:
if (self.y + other.y) % p == 0: return INFINITY
return self.double()
return self.calc(other.y - self.y, other.x - self.x, other.x)
def __mul__(self, e):
if self.order: e %= self.order
if e == 0 or self == INFINITY: return INFINITY
result, q = INFINITY, self
while e:
if e&1: result += q
e, q = e >> 1, q.double()
return result
def __str__(self):
if self == INFINITY: return "infinity"
return "%x %x" % (self.x, self.y)
def inverse_mod(a):
if a < 0 or a >= p: a = a % p
c, d, uc, vc, ud, vd = a, p, 1, 0, 0, 1
while c:
q, c, d = divmod(d, c) + (c,)
uc, vc, ud, vd = ud - q*uc, vd - q*vc, uc, vc
if ud > 0: return ud
return ud + p

p, INFINITY = 377, Point(None, None)
g = Point(18, 26)
EvenNumber = 2

result = '  Scalar:    %xn   Point: %s' % (EvenNumber, g*EvenNumber)
f = open('Result.txt', 'a')
f.write(result)
f.close()
``````

I cannot understand in more detail the code itself. I need to change the algorithm of this script so that points on the plane of the curve are added only if an even number is specified.

``````I.e:

EvenNumber = 2
EvenNumber = 4
EvenNumber = 6
EvenNumber = 8
EvenNumber = 10
EvenNumber = 12
...
...
...
etc
``````

Is it possible to do so to completely eliminate the odd numbers in scalar multiplication?

## differential equations – Nonlinear PDE – Coefficients do not evaluate to a numerical scalar

I am trying to solve a nonlinear differential equation but I get an error message regarding the coefficients. Please help ..

``````n = 1/2;
cof = ((1/4 (Inactive(D)(u(r, θ), r))^2 +
1/4/r^2 (Inactive(D)(u(r, θ), θ))^2)/2)^((n - 1)/
2);
NDSolveValue({1/r D(cof  r  Inactive(D)(u(r, θ), r), r) +
1/r D(cof  1/r  Inactive(D)(
u(r, θ), θ), θ) == -1,
DirichletCondition(u(r, θ) == 0, True)},
u(r, θ), {r, 0, 1}, {θ, 0, Pi})
``````