Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of matrix-vector division operator of Julia

Tags:

matrix

julia

I stumbled upon something, which I consider very strange.

As an example consider the code

A = reshape(1:6, 3,2)
A/[1 1]

which gives

3×1 Array{Float64,2}:
 2.5
 3.5
 4.5

As I understand, in general such division gives the weighted average of columns, where each weight is inversely proportional to the corresponding element of the vector.

So my question is, why is it defined such way?

What is the mathematical justification of this definition?

like image 662
aberdysh Avatar asked Dec 10 '22 12:12

aberdysh


1 Answers

It's the minimum error solution to |A - v*[1 1]|₂ – which, being overconstrained, has no exact solution in general (i.e. value v such that the norm is precisely zero). The behavior of / and \ is heavily overloaded, solving both under and overconstrained systems by a variety of techniques and heuristics. Whether this kind of overloading is a good idea or not is debatable, but it's what people have come to expect from these operations in Matlab and Octave, and it's often quite convenient to have so much functionality available in a single operator.

like image 93
StefanKarpinski Avatar answered Feb 07 '23 02:02

StefanKarpinski