lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2014-04-08 23:14 GMT+02:00 Jeremy Ong <jeremycong@gmail.com>:
>> What's inconsistent, in my opinion, is that an error is not thrown
> when _getting_ a field using those non-retrievable keys, which
> may result in thorny debugging problems as well.

> Sometimes, the inconsistent definition is the useful one. 0! in math
> for example is equal to 1 (ignore the riemann zeta function for the
> sake of discussion). Matrix multiplication is performed with
> row-column inner products.

I can't resist a gap like that :-) Those definitions are actually
consistent.

An empty sum is zero, which is the identity element for addition:
x+0 = x always. An empty product is 1, which is the identity
element for multiplication: x*1=x always. 0! is an empty product.
So too is (-1)!, (-2)! etc.

Matrix multiplication is consistent for a less obvious reason.
Suppose the rule was that you make column-column inner
products, so A and B are compatible for multiplication if
they have the same number of rows. How many columns
must AB have? Same as A or same as B? Choose either,
but you will now find that BA is the transpose of AB. Getting
tricky. What's ABC? (AB)C or A(BC)? Neither is going to
work unless all three matrices as square. So we say: take
the number of rows from A and the number of columns
from B, and that leads you to row-column inner products.